cidr

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(s string) *net.IPNet

Parse is a convenience function that returns only the IPNet This function ignores errors since it is primarily a test helper, the result could be nil

Types

type Node

type Node[T any] struct {
	// contains filtered or unexported fields
}

type Tree4

type Tree4[T any] struct {
	// contains filtered or unexported fields
}

func NewTree4

func NewTree4[T any]() *Tree4[T]

func (*Tree4[T]) AddCIDR

func (tree *Tree4[T]) AddCIDR(cidr *net.IPNet, val T)

func (*Tree4[T]) Contains

func (tree *Tree4[T]) Contains(ip iputil.VpnIp) (ok bool, value T)

Contains finds the first match, which may be the least specific

func (*Tree4[T]) EachContains added in v1.9.0

func (tree *Tree4[T]) EachContains(ip iputil.VpnIp, each eachFunc[T]) bool

EachContains will call a function, passing the value, for each entry until the function returns true or the search is complete The final return value will be true if the provided function returned true

func (*Tree4[T]) GetCIDR added in v1.9.0

func (tree *Tree4[T]) GetCIDR(cidr *net.IPNet) (ok bool, value T)

GetCIDR returns the entry added by the most recent matching AddCIDR call

func (*Tree4[T]) List added in v1.7.0

func (tree *Tree4[T]) List() []entry[T]

List will return all CIDRs and their current values. Do not modify the contents!

func (*Tree4[T]) MostSpecificContains

func (tree *Tree4[T]) MostSpecificContains(ip iputil.VpnIp) (ok bool, value T)

MostSpecificContains finds the most specific match

type Tree6

type Tree6[T any] struct {
	// contains filtered or unexported fields
}

func NewTree6

func NewTree6[T any]() *Tree6[T]

func (*Tree6[T]) AddCIDR

func (tree *Tree6[T]) AddCIDR(cidr *net.IPNet, val T)

func (*Tree6[T]) MostSpecificContains

func (tree *Tree6[T]) MostSpecificContains(ip net.IP) (ok bool, value T)

Finds the most specific match

func (*Tree6[T]) MostSpecificContainsIpV4

func (tree *Tree6[T]) MostSpecificContainsIpV4(ip iputil.VpnIp) (ok bool, value T)

func (*Tree6[T]) MostSpecificContainsIpV6

func (tree *Tree6[T]) MostSpecificContainsIpV6(hi, lo uint64) (ok bool, value T)

Jump to

Keyboard shortcuts

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