ip

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidIPVersion     = errors.New("invalid IP version")
	ErrInvalidIPRangeFormat = errors.New("invalid IP range format")
	ErrInvalidIPFormat      = errors.New("invalid IP format")
	ErrInvalidCIDRFormat    = errors.New("invalid CIDR format")
)

Functions

func Cmp

func Cmp(ip1, ip2 net.IP) int

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

func ContainsIP added in v0.0.5

func ContainsIP(version types.IPVersion, subnet string, ip string) (bool, error)

func ContainsIPRange added in v0.0.5

func ContainsIPRange(version types.IPVersion, subnet string, ipRange string) (bool, error)

func IPsDiffSet

func IPsDiffSet(ips1, ips2 []net.IP) []net.IP

func IsCIDR added in v0.0.5

func IsCIDR(version types.IPVersion, subnet string) error

func IsCIDROverlap added in v0.0.5

func IsCIDROverlap(version types.IPVersion, subnet1, subnet2 string) (bool, error)

func IsIP added in v0.0.5

func IsIP(version types.IPVersion, s string) error

func IsIPRange added in v0.0.5

func IsIPRange(version types.IPVersion, ipRange string) error

IsIPRange check the format for the given ip range. it can be a single one just like '192.168.1.0', and it also could be an IP range just like '192.168.1.0-192.168.1.10'. Notice: the following formats are invalid 1. '192.168.1.0 - 192.168.1.10', there can not be space between two IP. 2. '192.168.1.1-2001:db8:a0b:12f0::1', the combination with one IPv4 and IPv6 is invalid. 3. '192.168.1.10-192.168.1.1', the IP range must be ordered.

func IsIPVersion added in v0.0.5

func IsIPVersion(version types.IPVersion) error

func IsIPv4CIDR added in v0.0.5

func IsIPv4CIDR(subnet string) bool

func IsIPv4IPRange added in v0.0.5

func IsIPv4IPRange(ipRange string) bool

func IsIPv6CIDR added in v0.0.5

func IsIPv6CIDR(subnet string) bool

func IsIPv6IPRange added in v0.0.5

func IsIPv6IPRange(ipRange string) bool

func NextIP

func NextIP(ip net.IP) net.IP

func ParseCIDR added in v0.0.5

func ParseCIDR(version types.IPVersion, subnet string) (*net.IPNet, error)

func ParseIP

func ParseIP(version types.IPVersion, s string) (*net.IPNet, error)

func ParseIPRange added in v0.0.5

func ParseIPRange(version types.IPVersion, ipRange string) ([]net.IP, error)

func ParseIPRanges

func ParseIPRanges(version types.IPVersion, ipRanges []string) ([]net.IP, error)

func PrevIP

func PrevIP(ip net.IP) net.IP

Types

This section is empty.

Jump to

Keyboard shortcuts

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