From 2c0345a0e520dcbc90206cc2f78bb58bca606501 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 15:55:40 +0500 Subject: [PATCH] chore(deps): bump maxminddb from 0.26.0 to 0.27.3 (#45) * chore(deps): bump maxminddb from 0.26.0 to 0.27.3 Bumps [maxminddb](https://github.com/oschwald/maxminddb-rust) from 0.26.0 to 0.27.3. - [Release notes](https://github.com/oschwald/maxminddb-rust/releases) - [Changelog](https://github.com/oschwald/maxminddb-rust/blob/main/CHANGELOG.md) - [Commits](https://github.com/oschwald/maxminddb-rust/compare/0.26.0...v0.27.3) --- updated-dependencies: - dependency-name: maxminddb dependency-version: 0.27.3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * fix: implement new version * chore: cleanup imports --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Lowder --- Cargo.lock | 4 ++-- querying/Cargo.toml | 2 +- querying/src/geoip.rs | 45 +++++++++++++++++++++---------------------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8ea3af..5e51eef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1791,9 +1791,9 @@ dependencies = [ [[package]] name = "maxminddb" -version = "0.26.0" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a197e44322788858682406c74b0b59bf8d9b4954fe1f224d9a25147f1880bba" +checksum = "76371bd37ce742f8954daabd0fde7f1594ee43ac2200e20c003ba5c3d65e2192" dependencies = [ "ipnetwork", "log", diff --git a/querying/Cargo.toml b/querying/Cargo.toml index ec8752b..1ec9c11 100644 --- a/querying/Cargo.toml +++ b/querying/Cargo.toml @@ -12,7 +12,7 @@ trie-rs = "0.4.2" tokio = { workspace = true } reqwest = { workspace = true } csv = "1.4.0" -maxminddb = "0.26.0" +maxminddb = "0.27.3" log = { workspace = true } hickory-resolver = { version = "0.26.0-alpha.1", features = ["tokio", "webpki-roots", "https-ring"] } thiserror = "2.0.18" diff --git a/querying/src/geoip.rs b/querying/src/geoip.rs index 4d0d876..afdc194 100644 --- a/querying/src/geoip.rs +++ b/querying/src/geoip.rs @@ -1,6 +1,6 @@ use crate::updater::{fetch_db, Updatable}; use async_trait::async_trait; -use maxminddb::geoip2::{city, country, City, Country}; +use maxminddb::geoip2::{City, Country}; use maxminddb::{geoip2, MaxMindDbError}; use serde::Serialize; use std::io::Error; @@ -58,38 +58,37 @@ impl GeoIp { pub fn lookup(&self, ip: IpAddr) -> Result { let asn = if let Some(db) = &self.asn { - db.lookup::(ip)? + db.lookup(ip)?.decode::()? } else { None }; let city = if let Some(db) = &self.city { - db.lookup::(ip)? + db.lookup(ip)?.decode::()? } else { None }; let country = if let Some(db) = &self.country { - db.lookup::(ip)? + db.lookup(ip)?.decode::()? } else { None }; - let country_code = country.as_ref().map(|c| c.country.as_ref() - .map(|c| c.iso_code - .map(|c| c.to_string())) - .flatten()) - .flatten(); + let country_code = country.as_ref() + .map(|c| c.country.iso_code) + .flatten() + .map(|c| c.to_string()); let city_geo_name_id = city.as_ref() - .map(|c| c.city.as_ref() - .map(|c| c.geoname_id) - .flatten()) + .map(|c| c.city.geoname_id) .flatten(); - let location = match (city, country) { - (Some(City { city: Some(city::City { names: Some(city), .. }), - country: Some(country::Country { names: Some(country), .. }), .. }), _) => { - let city = city.get("ru").unwrap_or(&"-"); - let country = country.get("ru").unwrap_or(&"-"); - format!("{}, {}", city, country) - } - (_, Some(Country { country: Some(country::Country { names: Some(country), .. }), .. })) => { - country.get("ru").unwrap_or(&"-").to_string() - } - (_, _) => "-".to_string(), + let mut location = (None, None); + if let Some(city) = city { + location.0 = city.city.names.russian.or(city.city.names.english); + } + if let Some(country) = country { + location.1 = country.country.names.russian.or(country.country.names.english); + } + + let location = match location { + (Some(city), Some(country)) => format!("{}, {}", city, country), + (Some(city), None) => city.to_string(), + (None, Some(country)) => country.to_string(), + (None, None) => "-".to_string(), }; Ok(IpInfo {