Skip to content

Commit bfdd0dc

Browse files
authored
Merge pull request #74 from openhpc/2025-11-29-maxminddb
Bump maxminddb from 0.26.0 to 0.27.0
2 parents 9a4854f + 607a552 commit bfdd0dc

File tree

3 files changed

+15
-19
lines changed

3 files changed

+15
-19
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ chrono = "0.4.42"
88
clap = { version = "4.3.24", features = ["derive"] }
99
console = "0.16.1"
1010
indicatif = "0.18.3"
11-
maxminddb = "0.26.0"
11+
maxminddb = "0.27.0"
1212
plotly = { version = "0.8.4", features = ["kaleido"] }
1313
rayon = "1.11.0"
1414
regex = "1.12.2"

src/main.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,15 +1391,13 @@ fn fill_country_results(params: &Args) -> Result<(), Box<dyn std::error::Error>>
13911391
for result in &*data {
13921392
result.ipv4.par_iter().for_each(|(key, value)| {
13931393
let client_country = match geoip_reader
1394-
.lookup::<maxminddb::geoip2::Country>(std::net::IpAddr::V4(Ipv4Addr::from(*key)))
1394+
.lookup(std::net::IpAddr::V4(Ipv4Addr::from(*key)))
1395+
.and_then(|r| r.decode::<maxminddb::geoip2::Country>())
13951396
{
1396-
Ok(Some(c)) => match c.country {
1397-
Some(co) => match co.iso_code {
1398-
Some(iso) => iso.to_string(),
1399-
_ => "N/A".to_string(),
1400-
},
1401-
_ => "N/A".to_string(),
1402-
},
1397+
Ok(Some(c)) => c
1398+
.country
1399+
.iso_code
1400+
.map_or("N/A".to_string(), |iso| iso.to_string()),
14031401
_ => "N/A".to_string(),
14041402
};
14051403

@@ -1427,15 +1425,13 @@ fn fill_country_results(params: &Args) -> Result<(), Box<dyn std::error::Error>>
14271425
});
14281426
result.ipv6.par_iter().for_each(|(key, value)| {
14291427
let client_country = match geoip_reader
1430-
.lookup::<maxminddb::geoip2::Country>(std::net::IpAddr::V6(Ipv6Addr::from(*key)))
1428+
.lookup(std::net::IpAddr::V6(Ipv6Addr::from(*key)))
1429+
.and_then(|r| r.decode::<maxminddb::geoip2::Country>())
14311430
{
1432-
Ok(Some(c)) => match c.country {
1433-
Some(co) => match co.iso_code {
1434-
Some(iso) => iso.to_string(),
1435-
_ => "N/A".to_string(),
1436-
},
1437-
_ => "N/A".to_string(),
1438-
},
1431+
Ok(Some(c)) => c
1432+
.country
1433+
.iso_code
1434+
.map_or("N/A".to_string(), |iso| iso.to_string()),
14391435
_ => "N/A".to_string(),
14401436
};
14411437

0 commit comments

Comments
 (0)