BGPKIT Commons
bgpkit-commons is a library for common BGP-related data and functions. It provides a unified
interface to multiple BGP data sources through a lazy-loading architecture — modules are
independently enabled via feature flags and data is only fetched when explicitly requested.
Architecture
graph TD
B[BgpkitCommons]
B -->|load_asinfo| M1[asinfo]
B -->|load_as2rel| M2[as2rel]
B -->|load_bogons| M3[bogons]
B -->|load_countries| M4[countries]
B -->|load_mrt_collectors| M5[mrt_collectors]
B -->|load_rpki| M6[rpki]
M1 -->|asinfo_get, asinfo_all| A1[RIPE NCC / CAIDA / APNIC / PeeringDB]
M2 -->|as2rel_lookup| A2[BGPKIT inference]
M3 -->|bogons_match| A3[IANA registries]
M4 -->|country_by_code| A4[GeoNames]
M5 -->|mrt_collectors_all| A5[RouteViews / RIPE RIS]
M6 -->|rpki_validate| A6[Cloudflare / RIPE NCC / RPKIviews / RPKISPOOL]
Each module is gated by a feature flag. The all feature (default) enables everything.
Data is fetched on the first load_xxx() call and kept in memory until reload() is called.
Modules
| Module | Feature | Data Sources | Key Functions |
|---|---|---|---|
[asinfo] |
asinfo |
RIPE NCC, CAIDA as2org, APNIC, IIJ IHR, PeeringDB | asinfo_get, asinfo_all, asinfo_are_siblings |
[as2rel] |
as2rel |
BGPKIT AS relationship inference | as2rel_lookup |
[bogons] |
bogons |
IANA special registries | bogons_match, bogons_match_prefix, bogons_match_asn |
[countries] |
countries |
GeoNames | country_by_code, country_by_code3, country_by_name |
[mrt_collectors] |
mrt_collectors |
RouteViews, RIPE RIS | mrt_collectors_all, mrt_collector_peers_all |
[rpki] |
rpki |
Cloudflare, RIPE NCC, RPKIviews, RPKISPOOL | rpki_validate, rpki_validate_check_expiry, rpki_lookup_by_prefix |
Quick Start
[]
= "0.10"
use BgpkitCommons;
let mut commons = new;
// Load the modules you need
commons.load_bogons.unwrap;
commons.load_asinfo.unwrap;
// Access the data
if let Ok = commons.bogons_match
if let Ok = commons.asinfo_get
Examples
RPKI Validation
use BgpkitCommons;
let mut commons = new;
commons.load_rpki.unwrap; // None = real-time from Cloudflare
let result = commons.rpki_validate.unwrap;
println!;
Historical RPKI Data
use BgpkitCommons;
use ;
use NaiveDate;
let mut commons = new;
let date = from_ymd_opt.unwrap;
// From RIPE NCC historical archives
commons.load_rpki_historical.unwrap;
// Or from an RPKIviews collector
let source = RpkiViews;
commons.load_rpki_historical.unwrap;
// Or from RPKISPOOL (CCR format, parses faster)
use RpkiSpoolsCollector;
let source = RpkiSpools;
commons.load_rpki_historical.unwrap;
Available RPKIviews collectors: SobornostNet (default), MassarsNet, AttnJp, KerfuffleNet.
Available RPKISPOOL collectors: SobornostNet (default), AttnJp, KerfuffleNet.
AS Information with Builder
use BgpkitCommons;
let mut commons = new;
let builder = commons.asinfo_builder
.with_as2org
.with_peeringdb;
commons.load_asinfo_with.unwrap;
if let Ok = commons.asinfo_are_siblings
Direct Module Access
All modules can be used directly without BgpkitCommons:
use Bogons;
use RpkiTrie;
let bogons = new.unwrap;
let trie = from_cloudflare.unwrap;
Feature Flags
| Feature | Description |
|---|---|
asinfo |
AS information: names, countries, organizations, population, hegemony |
as2rel |
AS relationship data |
bogons |
Bogon prefix and ASN detection |
countries |
Country information lookup |
mrt_collectors |
MRT collector metadata |
rpki |
RPKI validation (ROA and ASPA) |
all (default) |
Enables all modules |
For a minimal build:
[]
= { = "0.10", = false, = ["bogons", "rpki"] }
License
MIT