| Crates.io | asn-checker-rs |
| lib.rs | asn-checker-rs |
| version | 0.1.0 |
| created_at | 2025-10-15 12:55:31.877195+00 |
| updated_at | 2025-10-15 12:55:31.877195+00 |
| description | Get ASN info about IP |
| homepage | https://github.com/drmf-cz/asn-checker-rs |
| repository | https://github.com/drmf-cz/asn-checker-rs |
| max_upload_size | |
| id | 1884290 |
| size | 68,490 |
A Rust library for looking up Autonomous System Numbers (ASN) and related information for IPv4 and IPv6 addresses. It fetches, parses, and caches ASN and IP mapping data from public sources, providing fast and convenient lookups for network applications. Library was inspired by asn-checker.
tokioserde supportAdd the following to your Cargo.toml:
[dependencies]
asn-checker-rs = { path = "." }
use asn_checker_rs::checker::Checker;
use std::net::IpAddr;
use tokio;
#[tokio::main]
async fn main() {
let mut checker = Checker::new();
checker.init().await;
let ip: IpAddr = "1.1.1.1".parse().unwrap();
if let Some(info) = checker.search(&ip).await {
println!("ASN: {} Name: {} Country: {} Net: {}", info.asn.id, info.asn.name, info.asn.cc, info.net);
} else {
println!("No ASN info found for this IP");
}
}
Checker::new(): Create a new checker instance.Checker::init(&mut self): Download and parse ASN data (async).Checker::search(&self, ip: &IpAddr) -> Option<IpInfo>: Lookup ASN info for an IP address.ip: Optionnet: IpNet — The network/subnet matched.asn: ASN — ASN information.id: u32 — ASN number.name: String — ASN name.cc: String — Country code.Run tests with:
cargo test
Contributions are welcome! Please open issues or pull requests.