diff --git a/src/geoip.rs b/src/geoip.rs index 5e07f71..64fa7ee 100644 --- a/src/geoip.rs +++ b/src/geoip.rs @@ -3,9 +3,10 @@ * that provides the results ready for templating. */ -use log::{info,warn,error}; +use log::{debug,info,warn,error}; use maxminddb::geoip2; +use maxminddb::MaxMindDBError::AddressNotFoundError; use parking_lot::RwLock; use std::collections::BTreeMap; @@ -135,9 +136,15 @@ impl QueryAsn for MMDBCarrier { name: res.autonomous_system_organization.map(ToString::to_string), }) }, + Err(AddressNotFoundError(_)) => { + // Log to the debug channel. + // This isn't severe, and shouldn't be logged in production. + debug!("ASN not found in database for {address}."); + None + }, Err(e) => { error!("Error while looking up ASN for {address}: {e}"); - Default::default() + None } } }, @@ -203,9 +210,15 @@ impl QueryLocation for MMDBCarrier { }, }) }, + Err(AddressNotFoundError(_)) => { + // Log to the debug channel. + // This isn't severe, and shouldn't be logged in production. + debug!("IP location not found in database for {address}"); + None + }, Err(e) => { - error!("Error while looking up ASN for {address}: {e}"); - Default::default() + error!("Error while looking up IP location for {address}: {e}"); + None } } }, diff --git a/src/ipinfo.rs b/src/ipinfo.rs index 5a2660f..5427c44 100644 --- a/src/ipinfo.rs +++ b/src/ipinfo.rs @@ -111,6 +111,7 @@ impl AddressInfo { scope: address_scope } } + }