Skip to content

Commit ca675fe

Browse files
committed
Update maxminddb to latest version without security issue
1 parent c4a1c90 commit ca675fe

File tree

4 files changed

+34
-32
lines changed

4 files changed

+34
-32
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
@@ -36,7 +36,7 @@ eyre = "0.6.11"
3636
headers = "0.4.1"
3737
jsonwebtoken = "9.3.1"
3838
lettre = { version = "0.11.18", default-features = false }
39-
maxminddb = "0.26.0"
39+
maxminddb = "0.27.0"
4040
notify = "8.2.0"
4141
opentelemetry = "0.31.0"
4242
opentelemetry-otlp = { version = "0.31.0", features = ["reqwest-rustls"] }

nts-pool-ke/src/servers/geo.rs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -371,28 +371,31 @@ impl ServerManager for GeographicServerManager {
371371
} else {
372372
&inner.regions_ipv6
373373
};
374-
let region =
375-
if let Ok(Some(location)) = inner.geodb.lookup::<geoip2::Country>(address.ip()) {
376-
debug!("Geolocation lookup for {:?}", location);
377-
location
378-
.country
379-
.and_then(|v| v.iso_code)
380-
.and_then(|v| regions.get(v))
381-
.or_else(|| {
382-
debug!("Falling back to continent, country zone does not exist");
383-
location
384-
.continent
385-
.and_then(|v| v.code)
386-
.and_then(|v| CONTINENTS.get(v))
387-
.and_then(|v| regions.get(*v))
388-
})
389-
} else {
390-
None
391-
}
392-
.unwrap_or_else(|| {
393-
debug!("Falling back to global, continent and country zone does not exist");
394-
regions.get(GLOBAL).unwrap()
395-
});
374+
let region = if let Ok(Some(location)) = inner
375+
.geodb
376+
.lookup(address.ip())
377+
.and_then(|r| r.decode::<geoip2::Country>())
378+
{
379+
debug!("Geolocation lookup for {:?}", location);
380+
location
381+
.country
382+
.iso_code
383+
.and_then(|v| regions.get(v))
384+
.or_else(|| {
385+
debug!("Falling back to continent, country zone does not exist");
386+
location
387+
.continent
388+
.code
389+
.and_then(|v| CONTINENTS.get(v))
390+
.and_then(|v| regions.get(*v))
391+
})
392+
} else {
393+
None
394+
}
395+
.unwrap_or_else(|| {
396+
debug!("Falling back to global, continent and country zone does not exist");
397+
regions.get(GLOBAL).unwrap()
398+
});
396399

397400
if region.is_empty() {
398401
debug!("Selected region is empty");

nts-pool-management/src/models/time_source.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,10 @@ pub async fn infer_regions(
111111

112112
let mut result = HashSet::new();
113113
for addr in addresses {
114-
let Some(lookup) = (match geodb.lookup::<maxminddb::geoip2::Country>(addr.ip()) {
114+
let Some(lookup) = (match geodb
115+
.lookup(addr.ip())
116+
.and_then(|r| r.decode::<maxminddb::geoip2::Country>())
117+
{
115118
Ok(lookup) => lookup,
116119
Err(e) => {
117120
tracing::error!("Failure during geoip lookup: {e}");
@@ -121,14 +124,10 @@ pub async fn infer_regions(
121124
continue;
122125
};
123126

124-
if let Some(continent) = lookup
125-
.continent
126-
.and_then(|v| v.code)
127-
.and_then(|c| CONTINENTS.get(c))
128-
{
127+
if let Some(continent) = lookup.continent.code.and_then(|c| CONTINENTS.get(c)) {
129128
result.insert((*continent).to_owned());
130129
}
131-
if let Some(country) = lookup.country.and_then(|v| v.iso_code) {
130+
if let Some(country) = lookup.country.iso_code {
132131
result.insert(country.to_owned());
133132
}
134133
}

0 commit comments

Comments
 (0)