cidr

package
v0.0.0-...-030b38e Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CIDRStringContainsIP

func CIDRStringContainsIP(cidrs, ips string) bool

CIDRStringContainsIP parses the given CIDR string using net.ParseCIDR and returns an IP

func Contains

func Contains(ipNets []*net.IPNet, ipNet *net.IPNet) bool

Contains returns true if 'ipNets' contains ipNet.

func ContainsAll

func ContainsAll(ipNets1, ipNets2 []*net.IPNet) bool

ContainsAll returns true if 'ipNets1' contains all net.IPNet of 'ipNets2'

func Equal

func Equal(n, o *net.IPNet) bool

Equal returns true if the n and o net.IPNet CIDRs arr Equal.

func RemoveAll

func RemoveAll(ipNets, toRemove []*net.IPNet) []*net.IPNet

RemoveAll removes all cidrs specified in 'toRemove' from 'ipNets'. ipNets is clobbered (to ensure removed CIDRs can be garbage collected) and must not be used after this function has been called. Example usage:

cidrs = cidr.RemoveAll(cidrs, toRemove)

Types

type CIDR

type CIDR struct {
	*net.IPNet
}

CIDR is a network CIDR representation based on net.IPNet

func DiffCIDRLists

func DiffCIDRLists(old, new []*CIDR) (add, remove []*CIDR)

DiffCIDRLists compares an old and new list of CIDRs and returns the list of removed and added CIDRs

func MustParseCIDR

func MustParseCIDR(str string) *CIDR

MustParseCIDR parses the CIDR string using net.ParseCIDR and panics if the CIDR cannot be parsed

func NewCIDR

func NewCIDR(ipnet *net.IPNet) *CIDR

NewCIDR returns a new CIDR using a net.IPNet

func ParseCIDR

func ParseCIDR(str string) (*CIDR, error)

ParseCIDR parses the CIDR string using net.ParseCIDR

func (*CIDR) AvailableIPs

func (n *CIDR) AvailableIPs() int

AvailableIPs returns the number of IPs available in a CIDR

func (*CIDR) DeepCopy

func (n *CIDR) DeepCopy() *CIDR

DeepCopy creates a deep copy of a CIDR

func (*CIDR) DeepCopyInto

func (in *CIDR) DeepCopyInto(out *CIDR)

DeepCopyInto is a deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*CIDR) DeepEqual

func (in *CIDR) DeepEqual(other *CIDR) bool

DeepEqual is an deepequal function, deeply comparing the receiver with other. in must be non-nil.

func (*CIDR) Equal

func (n *CIDR) Equal(o *CIDR) bool

Equal returns true if the receiver's CIDR equals the other CIDR.

Jump to

Keyboard shortcuts

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