Update maxminddb dependency to 0.26 and adapt to breaking changes

This commit is contained in:
Slatian
2025-04-11 21:40:41 +02:00
parent 5c322f2611
commit 34e5e8f95c
3 changed files with 10 additions and 10 deletions

View File

@ -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::<geoip2::Asn>(*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::<geoip2::City>(*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) {