{"modulePath":"github.com/UnityTech/client-go","version":"v2.0.0+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package net\n\n## Functions\n\n```go\nfunc ChooseBindAddress(bindAddress net.IP) (net.IP, error)\n```\nIf bind-address is usable, return it directly If bind-address is not usable (unset, 0.0.0.0, or loopback), we will use the host's default interface.\n\n```go\nfunc ChooseHostInterface() (net.IP, error)\n```\nChooseHostInterface is a method used fetch an IP for a daemon. It uses data from /proc/net/route file. For a node with no internet connection ,it returns error For a multi n/w interface node it returns the IP of the interface with gateway on it.\n\n```go\nfunc CloneTLSConfig(cfg *tls.Config) *tls.Config\n```\nCloneTLSConfig returns a tls.Config with all exported fields except SessionTicketsDisabled and SessionTicketKey copied. This makes it safe to call CloneTLSConfig on a config in active use by a server. TODO: replace with tls.Config#Clone when we move to go1.8\n\n```go\nfunc FormatURL(scheme string, host string, port int, path string) *url.URL\n```\n\n```go\nfunc GetClientIP(req *http.Request) net.IP\n```\nExtracts and returns the clients IP from the given request. Looks at X-Forwarded-For header, X-Real-Ip header and request.RemoteAddr in that order. Returns nil if none of them are set or is set to an invalid value.\n\n```go\nfunc GetHTTPClient(req *http.Request) string\n```\n\n```go\nfunc IPNetEqual(ipnet1, ipnet2 *net.IPNet) bool\n```\nIPNetEqual checks if the two input IPNets are representing the same subnet. For example,\n\n\t10.0.0.1/24 and 10.0.0.0/24 are the same subnet.\n\t10.0.0.1/24 and 10.0.0.0/25 are not the same subnet.\n\n```go\nfunc IsProbableEOF(err error) bool\n```\nIsProbableEOF returns true if the given error resembles a connection termination scenario that would justify assuming that the watch is empty. These errors are what the Go http stack returns back to us which are general connection closure errors (strongly correlated) and callers that need to differentiate probable errors in connection behavior between normal \"this is disconnected\" should use the method.\n\n```go\nfunc JoinSchemeNamePort(scheme, name, port string) string\n```\nJoinSchemeNamePort returns a string that specifies the scheme, name, and port:\n\n  - \"\\\u003cname\u003e\"\n  - \"\\\u003cname\u003e:\\\u003cport\u003e\"\n  - \"\\\u003cscheme\u003e:\\\u003cname\u003e:\\\u003cport\u003e\"\n\nNone of the parameters may contain a ':' character Name is required Scheme must be \"\", \"http\", or \"https\"\n\n```go\nfunc NewProxierWithNoProxyCIDR(delegate func(req *http.Request) (*url.URL, error)) func(req *http.Request) (*url.URL, error)\n```\nNewProxierWithNoProxyCIDR constructs a Proxier function that respects CIDRs in NO\\_PROXY and delegates if no matching CIDRs are found\n\n```go\nfunc SetOldTransportDefaults(t *http.Transport) *http.Transport\n```\nSetOldTransportDefaults applies the defaults from http.DefaultTransport for the Proxy, Dial, and TLSHandshakeTimeout fields if unset\n\n```go\nfunc SetTransportDefaults(t *http.Transport) *http.Transport\n```\nSetTransportDefaults applies the defaults from http.DefaultTransport for the Proxy, Dial, and TLSHandshakeTimeout fields if unset\n\n```go\nfunc SplitSchemeNamePort(id string) (scheme, name, port string, valid bool)\n```\nSplitSchemeNamePort takes a string of the following forms:\n\n  - \"\\\u003cname\u003e\",                 returns \"\",        \"\\\u003cname\u003e\",\"\",      true\n  - \"\\\u003cname\u003e:\\\u003cport\u003e\",          returns \"\",        \"\\\u003cname\u003e\",\"\\\u003cport\u003e\",true\n  - \"\\\u003cscheme\u003e:\\\u003cname\u003e:\\\u003cport\u003e\", returns \"\\\u003cscheme\u003e\",\"\\\u003cname\u003e\",\"\\\u003cport\u003e\",true\n\nName must be non-empty or valid will be returned false. Scheme must be \"http\" or \"https\" if specified Port is returned as a string, and it is not required to be numeric (could be used for a named port, for example).\n\n```go\nfunc TLSClientConfig(transport http.RoundTripper) (*tls.Config, error)\n```\n\n## Types\n\n```go\ntype DialFunc func(net, addr string) (net.Conn, error)\n```\n\n```go\nfunc Dialer(transport http.RoundTripper) (DialFunc, error)\n```\n\n```go\ntype PortRange struct {\n\tBase int\n\tSize int\n}\n```\nPortRange represents a range of TCP/UDP ports.  To represent a single port, set Size to 1.\n\n```go\nfunc ParsePortRange(value string) (*PortRange, error)\n```\nParsePortRange parses a string of the form \"min-max\", inclusive at both ends, and initializs a new PortRange from it.\n\n```go\nfunc ParsePortRangeOrDie(value string) *PortRange\n```\n\n```go\nfunc (pr *PortRange) Contains(p int) bool\n```\nContains tests whether a given port falls within the PortRange.\n\n```go\nfunc (pr *PortRange) Set(value string) error\n```\nSet parses a string of the form \"min-max\", inclusive at both ends, and sets the PortRange from it.  This is part of the flag.Value and pflag.Value interfaces.\n\n```go\nfunc (pr PortRange) String() string\n```\nString converts the PortRange to a string representation, which can be parsed by PortRange.Set or ParsePortRange.\n\n```go\nfunc (*PortRange) Type() string\n```\nType returns a descriptive string about this type.  This is part of the pflag.Value interface.\n\n```go\ntype RoundTripperWrapper interface {\n\thttp.RoundTripper\n\tWrappedRoundTripper() http.RoundTripper\n}\n```\n\n```go\ntype Route struct {\n\tInterface   string\n\tDestination net.IP\n\tGateway     net.IP\n}\n```\n\n","path":"github.com/UnityTech/client-go/pkg/util/net","name":"net","synopsis":"","isRedistributable":true}
