Documentation
¶
Overview ¶
Package netaddr parses host and port strings, picks local and outbound IP addresses, builds bind addresses and routes lookups to a custom DNS server.
Index ¶
- func BuildTCPBindAddr(localIP string) net.Addr
- func BuildUDPBindAddr(localIP string) *net.UDPAddr
- func ExtractHost(input string) string
- func FormatAddress(s string) string
- func GetOutboundIP() net.IP
- func GetOutboundIPv4() net.IP
- func GetOutboundIPv6() net.IP
- func GetPorts(s string) []int
- func GetServerIp(ip string) string
- func Host(s string) string
- func IsPublicHost(addr string) bool
- func IsZeroIP(ip net.IP) bool
- func LocalUDP4IP() (net.IP, error)
- func LocalUDP6IP() (net.IP, error)
- func NormalizeIP(ip net.IP) net.IP
- func ParseIP(s string) (netip.Addr, bool)
- func PickEgressIPFor(dstIP net.IP) net.IP
- func Port(s string) int
- func SetCustomDNS(dnsAddr string)
- func SplitAddrAndHost(s string) (addr, host, sni string)
- func SplitServerAndPath(s string) (server, path string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildTCPBindAddr ¶
func BuildUDPBindAddr ¶
func ExtractHost ¶
ExtractHost returns the host and port of input, a URL or an address, e.g. "[2001:db8::1]:80".
func FormatAddress ¶
FormatAddress if the s is just a port,return 127.0.0.1:s
func GetOutboundIP ¶
func GetOutboundIPv4 ¶
func GetOutboundIPv6 ¶
func GetServerIp ¶
func Host ¶
Host returns the host of s, an address given as "host", "host:port", "[ipv6]" or "[ipv6]:port", without brackets and with any zone kept. A bare IPv6 address such as "2001:db8::1" is a host without a port. The port is not checked. It returns "" for an empty host or an unclosed or trailing bracket, such as "[::1" or "[::1]x".
func IsPublicHost ¶
func LocalUDP4IP ¶
LocalUDP4IP returns the preferred local IPv4 egress IP.
func LocalUDP6IP ¶
LocalUDP6IP returns the preferred local IPv6 egress IP.
func ParseIP ¶
ParseIP reads an IP address given alone or as host:port, with IPv6 in brackets and a port in 0-65535. A zone and an IPv4-mapped IPv6 form are kept.
func SetCustomDNS ¶
func SetCustomDNS(dnsAddr string)
func SplitAddrAndHost ¶
func SplitServerAndPath ¶
Types ¶
This section is empty.