cidr

package module
v0.0.0-...-63b6ed5 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotInAddressRange        = errors.New("cidr: not in address range")
	ErrHasBeenExcluded          = errors.New("cidr: has been excluded")
	ErrHasBeenPartiallyExcluded = errors.New("cidr: has been partially excluded")
	ErrAddressRangeConflict     = errors.New("cidr: address range conflict")
)

Functions

This section is empty.

Types

type CIDR

type CIDR interface {
	ContainsIP(netip.Addr) bool
	NextIP(netip.Addr) netip.Addr
	Length() *big.Int

	Contains(CIDR) ContainsStatus
}

type Consecutive

type Consecutive interface {
	CIDR

	FirstIP() netip.Addr
	LastIP() netip.Addr
	String() string
}

func ParseConsecutive

func ParseConsecutive(s string) (Consecutive, error)

type ContainsStatus

type ContainsStatus uint8
const (
	Contains ContainsStatus = iota
	ContainsPartially
	ContainsNot
)

type Exclude

type Exclude struct {
	// contains filtered or unexported fields
}

func NewExclude

func NewExclude(c CIDR, exclude ...Consecutive) (*Exclude, error)

func (*Exclude) Contains

func (e *Exclude) Contains(c CIDR) ContainsStatus

func (*Exclude) ContainsIP

func (e *Exclude) ContainsIP(addr netip.Addr) bool

func (*Exclude) DelExclude

func (e *Exclude) DelExclude(addr netip.Addr) error

func (*Exclude) Exclude

func (e *Exclude) Exclude() Group

func (*Exclude) ExcludeAddress

func (e *Exclude) ExcludeAddress(addr netip.Addr) error

func (*Exclude) ExcludeCIDR

func (e *Exclude) ExcludeCIDR(c Consecutive) error

func (*Exclude) Include

func (e *Exclude) Include() CIDR

func (*Exclude) Length

func (e *Exclude) Length() *big.Int

func (*Exclude) NextIP

func (e *Exclude) NextIP(addr netip.Addr) netip.Addr

func (*Exclude) Strings

func (e *Exclude) Strings() []string

type Fragment

type Fragment interface {
	CIDR

	Strings() []string
}

type Group

type Group struct {
	Arr []Consecutive
}

func ParseGroup

func ParseGroup(s []string) (*Group, error)

func (*Group) AddCIDR

func (x *Group) AddCIDR(c Consecutive) error

func (*Group) Contains

func (x *Group) Contains(cidr CIDR) ContainsStatus

func (*Group) ContainsIP

func (x *Group) ContainsIP(ip netip.Addr) bool

func (*Group) Length

func (x *Group) Length() *big.Int

func (*Group) NextIP

func (x *Group) NextIP(ip netip.Addr) netip.Addr

func (*Group) Strings

func (x *Group) Strings() []string

type Prefix

type Prefix struct {
	// contains filtered or unexported fields
}

func NewPrefix

func NewPrefix(p netip.Prefix) *Prefix

func ParsePrefix

func ParsePrefix(s string) (*Prefix, error)

func (Prefix) Contains

func (x Prefix) Contains(c CIDR) ContainsStatus

func (Prefix) ContainsIP

func (x Prefix) ContainsIP(ip netip.Addr) bool

func (Prefix) FirstIP

func (x Prefix) FirstIP() netip.Addr

func (Prefix) LastIP

func (x Prefix) LastIP() netip.Addr

func (Prefix) Length

func (x Prefix) Length() *big.Int

func (Prefix) NextIP

func (x Prefix) NextIP(ip netip.Addr) netip.Addr

func (Prefix) String

func (x Prefix) String() string

type Range

type Range struct {
	// contains filtered or unexported fields
}

func NewRange

func NewRange(start, end netip.Addr) *Range

func ParseRange

func ParseRange(s string) (*Range, error)

func (*Range) Contains

func (x *Range) Contains(c CIDR) ContainsStatus

func (*Range) ContainsIP

func (x *Range) ContainsIP(ip netip.Addr) bool

func (*Range) FirstIP

func (x *Range) FirstIP() netip.Addr

func (*Range) LastIP

func (x *Range) LastIP() netip.Addr

func (*Range) Length

func (x *Range) Length() *big.Int

func (*Range) NextIP

func (x *Range) NextIP(ip netip.Addr) netip.Addr

func (*Range) String

func (x *Range) String() string

type Single

type Single struct {
	// contains filtered or unexported fields
}

func NewSingle

func NewSingle(addr netip.Addr) *Single

func ParseSingle

func ParseSingle(s string) (*Single, error)

func (*Single) Contains

func (x *Single) Contains(b CIDR) ContainsStatus

func (*Single) ContainsIP

func (x *Single) ContainsIP(ip netip.Addr) bool

func (*Single) FirstIP

func (x *Single) FirstIP() netip.Addr

func (*Single) LastIP

func (x *Single) LastIP() netip.Addr

func (*Single) Length

func (x *Single) Length() *big.Int

func (*Single) NextIP

func (x *Single) NextIP(ip netip.Addr) netip.Addr

func (*Single) String

func (x *Single) String() string

Jump to

Keyboard shortcuts

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