mirror of
https://github.com/LowderPlay/cheburcheck.git
synced 2026-09-27 09:23:21 +03:00
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] <support@github.com> * fix: implement new version * chore: cleanup imports --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Lowder <me@lowderplay.dev>
This commit is contained in:
co-authored by
Lowder
parent
608aab5879
commit
2c0345a0e5
Generated
+2
-2
@@ -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",
|
||||
|
||||
+1
-1
@@ -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"
|
||||
|
||||
+22
-23
@@ -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<IpInfo, MaxMindDbError> {
|
||||
let asn = if let Some(db) = &self.asn {
|
||||
db.lookup::<geoip2::Asn>(ip)?
|
||||
db.lookup(ip)?.decode::<geoip2::Asn>()?
|
||||
} else { None };
|
||||
let city = if let Some(db) = &self.city {
|
||||
db.lookup::<City>(ip)?
|
||||
db.lookup(ip)?.decode::<City>()?
|
||||
} else { None };
|
||||
let country = if let Some(db) = &self.country {
|
||||
db.lookup::<Country>(ip)?
|
||||
db.lookup(ip)?.decode::<Country>()?
|
||||
} 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 {
|
||||
|
||||
Reference in New Issue
Block a user