Documentation ¶
Index ¶
- func ChooseBindAddress(bindAddress net.IP) (net.IP, error)
- func ChooseHostInterface() (net.IP, error)
- func CloneTLSConfig(cfg *tls.Config) *tls.Config
- func FormatURL(scheme string, host string, port int, path string) *url.URL
- func GetClientIP(req *http.Request) net.IP
- func GetHTTPClient(req *http.Request) string
- func IPNetEqual(ipnet1, ipnet2 *net.IPNet) bool
- func IsProbableEOF(err error) bool
- func JoinSchemeNamePort(scheme, name, port string) string
- func NewProxierWithNoProxyCIDR(delegate func(req *http.Request) (*url.URL, error)) func(req *http.Request) (*url.URL, error)
- func SetOldTransportDefaults(t *http.Transport) *http.Transport
- func SetTransportDefaults(t *http.Transport) *http.Transport
- func SplitSchemeNamePort(id string) (scheme, name, port string, valid bool)
- func TLSClientConfig(transport http.RoundTripper) (*tls.Config, error)
- type DialFunc
- type PortRange
- type RoundTripperWrapper
- type Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChooseBindAddress ¶
If 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.
func ChooseHostInterface ¶
ChooseHostInterface 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.
func CloneTLSConfig ¶ added in v1.4.2
CloneTLSConfig 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
func GetClientIP ¶
Extracts 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.
func GetHTTPClient ¶
func IPNetEqual ¶ added in v1.3.0
IPNetEqual checks if the two input IPNets are representing the same subnet. For example,
10.0.0.1/24 and 10.0.0.0/24 are the same subnet. 10.0.0.1/24 and 10.0.0.0/25 are not the same subnet.
func IsProbableEOF ¶
IsProbableEOF 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.
func JoinSchemeNamePort ¶
JoinSchemeNamePort returns a string that specifies the scheme, name, and port:
- "<name>"
- "<name>:<port>"
- "<scheme>:<name>:<port>"
None of the parameters may contain a ':' character Name is required Scheme must be "", "http", or "https"
func NewProxierWithNoProxyCIDR ¶ added in v1.3.0
func NewProxierWithNoProxyCIDR(delegate func(req *http.Request) (*url.URL, error)) func(req *http.Request) (*url.URL, error)
NewProxierWithNoProxyCIDR constructs a Proxier function that respects CIDRs in NO_PROXY and delegates if no matching CIDRs are found
func SetOldTransportDefaults ¶ added in v1.3.0
SetOldTransportDefaults applies the defaults from http.DefaultTransport for the Proxy, Dial, and TLSHandshakeTimeout fields if unset
func SetTransportDefaults ¶
SetTransportDefaults applies the defaults from http.DefaultTransport for the Proxy, Dial, and TLSHandshakeTimeout fields if unset
func SplitSchemeNamePort ¶
SplitSchemeNamePort takes a string of the following forms:
- "<name>", returns "", "<name>","", true
- "<name>:<port>", returns "", "<name>","<port>",true
- "<scheme>:<name>:<port>", returns "<scheme>","<name>","<port>",true
Name 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).
func TLSClientConfig ¶
func TLSClientConfig(transport http.RoundTripper) (*tls.Config, error)
Types ¶
type PortRange ¶
PortRange represents a range of TCP/UDP ports. To represent a single port, set Size to 1.
func ParsePortRange ¶
ParsePortRange parses a string of the form "min-max", inclusive at both ends, and initializs a new PortRange from it.
func ParsePortRangeOrDie ¶
func (*PortRange) Set ¶
Set 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.
type RoundTripperWrapper ¶
type RoundTripperWrapper interface { http.RoundTripper WrappedRoundTripper() http.RoundTripper }