asn

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package asn provides ASN (Autonomous System Number) verification for bots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distinct

func Distinct(prefixes []netip.Prefix) []netip.Prefix

Distinct removes invalid and duplicate prefixes from a slice.

func ValidatePrefix

func ValidatePrefix(prefix netip.Prefix) bool

ValidatePrefix checks if a prefix is valid for ASN cache. Returns false for loopback, multicast, unspecified, or /0 prefixes.

Types

type BGPHE

type BGPHE struct {
	Client *http.Client
}

BGPHE fetches ASN prefixes from BGPHE (Hurricane Electric) website.

func NewBGPHE

func NewBGPHE() *BGPHE

func (*BGPHE) Fetch

func (b *BGPHE) Fetch(asn int) ([]netip.Prefix, error)

type Fetcher

type Fetcher interface {
	Fetch(asn int) ([]netip.Prefix, error)
}

Fetcher defines the interface for fetching ASN IP prefixes.

type RIPE

type RIPE struct {
	Client *http.Client
}

RIPE fetches ASN prefixes from RIPE Stat API.

func NewRIPE

func NewRIPE() *RIPE

func (*RIPE) Fetch

func (r *RIPE) Fetch(asn int) ([]netip.Prefix, error)

type RIPEData

type RIPEData struct {
	Data struct {
		Prefixes []struct {
			Prefix string `json:"prefix"`
		} `json:"prefixes"`
	} `json:"data"`
}

type RouteViews

type RouteViews struct {
	Client *http.Client
}

RouteViews fetches ASN prefixes from RouteViews API.

func NewRouteViews

func NewRouteViews() *RouteViews

func (*RouteViews) Fetch

func (r *RouteViews) Fetch(asn int) ([]netip.Prefix, error)

type Store

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

Store handles ASN data fetching and caching.

func NewStore

func NewStore(cacheDir string) *Store

NewStore creates a new ASN store.

func (*Store) Load

func (s *Store) Load(botName string, asn int) []netip.Prefix

func (*Store) Refresh

func (s *Store) Refresh(botName string, asn int) []netip.Prefix

Get returns prefixes for a given ASN from cache or fetches them.

Jump to

Keyboard shortcuts

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