network

package
v0.0.0-...-1d35728 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	IPv4 = iota
	IPv6
	UNKNOWN
)

Variables

View Source
var ErrResolveNoAddress = fmt.Errorf("no address specified")

ErrResolveNoAddress error occurs when IP address resolution is attempted, but no address was provided.

Functions

func AllIPv4

func AllIPv4(ipAddrs []string) bool

AllIPv4 checks the addresses slice and returns true if all addresses are valid IPv4 address, for all other cases it returns false.

func AllIPv6

func AllIPv6(ipAddrs []string) bool

AllIPv6 checks the addresses slice and returns true if all addresses are valid IPv6 address, for all other cases it returns false.

func GetPrivateIPs

func GetPrivateIPs(ctx context.Context) ([]string, bool)

GetPrivateIPs blocks until private IP addresses are available, or a timeout is reached.

func GetPrivateIPsIfAvailable

func GetPrivateIPsIfAvailable() ([]string, bool)

GetPrivateIPsIfAvailable returns all the private IP addresses

func GlobalUnicastIP

func GlobalUnicastIP(ipAddrs []string) string

GlobalUnicastIP returns the first global unicast address in the passed in addresses.

func ResolveAddr

func ResolveAddr(addr string, lookupIPAddr ...lookupIPAddrType) (string, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL