net

package
v0.0.0-...-d88c8b5 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDualStackCIDRStrings

func IsDualStackCIDRStrings(cidrs []string) (bool, error)

IsDualStackCIDRStrings returns if - all are valid cidrs - at least one cidr from each family (v4 or v6)

func IsDualStackCIDRs

func IsDualStackCIDRs(cidrs []*net.IPNet) (bool, error)

IsDualStackCIDRs returns if - all are valid cidrs - at least one cidr from each family (v4 or v6)

func IsDualStackIPStrings

func IsDualStackIPStrings(ips []string) (bool, error)

IsDualStackIPStrings returns if - all are valid ips - at least one ip from each family (v4 or v6)

func IsDualStackIPs

func IsDualStackIPs(ips []net.IP) (bool, error)

IsDualStackIPs returns if a slice of ips is: - all are valid ips - at least one ip from each family (v4 or v6)

func IsIPv6

func IsIPv6(netIP net.IP) bool

IsIPv6 returns if netIP is IPv6.

func IsIPv6CIDR

func IsIPv6CIDR(cidr *net.IPNet) bool

IsIPv6CIDR returns if a cidr is ipv6

func IsIPv6CIDRString

func IsIPv6CIDRString(cidr string) bool

IsIPv6CIDRString returns if cidr is IPv6. This assumes cidr is a valid CIDR.

func IsIPv6String

func IsIPv6String(ip string) bool

IsIPv6String returns if ip is IPv6.

func ParseCIDRs

func ParseCIDRs(cidrsString []string) ([]*net.IPNet, error)

ParseCIDRs parses a list of cidrs and return error if any is invalid. order is maintained

Types

type IPNetSet

type IPNetSet map[string]*net.IPNet

IPNetSet maps string to net.IPNet.

func ParseIPNets

func ParseIPNets(specs ...string) (IPNetSet, error)

ParseIPNets parses string slice to IPNetSet.

func (IPNetSet) Delete

func (s IPNetSet) Delete(items ...*net.IPNet)

Delete removes all items from the set.

func (IPNetSet) Difference

func (s IPNetSet) Difference(s2 IPNetSet) IPNetSet

Difference returns a set of objects that are not in s2 For example: s1 = {a1, a2, a3} s2 = {a1, a2, a4, a5} s1.Difference(s2) = {a3} s2.Difference(s1) = {a4, a5}

func (IPNetSet) Equal

func (s IPNetSet) Equal(s2 IPNetSet) bool

Equal returns true if and only if s1 is equal (as a set) to s2. Two sets are equal if their membership is identical. (In practice, this means same elements, order doesn't matter)

func (IPNetSet) Has

func (s IPNetSet) Has(item *net.IPNet) bool

Has returns true if and only if item is contained in the set.

func (IPNetSet) HasAll

func (s IPNetSet) HasAll(items ...*net.IPNet) bool

HasAll returns true if and only if all items are contained in the set.

func (IPNetSet) Insert

func (s IPNetSet) Insert(items ...*net.IPNet)

Insert adds items to the set.

func (IPNetSet) IsSuperset

func (s IPNetSet) IsSuperset(s2 IPNetSet) bool

IsSuperset returns true if and only if s1 is a superset of s2.

func (IPNetSet) Len

func (s IPNetSet) Len() int

Len returns the size of the set.

func (IPNetSet) StringSlice

func (s IPNetSet) StringSlice() []string

StringSlice returns a []string with the String representation of each element in the set. Order is undefined.

Jump to

Keyboard shortcuts

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