mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 18:18:55 +00:00
chore: render contextual information more Sentry-friendly (#10386)
Sentry can group issues together that have unique identifiers in their message. Unfortunately, it does that only well for integers and UUIDs and not so much for hex-values. To avoid alert fatigue, we render the public key as a u256 which hopefully allows Sentry to group these together.
This commit is contained in:
7
rust/Cargo.lock
generated
7
rust/Cargo.lock
generated
@@ -943,6 +943,12 @@ dependencies = [
|
||||
"piper",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bnum"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "119771309b95163ec7aaf79810da82f7cd0599c19722d48b9c03894dca833966"
|
||||
|
||||
[[package]]
|
||||
name = "boringtun"
|
||||
version = "0.6.1"
|
||||
@@ -6907,6 +6913,7 @@ name = "snownet"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bnum",
|
||||
"boringtun",
|
||||
"bufferpool",
|
||||
"bytecodec",
|
||||
|
||||
@@ -56,6 +56,7 @@ aya-log-ebpf = { git = "https://github.com/aya-rs/aya" }
|
||||
backoff = { version = "0.4", features = ["tokio"] }
|
||||
base64 = { version = "0.22.1", default-features = false }
|
||||
bimap = "0.6"
|
||||
bnum = "0.13.0"
|
||||
boringtun = { version = "0.6", default-features = false }
|
||||
bufferpool = { path = "connlib/bufferpool" }
|
||||
bytecodec = "0.5.0"
|
||||
|
||||
@@ -6,6 +6,7 @@ license = { workspace = true }
|
||||
|
||||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
bnum = { workspace = true }
|
||||
boringtun = { workspace = true }
|
||||
bufferpool = { workspace = true }
|
||||
bytecodec = { workspace = true }
|
||||
|
||||
@@ -1465,7 +1465,7 @@ where
|
||||
let id = self
|
||||
.established_by_wireguard_session_index
|
||||
.get(&index.global())
|
||||
.with_context(|| format!("No connection for with index {index}"))?;
|
||||
.with_context(|| format!("No connection for index {}", index.global()))?;
|
||||
let connection = self
|
||||
.established
|
||||
.get_mut(id)
|
||||
@@ -1482,7 +1482,7 @@ where
|
||||
.established
|
||||
.iter_mut()
|
||||
.find(|(_, c)| c.tunnel.remote_static_public().as_bytes() == &key)
|
||||
.with_context(|| format!("No connection with public key {}", hex::encode(key)))?;
|
||||
.with_context(|| format!("No connection for public key {}", into_u256(key)))?;
|
||||
|
||||
Ok((*id, conn))
|
||||
}
|
||||
@@ -1529,6 +1529,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn into_u256(key: [u8; 32]) -> bnum::BUint<4> {
|
||||
// Note: `parse_str_radix` panics when the number is too big.
|
||||
// We are passing 32 u8's though which fits exactly into a u256.
|
||||
bnum::types::U256::parse_str_radix(&hex::encode(key), 16)
|
||||
}
|
||||
|
||||
fn add_local_candidate<TId>(
|
||||
id: TId,
|
||||
agent: &mut IceAgent,
|
||||
@@ -2753,4 +2759,20 @@ mod tests {
|
||||
assert!(agent.remote_candidates().contains(&expected_candidate2));
|
||||
assert!(!agent.remote_candidates().contains(&unexpected_candidate3));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn can_make_u256_out_of_byte_array() {
|
||||
let bytes = random();
|
||||
let _num = into_u256(bytes);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn u256_renders_as_int() {
|
||||
let num = into_u256([1; 32]);
|
||||
|
||||
assert_eq!(
|
||||
num.to_string(),
|
||||
"454086624460063511464984254936031011189294057512315937409637584344757371137"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user