# Functions
AddrFamilyFromRRType returns an AddrFamily appropriate for the DNS resource record type rr.
CloneHostPorts returns a deep copy of hps.
CloneIPs returns a deep clone of ips.
CloneURL returns a deep clone of u.
ExtractReversedAddr searches for an ARPA subdomain within domain and returns the encoded prefix.
IPAndPortFromAddr returns the IP address and the port from addr.
IPFromReversedAddr tries to convert a full reversed ARPA address to a normal IP address.
IPNetToPrefix is a helper that converts a [*net.IPNet] into a [netip.Prefix].
IPNetToPrefixNoMapped is like [IPNetToPrefix] but it detects the address family automatically by assuming that every IPv6-mapped IPv4 address is actually an IPv4 address.
IPToAddr converts a [net.IP] into a [netip.Addr] of the given family and returns a meaningful error.
IPToAddrNoMapped is like [IPToAddr] but it detects the address family automatically by assuming that every IPv6-mapped IPv4 address is actually an IPv4 address.
IPToReversedAddr returns the reversed ARPA address of ip suitable for reverse DNS (PTR) record lookups.
IPv4allrouter returns a new all routers IPv4 address, 224.0.0.2.
IPv4allsys returns a new all systems (aka all hosts) IPv4 address, 224.0.0.1.
IPv4bcast returns a new limited broadcast IPv4 address, 255.255.255.255.
IPv4Localhost returns the IPv4 localhost address "127.0.0.1".
IPv4Zero returns a new unspecified (aka empty or null) IPv4 address, 0.0.0.0.
IPv6Localhost returns the IPv6 localhost address "::1".
IPv6Zero returns a new unspecified (aka empty or null) IPv6 address, [::].
IsImmediateSubdomain returns true if domain is an immediate subdomain of top.
IsLocallyServed checks if ip belongs to any network defined by [RFC 6303]:
10.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 192.0.2.0/24 192.168.0.0/16 198.51.100.0/24 203.0.113.0/24 255.255.255.255/32
::/128 ::1/128 2001:db8::/32 fd00::/8 fe80::/10
It may also be used as a [SubnetSetFunc].
IsSpecialPurpose checks if ip belongs to any network defined by IANA Special-Purpose Address Registry:
0.0.0.0/8 "This host on this network".
IsSubdomain returns true if domain is a subdomain of top.
IsValidHostInnerRune returns true if r is a valid inner—that is, neither initial nor final—rune for a hostname label.
IsValidHostname returns true if name is in accordance to [RFC 952], [RFC 1035], and with [RFC 1123]'s inclusion of digits at the start of the host.
IsValidHostnameLabel returns false if label is not a valid label of a host name.
IsValidHostOuterRune returns true if r is a valid initial or final rune for a hostname label.
IsValidIPString returns true if s is a valid IPv4 or IPv6 address string representation as accepted by [netip.ParseAddr].
JoinHostPort is a convenient wrapper for net.JoinHostPort with port of type uint16.
NetAddrToAddrPort converts a [net.Addr] into a [netip.AddrPort] if it can.
ParseHostPort parses a HostPort from addr.
ParseIP is a wrapper around net.ParseIP that returns a useful error.
ParseIPv4 is a wrapper around net.ParseIP that makes sure that the parsed IP is an IPv4 address and returns a useful error.
PreferIPv4 compares two addresses, preferring IPv4 addresses over IPv6 ones.
PreferIPv6 compares two addresses, preferring IPv6 addresses over IPv4 ones.
PrefixFromReversedAddr tries to convert a reversed ARPA address to an IP address prefix.
SplitHost is a wrapper for [net.SplitHostPort] for cases when the hostport may or may not contain a port.
SplitHostPort is a convenient wrapper for [net.SplitHostPort] with port of type uint16.
Subdomains returns all subdomains of domain, starting from domain itself.
UnembedPrefixes returns a slice of [netip.Prefix] from embed slice.
ValidateDomainName validates the domain name in accordance to [RFC 1035] and [RFC 3696 Section 2].
ValidateDomainNameLabel returns an error if label is not a valid label of a domain name.
ValidateHostname validates the domain name in accordance to [RFC 952], [RFC 1035], and with [RFC 1123]'s inclusion of digits at the start of the host.
ValidateHostnameLabel returns an error if label is not a valid label of a host name.
ValidateIP returns an error if ip is not a valid IPv4 or IPv6 address.
ValidateMAC returns an error if mac is not a valid EUI-48, EUI-64, or 20-octet InfiniBand link-layer address.
ValidateServiceNameLabel returns an error if label is not a valid label of a service domain name.
ValidateSRVDomainName validates name assuming it belongs to the superset of service domain names in accordance to [RFC 2782] and [RFC 6763].
ValidateTLDLabel validates a top-level domain label in accordance to [RFC 3696 Section 2].
ZeroPrefix returns an IP subnet with prefix 0 and all bytes of the IP address set to 0.
# Constants
An incomplete list of IANA address family numbers.
An incomplete list of IANA address family numbers.
An incomplete list of IANA address family numbers.
Kinds of addresses for [AddrError].
Kinds of addresses for [AddrError].
Kinds of addresses for [AddrError].
Kinds of addresses for [AddrError].
Kinds of addresses for [AddrError].
Kinds of addresses for [AddrError].
Kinds of addresses for [AddrError].
Kinds of addresses for [AddrError].
Kinds of addresses for [AddrError].
Kinds of addresses for [AddrError].
ErrNotAReversedIP is the underlying error returned from validation functions when a domain name is not a full reversed IP address.
ErrNotAReversedSubnet is the underlying error returned from validation functions when a domain name is not a valid reversed IP network.
Bit lengths of IP addresses.
Bit lengths of IP addresses.
Kinds of labels for [LabelError].
Kinds of labels for [LabelError].
Kinds of labels for [LabelError].
Kinds of labels for [LabelError].
MaxDomainLabelLen is the maximum allowed length of a domain name label according to [RFC 1035].
MaxDomainNameLen is the maximum allowed length of a full domain name according to [RFC 1035].
MaxServiceLabelLen is the maximum allowed length of a service name label according to [RFC 6335].
# Structs
AddrError is the underlying type of errors returned from validation functions when a domain name is invalid.
HostPort is a convenient type for addresses that contain a hostname and a port, like "example.com:12345", "1.2.3.4:56789", or "[1234::cdef]:12345".
LabelError is the underlying type of errors returned from validation functions when a label of a name is invalid.
LengthError is the underlying type of errors returned from validation functions when an address or a part of an address has a bad length.
Prefix is a wrapper for [netip.Prefix] providing more functionality in encoding.
RuneError is the underlying type of errors returned from validation functions when a rune in the address is invalid.
# Interfaces
SubnetSet represents a set of IP networks used to determine if an IP address belongs to any of them.
# Type aliases
AddrFamily is the type for IANA address family numbers.
AddrKind is a convenient alias for string describing the kind of address and used for error reporting.
LabelKind is a convenient alias for string describing the kind of label of a name and used for error reporting.
SliceSubnetSet is the [SubnetSet] that checks the address through a slice of [netip.Prefix].
SubnetSetFunc is the [SubnetSet] that checks the address with the function determining if the given ip belongs to the set of subnets.