Quick start
Create a BgpkitCommons instance, load the module you need,
and call its access methods. All modules follow the same pattern:
load then query.
use bgpkit_commons::BgpkitCommons;
let mut commons = BgpkitCommons::new();
// Load bogon data
commons.load_bogons().unwrap();
// Use the data
if let Ok(is_bogon) = commons.bogons_match("23456") {
println!("ASN 23456 is a bogon: {}", is_bogon);
} Design
- Lazy-loading: module data
is loaded only when you call
load_*. - Feature flags: disable defaults and compile only required modules.
- In-memory cache: once loaded, data stays in memory for fast repeated lookups.
Installation
Add the crate to your Cargo.toml. If you want a minimal
build, disable default features and enable just the modules you use.
# Cargo.toml
[dependencies]
bgpkit-commons = "0.10"
# Minimal build example (pick only what you need)
# bgpkit-commons = { version = "0.10", default-features = false, features = ["bogons", "countries"] } Available modules
Each module is independently enabled via a feature flag. Load methods and
access methods are available through the central BgpkitCommons
object.
asinfo AS information (name/org/country + sources like CAIDA as2org, PeeringDB, population, hegemony).
as2rel AS relationship lookup (provider-customer, peer-to-peer, sibling) inferred by BGPKIT.
bogons Bogon detection for prefixes and ASNs using IANA special registries.
countries ISO country metadata and lookup helpers based on GeoNames.
mrt_collectors Collector + peer metadata for RouteViews and RIPE RIS, including full-feed classification.
rpki RPKI validation helpers with multiple real-time and historical sources.
Examples
These examples mirror the upstream README patterns. For the most up-to-date API surface, refer to the crate documentation.
use bgpkit_commons::BgpkitCommons;
let mut commons = BgpkitCommons::new();
// Load multiple data sources
commons.load_asinfo(false, false, false, false).unwrap();
commons.load_countries().unwrap();
// Use the data together
if let Ok(Some(asinfo)) = commons.asinfo_get(13335) {
println!("AS13335: {} ({})", asinfo.name, asinfo.country);
} use bgpkit_commons::BgpkitCommons;
let mut commons = BgpkitCommons::new();
// Clear, self-documenting configuration
let builder = commons
.asinfo_builder()
.with_as2org()
.with_peeringdb();
commons.load_asinfo_with(builder).unwrap();
// Check if two ASes are siblings (requires as2org data)
if let Ok(are_siblings) = commons.asinfo_are_siblings(13335, 132892) {
println!("AS13335 and AS132892 are siblings: {}", are_siblings);
} Feature flags
Default builds enable a convenience feature set. For smaller binaries, use a minimal selection and compile only what you need.
# Cargo.toml (minimal build: only bogons + countries)
[dependencies]
bgpkit-commons = { version = "0.10", default-features = false, features = ["bogons", "countries"] } Lazy-loading by module
Load only the datasets you need at runtime (e.g., bogons, countries, AS info, RPKI) to keep memory and dependencies predictable.
Feature-flag driven builds
Disable default features and enable just the modules you use (useful for small CLIs, libraries, and constrained environments).
Operator-friendly helpers
Common lookups (bogons, countries), metadata (collectors), and validation (RPKI) live behind a consistent API surface.
Composable with the BGPKIT ecosystem
Designed to be used alongside Parser/Broker/Monocle for end-to-end BGP data workflows.