ipmetadata

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package ipmetadata performs offline ASN and approximate location lookups. It does not resolve names or contact any network service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Global

func Global(ip netip.Addr) bool

func GlobalPrefix

func GlobalPrefix(p netip.Prefix) bool

GlobalPrefix reports whether every address in p is global as Global defines it, so that a database never holds a record Lookup cannot reach.

Types

type Databases

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

Databases holds the configured readers. Reload replaces a reader whose file was atomically renamed over; a lookup in progress keeps the reader it started with, which is closed only after that lookup returns. Never rewrite or truncate a mapped file in place.

func Open

func Open(asnPath, cityPath string) (*Databases, error)

func (*Databases) Close

func (d *Databases) Close() error

func (*Databases) Lookup

func (d *Databases) Lookup(address, addressSource string, observedAt int64, optOut bool) wire.AddressMetadata

Lookup accepts literal global addresses only. A hostname is unknown without a DNS lookup. IPv4-mapped IPv6 is treated as IPv4.

func (*Databases) Reload

func (d *Databases) Reload() []Reloaded

Reload reopens each configured database whose file is no longer the one it was opened from, typically because a new file was renamed into place. A replacement is validated as at startup before it is swapped in; when it is refused, the previous database stays in use. Lookups made afterwards use the new database; values already looked up keep their own source.

func (*Databases) Watch

func (d *Databases) Watch(ctx context.Context, interval time.Duration, report func(Reloaded))

Watch calls Reload every interval until ctx ends and passes each result to report. Executors are looked up again when they (re)register, so a replacement applies to registrations after it.

type Reloaded

type Reloaded struct {
	Kind, Path, Source string
	Err                error
}

Reloaded reports one replacement attempt: Source names the database now in use, and Err why a replacement was refused, in which case the previous database stays in use.

Directories

Path Synopsis
Package ris builds the dispatcher's ASN database from RIPE RIS routing data, the method RIPE Atlas uses for a probe's prefix and ASN: an address belongs to the longest prefix announced in BGP, and to that prefix's origin AS.
Package ris builds the dispatcher's ASN database from RIPE RIS routing data, the method RIPE Atlas uses for a probe's prefix and ASN: an address belongs to the longest prefix announced in BGP, and to that prefix's origin AS.

Jump to

Keyboard shortcuts

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