fix: don't panic on a peer's obfuscated port (u16) — widen the field

GetPeerAddressResponse narrowed obfuscated_port (u16) into a u8 via
try_into().unwrap(), panicking for any real obfuscated port (>255) and
unwinding the client's single ops-loop thread — hanging all downloads,
searches and peer events. Since download() now auto-resolves peer addresses
via GetPeerAddress, a download to any obfuscation-enabled peer could crash the
whole client. Widen Peer::obfuscated_port to u16 and stop truncating.
This commit is contained in:
michel
2026-07-19 17:45:30 +02:00
parent 51c5397d8f
commit 7c3bcc0598
2 changed files with 28 additions and 5 deletions
+7 -2
View File
@@ -1137,8 +1137,13 @@ impl Client {
port,
None,
0,
obfuscation_type.try_into().unwrap(),
obfuscated_port.try_into().unwrap(),
// obfuscation_type is a small enum; a
// real obfuscated_port is a full u16 and
// must not be truncated into a u8 (which
// panicked and took down the ops thread).
u8::try_from(obfuscation_type)
.unwrap_or(0),
obfuscated_port,
);
let client_context_clone =
client_context.clone();