utils

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Range

type Range struct {
	RangeStart net.IP
	RangeEnd   net.IP
	Subnet     net.IPNet
	Gateway    net.IP
}

Range represents a IP range

func (*Range) Canonicalize

func (r *Range) Canonicalize() error

Canonicalize takes a given range and ensures that all information is consistent, filling out Start, End, and Gateway with sane values if missing

func (*Range) Contains

func (r *Range) Contains(addr net.IP) bool

Contains checks if a given ip contained in the range

func (*Range) Overlaps

func (r *Range) Overlaps(r1 *Range) bool

Overlaps returns true if there is any overlap between ranges

func (*Range) String

func (r *Range) String() string

String prints the range

type RangeIter

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

RangeIter is a iterator of a RangeSet

func (*RangeIter) Next

func (i *RangeIter) Next() (*net.IPNet, net.IP)

Next returns the next IP, its mask, and its gateway. Returns nil if the iterator has been exhausted

type RangeSet

type RangeSet []Range

RangeSet is a array of Range

func (*RangeSet) Canonicalize

func (rs *RangeSet) Canonicalize() error

Canonicalize ensures the RangeSet is in a standard form, and detects any invalid input. Call Range.Canonicalize() on every Range in the set

func (*RangeSet) Concat

func (rs *RangeSet) Concat(s string, subnet *net.IPNet) (*RangeSet, error)

Concat concats RangeSet from string for given subnet. eg: "10.0.0.[2-4], 10.0.1.4, 10.0.1.5, 10.0.1.9", 10.0.1.0/24

func (*RangeSet) Contains

func (rs *RangeSet) Contains(addr net.IP) bool

Contains returns true if any range in this set contains an IP

func (RangeSet) Len

func (rs RangeSet) Len() int

func (RangeSet) Less

func (rs RangeSet) Less(i, j int) bool

func (*RangeSet) Overlaps

func (rs *RangeSet) Overlaps(p1 *RangeSet) bool

Overlaps returns true if any ranges in any set overlap with this one

func (*RangeSet) RangeFor

func (rs *RangeSet) RangeFor(addr net.IP) (*Range, error)

RangeFor finds the range that contains an IP, or nil if not found

func (*RangeSet) String

func (rs *RangeSet) String() string

func (RangeSet) Swap

func (rs RangeSet) Swap(i, j int)

Jump to

Keyboard shortcuts

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