use ipwhois::{IpWhois, Options};
#[tokio::main]
async fn main() {
let ipwhois = IpWhois::with_key("YOUR_API_KEY");
let ips = [
"8.8.8.8",
"1.1.1.1",
"208.67.222.222",
"2c0f:fb50:4003::", ];
let opts = Options::new().with_lang("en").with_security(true);
let results = match ipwhois.bulk_lookup_with(ips, &opts).await {
Ok(r) => r,
Err(e) => {
eprintln!(
"Bulk request failed: {} (HTTP {})",
e.message(),
e.http_status()
.map(|s| s.to_string())
.unwrap_or_else(|| "?".to_string()),
);
std::process::exit(1);
}
};
for row in &results {
if !row.success {
println!(
"[skip] {} — {}",
row.ip.as_deref().unwrap_or("?"),
row.message.as_deref().unwrap_or("error"),
);
continue;
}
println!(
"{:<18} {} {:<4} {}",
row.ip.as_deref().unwrap_or(""),
row.flag
.as_ref()
.and_then(|f| f.emoji.as_deref())
.unwrap_or(" "),
row.country_code.as_deref().unwrap_or(""),
row.connection
.as_ref()
.and_then(|c| c.isp.as_deref())
.unwrap_or(""),
);
}
}