Documentation
¶
Overview ¶
Package netutil provides utility functions for networking, including parsing IP addresses and prefixes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPServerAddr ¶
HTTPServerAddr returns the address of an HTTP server based on the address and port of the server in a form to be used with http.Server.Addr. If the address is unspecified then it will be replaced with an empty string. If the port is 80 then "http" will be appended to the address, if the port is 443 then "https" will be appended to the address, otherwise the numeric port will be used.
func ParseAddrDefaultPort ¶
ParseAddrDefaultPort parses an IP address string. If the address string already contains a port, it is parsed and returned. Otherwise, the supplied default port is used to construct and parse an address with that port. If the address contains only a port an address of "::" is used. ParseAddrDefaultPort calls Resolve to resolve the address before parsing it.
func ParseAddrIgnoringPort ¶
ParseAddrIgnoringPort parses an IP address string and returns the address. If the string is an address with a port, it will be parsed as an address with a port and the address will be returned, ignoring the port. ParseAddrIgnoringPort calls Resolve to resolve the address before parsing it.
func ParseAddrOrPrefix ¶
ParseAddrOrPrefix parses an IP address or prefix string and returns a netip.Prefix. If the string is an IP address without a prefix, it is treated as a full-bit prefix (/32 for IPv4, /128 for IPv6). ParseAddrOrPrefix calls Resolve to resolve the address before parsing it.
Types ¶
This section is empty.