netutil

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2022 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIP

func GetLocalIP() (string, error)

GetLocalIP returns the non loopback local IP of the host

func IsAddrInUse

func IsAddrInUse(err error) bool

IsAddrInUse checks whether the given error indicates "address in use"

func IsPrivateAddress

func IsPrivateAddress(address string) (bool, error)

IsPrivateAddress works by checking if the address is under private CIDR blocks. List of private CIDR blocks can be seen on :

https://en.wikipedia.org/wiki/Private_network

https://en.wikipedia.org/wiki/Link-local_address

func JoinURLs

func JoinURLs(list []*url.URL) string

JoinURLs returns coma-separated lists of URLs in string format

func ParseURLs

func ParseURLs(list []string) ([]*url.URL, error)

ParseURLs creates a list of URLs from lists of hosts

func ParseURLsFromString

func ParseURLsFromString(hosts string) ([]*url.URL, error)

ParseURLsFromString creates a list of URLs from a coma-separated lists of hosts

func WaitForNetwork

func WaitForNetwork(d time.Duration) (ipaddr string, err error)

WaitForNetwork will wait until the local IP is available or timeout ocurred

Types

type GetNodeNameFn

type GetNodeNameFn func(hostname string) string

GetNodeNameFn is an interface to return an application specific node name from the host name.

type NodeInfo

type NodeInfo interface {
	HostName() string
	LocalIP() string
	NodeName() string
}

NodeInfo is an interface to provide host and IP address for the node in the cluster.

func NewNodeInfo

func NewNodeInfo(extractor GetNodeNameFn) (NodeInfo, error)

NewNodeInfo constructs node info using provided extractor function. If extractor is nil, then host name is used.

Jump to

Keyboard shortcuts

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