Documentation ¶
Overview ¶
Package net provides functions extending standard library package `net`.
Index ¶
- func AddressContainsPort(addr string) bool
- func FilterIPs(ips []netip.Addr, cidrs []string) ([]netip.Addr, error)
- func FormatAddress(addr string) string
- func FormatCIDR(ip netip.Addr, network netip.Prefix) string
- func NthIPInCIDRSet(cidrList []netip.Prefix, offset int) (out []netip.Addr, err error)
- func NthIPInNetwork(network netip.Prefix, n int) (netip.Addr, error)
- func ParseSubnetOrAddress(subnet string) (netip.Prefix, error)
- func SplitCIDRs(cidrList string) (out []netip.Prefix, err error)
- func ValidateEndpointURI(ep string) error
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 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 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 ParseSubnetOrAddress ¶ added in v0.4.0
ParseSubnetOrAddress parses a CIDR or an IP address, returning a netip.Prefix.
If a bare IP address is passed, it's treated as a CIDR with either /32 or /128 prefix.
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 ¶
This section is empty.