patricia

package
v0.0.0-...-f33e45f Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FILE_CHECK_TIME = time.Hour
)

Variables

View Source
var (
	ErrorNotFound     = errors.New("Not found")
	ErrorNoEntries    = errors.New("No entries")
	ErrorNotIPv6      = errors.New("Not an IPv6 address")
	ErrorDuplicateKey = errors.New("Key already exists")
)

Functions

func GetCity

func GetCity(n *NodeGeo) uint32

func GetCountry

func GetCountry(n *NodeGeo) uint32

func GetRegion

func GetRegion(n *NodeGeo) uint32

func PackGeo

func PackGeo(cnty []byte) uint32

Utility to turn Geo -> packed int

func PackIPAddr

func PackIPAddr(ip net.IP) *[16]byte

func UnpackGeo

func UnpackGeo(pked uint32) *string

Utility to turn packed int -> Geo

Types

type GeoTrees

type GeoTrees struct {
	Trees
	// contains filtered or unexported fields
}

Geo tree only holds geo data

func NewGeoTrees

func NewGeoTrees(log *logger.Logger) (*GeoTrees, error)

func OpenGeo

func OpenGeo(file string, force bool, log *logger.Logger) (*GeoTrees, error)

func (*GeoTrees) Load

func (p *GeoTrees) Load(file string) error

func (*GeoTrees) SearchBestFromHostGeo

func (p *GeoTrees) SearchBestFromHostGeo(ip net.IP) (*NodeGeo, error)

func (*GeoTrees) Update

func (p *GeoTrees) Update(file string)

Run in a loop, update when the base file changes

type NodeGeo

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

type PatriciaError

type PatriciaError string

PatriciaError is used for errors using the sflow library. It implements the builtin error interface.

func (PatriciaError) Error

func (err PatriciaError) Error() string

type StringTrees

type StringTrees struct {
	Trees
	// contains filtered or unexported fields
}

StringTrees is a IPv4/IPv6 pair of trees that hold string payloads

func NewStringTrees

func NewStringTrees(log *logger.Logger) (*StringTrees, error)

NewStringTrees returns a new StringTrees

func (*StringTrees) AddPrefix

func (p *StringTrees) AddPrefix(addr string, content string)

func (*StringTrees) FindAllMatches

func (p *StringTrees) FindAllMatches(addr net.IP, len uint8) ([]string, error)

Finds all tags with the input address (relying on tree traversing behavior)

func (*StringTrees) FindBestMatch

func (p *StringTrees) FindBestMatch(addr uint32, addr6 []byte) (bool, string, error)

Finds the most-specific tag with the input address (relying on tree traversing behavior)

func (*StringTrees) RemovePrefix

func (p *StringTrees) RemovePrefix(addr string, content string) bool

Always removes content at prefix - returns whether the delete removed any prefixes

func (*StringTrees) SetPrefix

func (p *StringTrees) SetPrefix(addr string, content string)

Set the value for a prefix - overwrites what's there (technically, the first in the list)

type Trees

type Trees struct {
	Length int
	// contains filtered or unexported fields
}

Trees is a pair of IPv4/IPv6 patricia trees

func (*Trees) Close

func (p *Trees) Close()

Close cloess up anything that needs to be closed

type Uint32Trees

type Uint32Trees struct {
	Trees
	// contains filtered or unexported fields
}

PatriciaUin32 is a IPv4/IPv6 pair of trees that hold uint32 payloads

func NewUint32Trees

func NewUint32Trees(log *logger.Logger, file4 string, file6 string) (*Uint32Trees, error)

NewUint32Trees returns a new Uint32Trees

func OpenASN

func OpenASN(file4 string, file6 string, log *logger.Logger) (*Uint32Trees, error)

func (*Uint32Trees) AddPrefix

func (p *Uint32Trees) AddPrefix(addr string, content uint32)

func (*Uint32Trees) FindBestMatch

func (p *Uint32Trees) FindBestMatch(addr uint32, addr6 []byte) (bool, uint32, error)

Finds the most-specific tag with the input address (relying on tree traversing behavior)

func (*Uint32Trees) RemovePrefix

func (p *Uint32Trees) RemovePrefix(addr string, content uint32) bool

Always removes content at prefix - returns whether the delete removed any prefixes

Jump to

Keyboard shortcuts

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