Documentation
¶
Overview ¶
Package net provides functions extending standard library package `net`.
Index ¶
- func AddressContainsPort(addr string) bool
- func DNSNames() (dnsNames []string, err error)
- func DomainName() (domainname string, err error)
- func FilterIPs(ips []net.IP, cidrs []string) ([]net.IP, error)
- func FormatAddress(addr string) string
- func FormatCIDR(ip net.IP, network net.IPNet) string
- func IPAddrs() (ips []net.IP, err error)
- func IPFilter(addrs []net.IP, filters ...IPFilterFunc) (result []net.IP)
- func IsIPv6(addrs ...net.IP) bool
- func IsNonLocalIPv6(in net.IP) bool
- func NthIPInCIDRSet(cidrList []*net.IPNet, offset int) (out []net.IP, err error)
- func NthIPInNetwork(network *net.IPNet, n int) (net.IP, error)
- func ParseCIDR(in string) (*net.IPNet, error)
- func SplitCIDRs(cidrList string) (out []*net.IPNet, err error)
- func ValidateEndpointURI(ep string) error
- type IPFilterFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddressContainsPort ¶
AddressContainsPort checks to see if the supplied address contains both an address and a port. This will not catch every possible permutation, but it is a best-effort routine suitable for prechecking human-interactive parameters.
func DNSNames ¶
DNSNames returns a default set of machine names. It includes the hostname, and FQDN if the kernel domain name is set. If the kernel domain name is not set, only the hostname is included in the set.
func DomainName ¶
DomainName returns the kernel domain name. If a domain name is not found, an empty string is returned.
func FilterIPs ¶
FilterIPs filters list of IPs with the list of subnets.
Each subnet can be either regular match or negative match (if prefixed with '!').
func FormatAddress ¶
FormatAddress checks that the address has a consistent format.
func FormatCIDR ¶
FormatCIDR formats IP from the network as CIDR notation.
func IPAddrs ¶
IPAddrs finds and returns a list of non-loopback IP addresses of the current machine.
func IPFilter ¶
func IPFilter(addrs []net.IP, filters ...IPFilterFunc) (result []net.IP)
IPFilter filters list of IP addresses by applying sequence of filters.
If any of the filters returns false, address is skipped.
func IsNonLocalIPv6 ¶
IsNonLocalIPv6 indicates whether provided address is non-local IPv6 address.
func NthIPInCIDRSet ¶
NthIPInCIDRSet returns nth IP for each CIDR in the list.
func NthIPInNetwork ¶
NthIPInNetwork takes an IPNet and returns the nth IP in it.
func ParseCIDR ¶
ParseCIDR parses a CIDR-formatted IP address. Unlike the standard library version, this will return the IP address itself, rather than the bare IP and the network address. If no CIDR notation is supplied, the address is presumed to be on a solo network (/32 for IPv4 or /128 for IPv6). NOTE: Unlike rtnl.ParseCIDR, this allows network addresses, since in many places in the kubernetes ecosystem, the functionality of a "network address" is not used and improperly prevents the use of an entire range of IP addresses.
func SplitCIDRs ¶
SplitCIDRs parses list of CIDRs in a string separated by commas.
func ValidateEndpointURI ¶
ValidateEndpointURI checks that an endpoint is valid. This is a more strict check that merely `url.Parse`, in that it requires such things as properly-ranged numeric ports and bracket-enclosed IPv6 addresses.
Types ¶
type IPFilterFunc ¶
IPFilterFunc filters IP addresses.
List of IPFilterFuncs is applied with AND logic: all filters should return true for the IP address to be included in the response.