use monocle::config::MonocleConfig;
use monocle::database::MonocleDatabase;
use monocle::lens::inspect::{InspectLens, InspectQueryOptions};
fn main() -> anyhow::Result<()> {
let db = MonocleDatabase::open_in_memory()?;
let config = MonocleConfig::default();
let lens = InspectLens::new(&db, &config);
println!("Loading data...");
lens.ensure_data_available()?;
println!("\nQuerying AS13335:");
let result = lens.query_as_asn(&["13335".to_string()], &InspectQueryOptions::default())?;
if let Some(q) = result.queries.first() {
if let Some(ref info) = q.asinfo {
if let Some(ref detail) = info.detail {
println!(" Name: {}", detail.core.name);
}
}
}
println!("\nQuerying 1.1.1.0/24:");
let result =
lens.query_as_prefix(&["1.1.1.0/24".to_string()], &InspectQueryOptions::default())?;
if let Some(q) = result.queries.first() {
if let Some(ref pfx) = q.prefix {
if let Some(ref info) = pfx.pfx2as {
println!(" Origin AS: {:?}", info.origin_asns);
}
}
}
Ok(())
}