networkutils

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: Apache-2.0 Imports: 8 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 soft check to see if there are any services listening on a selection of common ports at ip by trying to establish a TCP connection. Ports checked include: 22, 23, 80, 443 and 6443 (Kubernetes API Server). Each connection attempt allows up-to 500ms for a response.

todo(chrisdoherty) change to an icmp approach to eliminate the need for ports.

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