asndb

package module
v2.0.1-0...-166e276 Latest Latest
Warning

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

Go to latest
Published: May 15, 2021 License: MIT Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASN

type ASN struct {
	Network      *net.IPNet `json:"network"`
	From         *net.IP    `json:"from"`
	To           *net.IP    `json:"to"`
	Cidr         string     `json:"cidr"`
	ASN          int        `json:"asn"`
	Organization string     `json:"organization"`
}

ASN contains information about a netblock

func NewASN

func NewASN(cidr string, asnr string, org string) (*ASN, error)

NewASN creates a new ASN struct based on cidr, asnr and org

func (*ASN) Less

func (a *ASN) Less(bt btree.Item) bool

Less determines whether a is lexicographically smaller than bt

type DB

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

DB contains a b-tree of ASNs

func New

func New(baseURLOrFile string) (*DB, error)

New creates a new ASN database. fname denotes the path to the Maxmind ASN CSV file

func (*DB) Each

func (a *DB) Each(f func(a *ASN) bool)

Each iterates over each element in the database

func (*DB) Lookup

func (a *DB) Lookup(ip net.IP) *ASN

Lookup returns the ASN struct of the network that contains ip

func (*DB) Size

func (a *DB) Size() int

Size returns the number of networks in the database

Jump to

Keyboard shortcuts

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