You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let resp = ureq::get("https://iptoasn.com/data/ip2asn-v4.tsv.gz").call();
if resp.status() != 200{
panic!("iptoasn.com failed")
}
let reader = resp.into_reader();
let reader = BufReader::new(GzDecoder::new(BufReader::new(reader)));
letmut toret = RangeMap::new();
for(idx, line)in reader.lines().enumerate(){
let line = line.expect("I/O error while downloading ASN database");
if idx % 1000 == 0{
log::debug!("loading line {} of ASN database...", idx);
}
let elems:Vec<&str> = line.split_ascii_whitespace().collect();
if elems.len() < 3{
log::warn!("skipping line in ASN database: {}", line)
}else{
let start:Ipv4Addr = elems[0].parse().unwrap();
let end:Ipv4Addr = next_ip(elems[1].parse().unwrap());
let asn:u32 = elems[2].parse().unwrap();
if end > start {
toret.insert(start..end, asn);
}
}
}
toret
});
It looks like the ASN database you're importing works with inclusive ranges. Might it therefore be more natural to use RangeInclusiveMap to store/query this, and not need the next_ip function?
The text was updated successfully, but these errors were encountered:
Hi there,
In this code:
geph4-exit/src/asn.rs
Lines 11 to 38 in a91fda6
It looks like the ASN database you're importing works with inclusive ranges. Might it therefore be more natural to use RangeInclusiveMap to store/query this, and not need the
next_ip
function?The text was updated successfully, but these errors were encountered: