Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IPMapper ¶
type IPMapper[V comparable] interface { GetIP(ip netip.Addr) (value V, matches bool) }
IPMapper represents an type can perform a get on a map of netip.Addr to value V, typically implemented against netip.Prefix data
See TrieMap for an efficient implementation
func NewBruteForceMapper ¶
func NewBruteForceMapper[V comparable](mapping map[V][]netip.Prefix) IPMapper[V]
NewBruteForceMapper returns a naive IPMapper that loops over the map and compares all netip.Prefix
This type exists purely for testing and benchmarking
type TrieMap ¶
type TrieMap[V comparable] struct { // contains filtered or unexported fields }
TrieMap contains an efficient trie structure of netip.Prefix that can match a netip.Addr to the associated Prefix if any and return the value associated with it of type V.
Use NewTrieMap to instantiate ¶
NOTE: This is insert-only (no delete) and insertion is *not* thread-safe.
Currently this is a simple TrieMap, in the future it may have compression.
See: https://vincent.bernat.ch/en/blog/2017-ipv4-route-lookup-linux
For benchmarks with real data see ./aws/mapper_test.go
func NewTrieMap ¶
func NewTrieMap[V comparable]() *TrieMap[V]
NewTrieMap[V] returns a new, properly allocated TrieMap[V]