use asn_db2::Database; use std::{fs::File, io::BufReader, net::IpAddr, str::FromStr}; fn main() -> Result<(), Box> { let database = { let reader = BufReader::new(File::open("ip2asn-combined.tsv")?); Database::from_reader(reader)? }; let ips = [ "2606:4700:4700::1111", "2606:4700:4700::1001", "2a05:dfc2::", "2a05:dfc3:cafe::", "1.1.1.1", "8.8.8.8", ]; for ip in ips { let ip = IpAddr::from_str(ip)?; let asn = database.lookup(ip).unwrap(); println!("{:#?}", asn); } Ok(()) }