From 95db1b16ec81476ed62d5f4fce20cc3fbd72b24f Mon Sep 17 00:00:00 2001 From: GyulyVGC Date: Tue, 2 Dec 2025 12:34:40 +0100 Subject: [PATCH] update maxminddb to 0.27.0 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/mmdb/asn.rs | 2 +- src/mmdb/country.rs | 2 +- src/mmdb/types/mmdb_reader.rs | 13 +++++-------- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index acc2e277..da84ec22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2719,9 +2719,9 @@ dependencies = [ [[package]] name = "maxminddb" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a197e44322788858682406c74b0b59bf8d9b4954fe1f224d9a25147f1880bba" +checksum = "7ef0551fc3e7345a6c854c1026b0ddada1e443e51f4fb4cdcf86cc1a71d4b337" dependencies = [ "ipnetwork", "log", diff --git a/Cargo.toml b/Cargo.toml index f81bcd9c..fa0585e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,7 +43,7 @@ chrono = { version = "0.4.42", default-features = false, features = ["clock"] } plotters = { version = "0.3.7", default-features = false, features = ["area_series", "line_series"] } iced = { version = "0.13.1", features = ["tokio", "svg", "advanced", "lazy", "image"] } plotters-iced = "0.11.0" -maxminddb = "0.26.0" +maxminddb = "0.27.0" confy = "2.0.0" serde = { version = "1.0.228", default-features = false, features = ["derive"] } serde_json = { version = "1.0.145", features = ["preserve_order"] } diff --git a/src/mmdb/asn.rs b/src/mmdb/asn.rs index e120d2ee..c19c6074 100644 --- a/src/mmdb/asn.rs +++ b/src/mmdb/asn.rs @@ -7,7 +7,7 @@ #[allow(clippy::module_name_repetitions)] pub fn get_asn(address: &IpAddr, asn_db_reader: &MmdbReader) -> Asn { - if let Ok(Some(res)) = asn_db_reader.lookup::(*address) { + if let Some(res) = asn_db_reader.lookup::(*address) { return res.get_asn(); } Asn::default() diff --git a/src/mmdb/country.rs b/src/mmdb/country.rs index 9e5cd9a0..533163c1 100644 --- a/src/mmdb/country.rs +++ b/src/mmdb/country.rs @@ -7,7 +7,7 @@ #[allow(clippy::module_name_repetitions)] pub fn get_country(address: &IpAddr, country_db_reader: &MmdbReader) -> Country { - if let Ok(Some(res)) = country_db_reader.lookup::(*address) { + if let Some(res) = country_db_reader.lookup::(*address) { return res.get_country(); } Country::ZZ // unknown diff --git a/src/mmdb/types/mmdb_reader.rs b/src/mmdb/types/mmdb_reader.rs index d7e7e333..f67850c2 100644 --- a/src/mmdb/types/mmdb_reader.rs +++ b/src/mmdb/types/mmdb_reader.rs @@ -3,7 +3,7 @@ use crate::location; use crate::utils::error_logger::{ErrorLogger, Location}; -use maxminddb::{MaxMindDbError, Reader}; +use maxminddb::Reader; use serde::Deserialize; #[derive(Clone)] @@ -32,14 +32,11 @@ pub fn from(mmdb_path: &String, default_mmdb: &'static [u8]) -> MmdbReader { } } - pub fn lookup<'a, T: Deserialize<'a>>( - &'a self, - ip: IpAddr, - ) -> Result, MaxMindDbError> { + pub fn lookup<'a, T: Deserialize<'a>>(&'a self, ip: IpAddr) -> Option { match self { - MmdbReader::Default(reader) => reader.lookup(ip), - MmdbReader::Custom(reader) => reader.lookup(ip), - MmdbReader::Empty => Ok(None), + MmdbReader::Default(reader) => reader.lookup(ip).and_then(|lr| lr.decode()).ok()?, + MmdbReader::Custom(reader) => reader.lookup(ip).and_then(|lr| lr.decode()).ok()?, + MmdbReader::Empty => None, } } }