Documentation ¶
Index ¶
- Constants
- Variables
- func AllIPv4(ipAddrs []string) bool
- func AllIPv6(ipAddrs []string) bool
- func GetPrivateIPs(ctx context.Context) ([]string, bool)
- func GetPrivateIPsIfAvailable() ([]string, bool)
- func GlobalUnicastIP(ipAddrs []string) string
- func ResolveAddr(addr string, lookupIPAddr ...lookupIPAddrType) (string, error)
- type IPFamilyType
Constants ¶
const ( IPv4 = iota IPv6 UNKNOWN )
Variables ¶
var ErrResolveNoAddress = fmt.Errorf("no address specified")
ErrResolveNoAddress error occurs when IP address resolution is attempted, but no address was provided.
Functions ¶
func AllIPv4 ¶
AllIPv4 checks the addresses slice and returns true if all addresses are valid IPv4 address, for all other cases it returns false.
func AllIPv6 ¶
AllIPv6 checks the addresses slice and returns true if all addresses are valid IPv6 address, for all other cases it returns false.
func GetPrivateIPs ¶
GetPrivateIPs blocks until private IP addresses are available, or a timeout is reached.
func GetPrivateIPsIfAvailable ¶
GetPrivateIPsIfAvailable returns all the private IP addresses
func GlobalUnicastIP ¶
GlobalUnicastIP returns the first global unicast address in the passed in addresses.
func ResolveAddr ¶
ResolveAddr resolves an authority address to an IP address. Incoming addr can be an IP address or hostname. If addr is an IPv6 address, the IP part must be enclosed in square brackets.
LookupIPAddr() may return multiple IP addresses, of which this function returns the first IPv4 entry. To use this function in an IPv6 only environment, either provide an IPv6 address or ensure the hostname resolves to only IPv6 addresses.
Types ¶
type IPFamilyType ¶
type IPFamilyType int
ip family enum
func CheckIPFamilyTypeForFirstIPs ¶
func CheckIPFamilyTypeForFirstIPs(ipAddrs []string) (IPFamilyType, error)
CheckIPFamilyTypeForFirstIPs checks the ip family type for the first ip addresses