diff --git a/Cargo.lock b/Cargo.lock index b5342fc..a2d8ca6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1403,14 +1403,15 @@ checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" [[package]] name = "maxminddb" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "144de2546bf4846c6c84b7f76be035f7ebbc1e7d40cfb05810ba45c129508321" +checksum = "2a197e44322788858682406c74b0b59bf8d9b4954fe1f224d9a25147f1880bba" dependencies = [ "ipnetwork", "log", "memchr", "serde", + "thiserror 2.0.12", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3b6b6c5..8cea277 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ hickory-resolver = { version = "0.25", features = ["tls-ring","https-ring","qui http = "1.3" idna = "1.0" log = "0.4" -maxminddb = "0.25" +maxminddb = "0.26" mime = "0.3" parking_lot = "0.12" regex = "1.11" diff --git a/src/geoip.rs b/src/geoip.rs index 64fa7ee..8e01705 100644 --- a/src/geoip.rs +++ b/src/geoip.rs @@ -6,7 +6,6 @@ use log::{debug,info,warn,error}; use maxminddb::geoip2; -use maxminddb::MaxMindDBError::AddressNotFoundError; use parking_lot::RwLock; use std::collections::BTreeMap; @@ -130,13 +129,13 @@ impl QueryAsn for MMDBCarrier { match &*mmdb { Some(mmdb) => { match mmdb.lookup::(*address) { - Ok(res) => { + Ok(Some(res)) => { Some(AsnResult { asn: res.autonomous_system_number, name: res.autonomous_system_organization.map(ToString::to_string), }) }, - Err(AddressNotFoundError(_)) => { + Ok(None) => { // Log to the debug channel. // This isn't severe, and shouldn't be logged in production. debug!("ASN not found in database for {address}."); @@ -159,7 +158,7 @@ impl QueryLocation for MMDBCarrier { match &*mmdb { Some(mmdb) => { match mmdb.lookup::(*address) { - Ok(res) => { + Ok(Some(res)) => { Some(LocationResult { continent: res.continent.map(|c| geoip2_continent_to_named_location(c, languages)), @@ -210,7 +209,7 @@ impl QueryLocation for MMDBCarrier { }, }) }, - Err(AddressNotFoundError(_)) => { + Ok(None) => { // 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}"); @@ -236,14 +235,14 @@ impl MMDBCarrier { } } - pub fn reload_database(&self) -> Result<(),maxminddb::MaxMindDBError> { + pub fn reload_database(&self) -> Result<(),maxminddb::MaxMindDbError> { match &self.path { Some(path) => self.load_database_from_path(Path::new(&path)), None => Ok(()), } } - pub fn load_database_from_path(&self, path: &Path) -> Result<(),maxminddb::MaxMindDBError> { + pub fn load_database_from_path(&self, path: &Path) -> Result<(),maxminddb::MaxMindDbError> { let mut mmdb = self.mmdb.write(); info!("Loading {} from '{}' ...", &self.name, path.display()); match maxminddb::Reader::open_readfile(path) {