net

package
v21.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CIDROverlap

func CIDROverlap(n1, n2 net.IPNet) bool

CIDROverlap VPL: Not used ? duplicate with DoCIDRsIntersect CIDROverlap tells if the 2 CIDR passed as parameter intersect

func CIDRToIPv4Range

func CIDRToIPv4Range(cidr string) (string, string, fail.Error)

CIDRToIPv4Range converts CIDR to IPv4 range

func CIDRToUInt32Range

func CIDRToUInt32Range(cidr string) (uint32, uint32, fail.Error)

CIDRToUInt32Range converts CIDR to IPv4 range

func CheckRemoteTCP added in v21.11.1

func CheckRemoteTCP(ip string, port int) bool

CheckRemoteTCP returns true if ip:port is listening, false otherwise

func FirstIncludedSubnet

func FirstIncludedSubnet(base net.IPNet, maskAddition uint8) (net.IPNet, fail.Error)

FirstIncludedSubnet takes a parent CIDR range and gives the first subnet within it with the given number of additional prefix bits 'maskAddition'.

For example, 192.168.0.0/16, extended by 8 bits becomes 192.168.0.0/24.

func IPv4StringToUInt32

func IPv4StringToUInt32(ip string) uint32

IPv4StringToUInt32 converts IPv4 to uint32

func IPv4ToUInt32

func IPv4ToUInt32(ip net.IP) uint32

IPv4ToUInt32 converts net.IP to uint32

func IsCIDRRoutable

func IsCIDRRoutable(cidr string) (bool, fail.Error)

IsCIDRRoutable tells if the network is routable

func IsConnectionRefused

func IsConnectionRefused(err error) bool

IsConnectionRefused returns true if given err is a "connection refused" error

func IsConnectionReset

func IsConnectionReset(err error) bool

IsConnectionReset returns true if given err is a "reset by peer" error

func NthIncludedSubnet

func NthIncludedSubnet(base net.IPNet, maskAddition uint8, nth uint) (net.IPNet, fail.Error)

NthIncludedSubnet takes a parent CIDR range and gives the 'nth' subnet within it with the given numver of additional prefix bits 'maskAddition'

For example, 192.168.0.0/16, extended by 8 bits gives as 4th subnet 192.168.4.0/24.

func UInt32ToIPv4

func UInt32ToIPv4(value uint32) net.IP

UInt32ToIPv4 converts uint32 to net.IP

func UInt32ToIPv4String

func UInt32ToIPv4String(value uint32) string

UInt32ToIPv4String converts uint32 to IP

func WhileCommunicationUnsuccessfulDelay1Second

func WhileCommunicationUnsuccessfulDelay1Second(callback func() error, timeout time.Duration) fail.Error

WhileCommunicationUnsuccessfulDelay1Second executes callback inside a retry loop with tolerance for communication errors (relative to net package), waiting 1 second between each try, with a limit of 'timeout'

func WhileUnsuccessfulButRetryable

func WhileUnsuccessfulButRetryable(callback func() error, waiter *retry.Officer, timeout time.Duration, options ...retry.Option) fail.Error

WhileUnsuccessfulButRetryable executes callback inside a retry loop with tolerance for communication errors (relative to net package), or some fail.Error that are considered retryable: asking "waiter" to wait between each try, with a duration limit of 'timeout'.

Types

type CIDRString

type CIDRString string

CIDRString string representing a CIDR

func (CIDRString) Contains

func (cs CIDRString) Contains(cidr CIDRString) (bool, error)

Contains tells if 'cs' contains 'cidr'

func (CIDRString) IntersectsWith

func (cs CIDRString) IntersectsWith(cidr CIDRString) (bool, error)

IntersectsWith tells if the 2 cidr intersects

Jump to

Keyboard shortcuts

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