net

package
v0.0.0-...-68fec7b Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CidrEqual

func CidrEqual(a, b *net.IPNet) bool

Whether two Cidr are equal (IP and masks match)

func FirstIpv4

func FirstIpv4(n *net.IPNet) net.IP

First Ipv4 address in a CIDR (ignores network address)

func Ipv4FromUint

func Ipv4FromUint(u uint32) net.IP

Get an IP address from a 32bit uint

func Ipv4ToUint

func Ipv4ToUint(ip net.IP) uint32

Turn an IP address into a 32bit uint

func LastIpv4

func LastIpv4(n *net.IPNet) net.IP

Last Ipv4 address in a CIDR (ignores broadcast)

func MaskFromByte

func MaskFromByte(b byte) net.IPMask

Convert a uint into an IPMask (from CIDR notation to go-internal)

func MaskToByte

func MaskToByte(m net.IPMask) byte

Convert an IPMask into a byte, much like in CIDR notation (0-32)

Types

type CidrValue

type CidrValue struct {
	Cidr  *net.IPNet
	Value interface{}
}

type Tree

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

func New

func New(merge func(a, b interface{}) interface{}) *Tree

func (*Tree) AddCidr

func (t *Tree) AddCidr(cidr *net.IPNet, value interface{})

Add a CIDR to the tree

func (*Tree) AddIp

func (t *Tree) AddIp(ip net.IP, value interface{})

Add a single IP to the tree

func (*Tree) AddRange

func (t *Tree) AddRange(start, end net.IP, value interface{})

Add a range of IPs to the tree (inclusive)

func (*Tree) ListCidr

func (t *Tree) ListCidr() []CidrValue

List all CIDR that describe the contents of the tree

Jump to

Keyboard shortcuts

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