asn

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package asn looks up the autonomous system of an address in a MaxMind DB file (DB-IP ASN Lite or GeoLite2-ASN).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPublic

func IsPublic(ip netip.Addr) bool

IsPublic reports whether ip is a globally routed unicast address.

Types

type DB

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

DB reads an ASN file in MaxMind DB format (DB-IP ASN Lite or GeoLite2-ASN).

func Open

func Open(path string) (*DB, error)

Open loads the database; an empty path gives a DB that finds nothing.

func (*DB) Close

func (d *DB) Close()

func (*DB) ID

func (d *DB) ID() string

ID names the database build, stored with every lookup. Empty without database.

func (*DB) Lookup

func (d *DB) Lookup(ip netip.Addr) Info

Lookup returns the AS of ip. Non public addresses return nothing.

type Info

type Info struct {
	ASN   uint32
	ASOrg string
	DB    string // the database build that answered
}

Info is the AS of an address.

Jump to

Keyboard shortcuts

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