Skip to content

Commit 7fb64fe

Browse files
authored
fix(deps): Update maxminddb (#5432)
1 parent 71de3e2 commit 7fb64fe

File tree

3 files changed

+19
-32
lines changed

3 files changed

+19
-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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ json-forensics = "0.1.1"
133133
libc = "0.2.177"
134134
liblzma = "0.4.5"
135135
lru = "0.16.1"
136-
maxminddb = "0.26.0"
136+
maxminddb = "0.27.0"
137137
md5 = "0.8.0"
138138
memchr = "2.7.6"
139139
mimalloc = { version = "0.1.48", features = ["v3"] }
@@ -180,7 +180,9 @@ sentry = { version = "0.41.0", default-features = false, features = [
180180
] }
181181
sentry-core = "0.41.0"
182182
sentry-kafka-schemas = { version = "2.1.14", default-features = false }
183-
sentry-release-parser = { version = "1.4.0", default-features = false, features = ["semver-1"] }
183+
sentry-release-parser = { version = "1.4.0", default-features = false, features = [
184+
"semver-1",
185+
] }
184186
sentry-types = "0.41.0"
185187
sentry_protos = "0.4.2"
186188
serde = { version = "=1.0.228", features = ["derive", "rc"] }

relay-event-normalization/src/geo.rs

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ impl GeoIpLookup {
2828
P: AsRef<Path>,
2929
{
3030
#[cfg(feature = "mmap")]
31-
let reader = maxminddb::Reader::open_mmap(path)?;
31+
let reader = unsafe { maxminddb::Reader::open_mmap(path)? };
3232
#[cfg(not(feature = "mmap"))]
3333
let reader = maxminddb::Reader::open_readfile(path)?;
3434
Ok(GeoIpLookup(Some(Arc::new(reader))))
@@ -45,37 +45,22 @@ impl GeoIpLookup {
4545
return Ok(None);
4646
};
4747

48-
let city: maxminddb::geoip2::City = match reader.lookup(ip_address) {
49-
Ok(Some(x)) => x,
50-
Ok(None) => return Ok(None),
51-
Err(e) => return Err(e),
48+
let Some(city) = reader
49+
.lookup(ip_address)?
50+
.decode::<maxminddb::geoip2::City>()?
51+
else {
52+
return Ok(None);
5253
};
5354

5455
Ok(Some(Geo {
55-
country_code: Annotated::from(
56-
city.country
57-
.as_ref()
58-
.and_then(|country| Some(country.iso_code.as_ref()?.to_string())),
59-
),
60-
city: Annotated::from(
61-
city.city
62-
.as_ref()
63-
.and_then(|city| Some(city.names.as_ref()?.get("en")?.to_string())),
64-
),
65-
subdivision: Annotated::from(city.subdivisions.as_ref().and_then(|subdivisions| {
66-
subdivisions.first().and_then(|subdivision| {
67-
subdivision.names.as_ref().and_then(|subdivision_names| {
68-
subdivision_names
69-
.get("en")
70-
.map(|subdivision_name| subdivision_name.to_string())
71-
})
72-
})
73-
})),
74-
region: Annotated::from(
75-
city.country
76-
.as_ref()
77-
.and_then(|country| Some(country.names.as_ref()?.get("en")?.to_string())),
56+
country_code: Annotated::from(city.country.iso_code.map(String::from)),
57+
city: Annotated::from(city.city.names.english.map(String::from)),
58+
subdivision: Annotated::from(
59+
city.subdivisions
60+
.first()
61+
.and_then(|subdivision| subdivision.names.english.map(String::from)),
7862
),
63+
region: Annotated::from(city.country.names.english.map(String::from)),
7964
..Default::default()
8065
}))
8166
}

0 commit comments

Comments
 (0)