iprange

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IP2Int

func IP2Int(ip net.IP) (uint32, bool)

IP2Int converts a IPv4 address to it's unsigned integer representation

func Int2IP

func Int2IP(i uint32) net.IP

Int2IP converts a uint32 to it's IPv4 representation

Types

type IPRange

type IPRange struct {
	Start net.IP
	End   net.IP
}

IPRange is a range of IP address from (inclusive) start to (inclusive) end IP.

func DeleteFrom

func DeleteFrom(delete *IPRange, ranges []*IPRange) []*IPRange

DeleteFrom deletes a range from a set of IP ranges. The range to delte may span multiple ip ranges

func Merge

func Merge(ranges []*IPRange) []*IPRange

Merge merges multiple IP ranges and combins overlapping ranges

func (*IPRange) ByIdx

func (r *IPRange) ByIdx(i int) net.IP

ByIdx returns the IP address at the given index

func (*IPRange) Clone

func (r *IPRange) Clone() *IPRange

Clone returns a deep copy of the IP range

func (*IPRange) Contains

func (r *IPRange) Contains(ip net.IP) bool

Contains checks if ip is part of the range

func (*IPRange) Len

func (r *IPRange) Len() int

Len returns the number of IP address available inside the range

func (*IPRange) String

func (r *IPRange) String() string

func (*IPRange) Validate

func (r *IPRange) Validate() error

Validate the IP range and return any error encountered

type IPRanges

type IPRanges []*IPRange

IPRanges is a slice of IPRange and implements the sort.Interface. Ranges are sorted by increasing start IP

func (IPRanges) Contains

func (ranges IPRanges) Contains(ip net.IP) bool

Contains reports whether on of the IP ranges contains the IP in question

func (IPRanges) Len

func (ranges IPRanges) Len() int

Len implements sort.Interface

func (IPRanges) Less

func (ranges IPRanges) Less(i, j int) bool

Less implements sort.Interface

func (IPRanges) Swap

func (ranges IPRanges) Swap(i, j int)

Swap implements sort.Interface

Jump to

Keyboard shortcuts

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