networkutils

package
v0.14.6 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLocalIP added in v0.9.2

func GetLocalIP() (net.IP, error)

func IsIPInUse added in v0.9.0

func IsIPInUse(client NetClient, ip string) bool

IsIPInUse performs a best effort check to see if an IP address is in use. It is not completely reliable as testing if an IP is in use is inherently difficult, particularly with non-trivial network topologies.

func IsPortInUse added in v0.12.0

func IsPortInUse(client NetClient, host string, port string) bool

func IsPortValid added in v0.7.0

func IsPortValid(port string) bool

func ValidateIP added in v0.8.0

func ValidateIP(ip string) error

Types

type DefaultNetClient

type DefaultNetClient struct{}

func (*DefaultNetClient) DialTimeout

func (n *DefaultNetClient) DialTimeout(network, address string, timeout time.Duration) (net.Conn, error)

type IPGenerator

type IPGenerator struct {
	// contains filtered or unexported fields
}

func NewIPGenerator

func NewIPGenerator(netClient NetClient) IPGenerator

func (IPGenerator) GenerateUniqueIP

func (ipgen IPGenerator) GenerateUniqueIP(cidrBlock string) (string, error)

type IPPool added in v0.7.1

type IPPool []string

func NewIPPool added in v0.7.1

func NewIPPool() IPPool

func NewIPPoolFromEnv added in v0.7.1

func NewIPPoolFromEnv(ipPoolEnvVar string) (IPPool, error)

func NewIPPoolFromString added in v0.7.1

func NewIPPoolFromString(fromString string) IPPool

func (*IPPool) AddIP added in v0.7.1

func (ipPool *IPPool) AddIP(ip string)

func (*IPPool) IsEmpty added in v0.7.1

func (ipPool *IPPool) IsEmpty() bool

func (*IPPool) PopIP added in v0.7.1

func (ipPool *IPPool) PopIP() (string, error)

func (*IPPool) ToEnvVar added in v0.7.1

func (ipPool *IPPool) ToEnvVar(envVarName string) error

func (*IPPool) ToString added in v0.7.1

func (ipPool *IPPool) ToString() string

type NetClient

type NetClient interface {
	DialTimeout(network, address string, timeout time.Duration) (net.Conn, error)
}

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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