asnlookup

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package asnlookup provides ASN and prefix lookup helpers used by test cases.

Index

Constants

View Source
const (
	// CodeFound indicates that one or more ASNs were found for the query IP.
	CodeFound = "AS_FOUND"
	// CodeEmpty indicates that the source returned no ASN mapping for the query IP.
	CodeEmpty = "EMPTY_ASN_SET"
	// CodeError indicates that ASN lookup failed across all configured sources.
	CodeError = "ERROR_ASN_DATABASE"
)

Variables

This section is empty.

Functions

func Get

func Get(ctx context.Context, resolver Resolver, ip netip.Addr) ([]int, error)

Get returns the list of ASNs for an IP address.

Types

type Resolver

type Resolver interface {
	Recurse(ctx context.Context, name string, qtype string, qclass string) (packet.Packet, error)
}

Resolver defines the DNS recursion interface used by ASN lookup.

type Result

type Result struct {
	ASNs   []int
	Prefix *netip.Prefix
	Raw    string
	Code   string
}

Result captures ASN lookup data and status.

func GetWithPrefix

func GetWithPrefix(ctx context.Context, resolver Resolver, ip netip.Addr) (Result, error)

GetWithPrefix returns ASN list, prefix, raw response, and status code.

Jump to

Keyboard shortcuts

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