util

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cmp

func Cmp(a, b net.IP) int

Cmp compares two IPs, returning the usual ordering: a < b : -1 a == b : 0 a > b : 1

func FirstIPInSubnet

func FirstIPInSubnet(addr *net.IPNet) (net.IP, error)

FirstIPInSubnet gets the first IP in a subnet

func GenerateNetworkFilters

func GenerateNetworkFilters(f map[string][]string) ([]types.FilterFunc, error)

func GenerateNetworkPruneFilters

func GenerateNetworkPruneFilters(f map[string][]string) ([]types.FilterFunc, error)

func GetLocalIP added in v0.54.0

func GetLocalIP() string

GetLocalIP returns the first non loopback local IPv4 of the host. If no ipv4 address is found it may return an ipv6 address. When no ip is found and empty string is returned.

func GetLocalIPExcluding added in v0.58.1

func GetLocalIPExcluding(exclude []net.IP) string

GetLocalIPExcluding returns the first non loopback local IPv4 of the host. If no ipv4 address is found it may return an ipv6 address. Additionally you can specify a list of ips that should not be returned. When no ip is found and empty string is returned.

func IsIPv4

func IsIPv4(netIP net.IP) bool

IsIPv4 returns true if netIP is IPv4.

func IsIPv6

func IsIPv6(netIP net.IP) bool

IsIPv6 returns true if netIP is IPv6.

func LastIPInSubnet

func LastIPInSubnet(addr *net.IPNet) (net.IP, error)

LastIPInSubnet gets the last IP in a subnet

func NextIP

func NextIP(ip net.IP) net.IP

NextIP returns IP incremented by 1

func NormalizeIP

func NormalizeIP(ip *net.IP)

NormalizeIP will transform the given ip to the 4 byte len ipv4 if possible

func PrevIP

func PrevIP(ip net.IP) net.IP

PrevIP returns IP decremented by 1

Types

This section is empty.

Jump to

Keyboard shortcuts

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