update maxminddb to 0.27.0

This commit is contained in:
GyulyVGC
2025-12-02 12:34:40 +01:00
parent e33f1fd599
commit 95db1b16ec
5 changed files with 10 additions and 13 deletions

4
Cargo.lock generated
View File

@@ -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",

View File

@@ -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"] }

View File

@@ -7,7 +7,7 @@ pub const ASN_MMDB: &[u8] = include_bytes!("../../resources/DB/GeoLite2-ASN.mmdb
#[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::<MmdbAsnEntry>(*address) {
if let Some(res) = asn_db_reader.lookup::<MmdbAsnEntry>(*address) {
return res.get_asn();
}
Asn::default()

View File

@@ -7,7 +7,7 @@ pub const COUNTRY_MMDB: &[u8] = include_bytes!("../../resources/DB/GeoLite2-Coun
#[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::<MmdbCountryEntry>(*address) {
if let Some(res) = country_db_reader.lookup::<MmdbCountryEntry>(*address) {
return res.get_country();
}
Country::ZZ // unknown

View File

@@ -3,7 +3,7 @@ use std::sync::Arc;
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 @@ impl MmdbReader {
}
}
pub fn lookup<'a, T: Deserialize<'a>>(
&'a self,
ip: IpAddr,
) -> Result<Option<T>, MaxMindDbError> {
pub fn lookup<'a, T: Deserialize<'a>>(&'a self, ip: IpAddr) -> Option<T> {
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,
}
}
}