fix: update vulnerable rust dependencies

This commit is contained in:
fanyang
2026-06-16 23:44:14 +08:00
parent 034f5066cd
commit af2e991df2
3 changed files with 140 additions and 147 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ dashmap = "6.1"
url = "2.2"
async-trait = "0.1"
maxminddb = "0.24"
maxminddb = "0.27"
once_cell = "1.18"
axum = { version = "0.7", features = ["macros"] }
+35 -19
View File
@@ -245,32 +245,40 @@ impl ClientManager {
}
let location = if let Some(db) = &*geoip_db {
match db.lookup::<geoip2::City>(ip) {
Ok(city) => {
match db.lookup(ip).and_then(|result| result.decode::<geoip2::City>()) {
Ok(Some(city)) => {
let country = city
.country
.and_then(|c| c.names)
.and_then(|n| {
n.get("zh-CN")
.or_else(|| n.get("en"))
.map(|s| s.to_string())
})
.names
.simplified_chinese
.or(city.country.names.english)
.map(|s| s.to_string())
.unwrap_or_else(|| "海外".to_string());
let city_name = city.city.and_then(|c| c.names).and_then(|n| {
n.get("zh-CN")
.or_else(|| n.get("en"))
.map(|s| s.to_string())
});
let city_name = city
.city
.names
.simplified_chinese
.or(city.city.names.english)
.map(|s| s.to_string());
let region = city.subdivisions.map(|r| {
r.iter()
.filter_map(|x| x.names.as_ref())
.filter_map(|x| x.get("zh-CN").or_else(|| x.get("en")))
let region = if city.subdivisions.is_empty() {
None
} else {
let region = city
.subdivisions
.iter()
.filter_map(|x| x.names.simplified_chinese.or(x.names.english))
.map(|x| x.to_string())
.collect::<Vec<_>>()
.join(",")
});
.join(",");
if region.is_empty() {
None
} else {
Some(region)
}
};
Location {
country,
@@ -278,6 +286,14 @@ impl ClientManager {
region,
}
}
Ok(None) => {
tracing::debug!("GeoIP data not found for {}", ip);
Location {
country: "海外".to_string(),
city: None,
region: None,
}
}
Err(err) => {
tracing::debug!("GeoIP lookup failed for {}: {}", ip, err);
Location {