use std::net::IpAddr;
use futures::StreamExt;
use cfprobe::{BatchScanConfig, CfProbe, CfProbeConfig, Target};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = CfProbeConfig::cloudflare_web_proxy_v1()?;
let probe = CfProbe::new(config).await?;
let targets = vec![
Target::https("104.16.77.250".parse::<IpAddr>()?, "example.com"),
Target::https("104.16.76.250".parse::<IpAddr>()?, "example.org"),
];
let config = BatchScanConfig::default()
.with_concurrency(8)
.with_target_timeout(std::time::Duration::from_secs(20))
.with_requests_per_second(Some(5));
let mut stream = probe.scan_unordered(targets, config)?;
while let Some(item) = stream.next().await {
println!(
"[{}] {:?} {:?}",
item.index,
item.status,
item.classification(),
);
if let Some(error) = item.error {
eprintln!("error: {}", error,);
}
if let Some(result) = item.result {
println!(" score = {}", result.detection.score,);
println!(" confidence = {:.2}", result.detection.confidence,);
}
}
Ok(())
}