apimachinery: k8s.io/apimachinery/pkg/util/net Index | Files

package net

import "k8s.io/apimachinery/pkg/util/net"

Index

Package Files

http.go interface.go port_range.go port_split.go util.go

func AppendForwardedForHeader Uses

func AppendForwardedForHeader(req *http.Request)

Prepares the X-Forwarded-For header for another forwarding hop by appending the previous sender's IP address to the X-Forwarded-For chain.

func ChooseBindAddress Uses

func ChooseBindAddress(bindAddress net.IP) (net.IP, error)

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 Uses

func ChooseHostInterface() (net.IP, error)

ChooseHostInterface is a method used fetch an IP for a daemon. If there is no routing info file, it will choose a global IP from the system interfaces. Otherwise, it will use IPv4 and IPv6 route information to return the IP of the interface with a gateway on it (with priority given to IPv4). For a node with no internet connection, it returns error.

func CloneHeader Uses

func CloneHeader(in http.Header) http.Header

CloneHeader creates a deep copy of an http.Header.

func CloneRequest Uses

func CloneRequest(req *http.Request) *http.Request

CloneRequest creates a shallow copy of the request along with a deep copy of the Headers.

func ConnectWithRedirects Uses

func ConnectWithRedirects(originalMethod string, originalLocation *url.URL, header http.Header, originalBody io.Reader, dialer Dialer, requireSameHostRedirects bool) (net.Conn, []byte, error)

ConnectWithRedirects uses dialer to send req, following up to 10 redirects (relative to originalLocation). It returns the opened net.Conn and the raw response bytes. If requireSameHostRedirects is true, only redirects to the same host are permitted.

func FormatURL Uses

func FormatURL(scheme string, host string, port int, path string) *url.URL

func GetClientIP Uses

func GetClientIP(req *http.Request) net.IP

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 Uses

func GetHTTPClient(req *http.Request) string

func IPNetEqual Uses

func IPNetEqual(ipnet1, ipnet2 *net.IPNet) bool

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 IsConnectionReset Uses

func IsConnectionReset(err error) bool

Returns if the given err is "connection reset by peer" error.

func IsNoRoutesError Uses

func IsNoRoutesError(err error) bool

IsNoRoutesError checks if an error is of type noRoutesError

func IsProbableEOF Uses

func IsProbableEOF(err error) bool

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 JoinPreservingTrailingSlash Uses

func JoinPreservingTrailingSlash(elem ...string) string

JoinPreservingTrailingSlash does a path.Join of the specified elements, preserving any trailing slash on the last non-empty segment

func JoinSchemeNamePort Uses

func JoinSchemeNamePort(scheme, name, port string) string

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 Uses

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 Uses

func SetOldTransportDefaults(t *http.Transport) *http.Transport

SetOldTransportDefaults applies the defaults from http.DefaultTransport for the Proxy, Dial, and TLSHandshakeTimeout fields if unset

func SetTransportDefaults Uses

func SetTransportDefaults(t *http.Transport) *http.Transport

SetTransportDefaults applies the defaults from http.DefaultTransport for the Proxy, Dial, and TLSHandshakeTimeout fields if unset

func SourceIPs Uses

func SourceIPs(req *http.Request) []net.IP

SourceIPs splits the comma separated X-Forwarded-For header or returns the X-Real-Ip header or req.RemoteAddr, in that order, ignoring invalid IPs. It returns nil if all of these are empty or invalid.

func SplitSchemeNamePort Uses

func SplitSchemeNamePort(id string) (scheme, name, port string, valid bool)

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 Uses

func TLSClientConfig(transport http.RoundTripper) (*tls.Config, error)

type AddressFamily Uses

type AddressFamily uint

type DialFunc Uses

type DialFunc func(ctx context.Context, net, addr string) (net.Conn, error)

func DialerFor Uses

func DialerFor(transport http.RoundTripper) (DialFunc, error)

type Dialer Uses

type Dialer interface {
    // Dial connects to the host specified by req's URL, writes the request to the connection, and
    // returns the opened net.Conn.
    Dial(req *http.Request) (net.Conn, error)
}

Dialer dials a host and writes a request to it.

type DialerFunc Uses

type DialerFunc func(req *http.Request) (net.Conn, error)

DialerFunc implements Dialer for the provided function.

func (DialerFunc) Dial Uses

func (fn DialerFunc) Dial(req *http.Request) (net.Conn, error)

type PortRange Uses

type PortRange struct {
    Base int
    Size int
}

PortRange represents a range of TCP/UDP ports. To represent a single port, set Size to 1.

func ParsePortRange Uses

func ParsePortRange(value string) (*PortRange, error)

ParsePortRange parses a string of the form "min-max", inclusive at both ends, and initializs a new PortRange from it.

func ParsePortRangeOrDie Uses

func ParsePortRangeOrDie(value string) *PortRange

func (*PortRange) Contains Uses

func (pr *PortRange) Contains(p int) bool

Contains tests whether a given port falls within the PortRange.

func (*PortRange) Set Uses

func (pr *PortRange) Set(value string) error

Set parses a string of the form "value", "min-max", or "min+offset", inclusive at both ends, and sets the PortRange from it. This is part of the flag.Value and pflag.Value interfaces.

func (PortRange) String Uses

func (pr PortRange) String() string

String converts the PortRange to a string representation, which can be parsed by PortRange.Set or ParsePortRange.

func (*PortRange) Type Uses

func (*PortRange) Type() string

Type returns a descriptive string about this type. This is part of the pflag.Value interface.

type RoundTripperWrapper Uses

type RoundTripperWrapper interface {
    http.RoundTripper
    WrappedRoundTripper() http.RoundTripper
}

type Route Uses

type Route struct {
    Interface   string
    Destination net.IP
    Gateway     net.IP
    Family      AddressFamily
}

type RouteFile Uses

type RouteFile struct {
    // contains filtered or unexported fields
}

type TLSClientConfigHolder Uses

type TLSClientConfigHolder interface {
    TLSClientConfig() *tls.Config
}

Package net imports 19 packages (graph) and is imported by 897 packages. Updated 2019-01-26. Refresh now. Tools for package owners.