From d6a670e7641f8531f3e54a9ecbce3566f65625cf Mon Sep 17 00:00:00 2001 From: rustdesk Date: Tue, 25 Aug 2026 08:38:56 +0800 Subject: [PATCH] bump hbb_common: name the punch by every transport it carries MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `get_local_endpoint_trickle` became `local_endpoint() -> &str`, which cannot fail, so both call sites lose an unreachable error arm — the mediator's closed a pc against a failure that no longer exists. `punch_type` named one transport, and picked it off `allow_tcp_punch`. A round carries several at once — a NAT port and a v6 address and an offer — and since the TCP punch became a switch it can carry none, so one name had to misreport both: the logs of the round that broke WebRTC read "#1 UDP punch attempt" while the request also carried the v6 address and the offer that was actually failing, and a round with nothing to punch with was labelled "WebRTC". List them instead — "UDP+IPv6+WebRTC" — and call the empty round "Relay", which is what it can still end as and what `typ` prints for it. The offer is moved into the request rather than cloned into it; that was its last use. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_019UzcMTdYTEv2QbMHcTSUy3 --- libs/hbb_common | 2 +- src/client.rs | 46 ++++++++++++++++++++++---------------- src/rendezvous_mediator.rs | 9 +------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/libs/hbb_common b/libs/hbb_common index 3e7968763..748eefdf2 160000 --- a/libs/hbb_common +++ b/libs/hbb_common @@ -1 +1 @@ -Subproject commit 3e7968763a6085dffa1dfba1593f15b9d3cf4315 +Subproject commit 748eefdf2ef10eb8d92ac9b30b7373185e94eead diff --git a/src/client.rs b/src/client.rs index 44e2295b1..e77939799 100644 --- a/src/client.rs +++ b/src/client.rs @@ -855,25 +855,33 @@ impl Client { .map(|(socket, addr)| (Some(socket), Some(addr))) .unwrap_or((None, None)); let udp_nat_port = udp.1.map(|x| *x.lock().unwrap()).unwrap_or(0); - let webrtc_sdp_offer = - if let Some(stream) = webrtc_offerer.as_ref().and_then(|g| g.stream()) { - match stream.get_local_endpoint_trickle().await { - Ok(endpoint) => endpoint, - Err(err) => { - log::warn!("failed to read local WebRTC offer: {}", err); - String::new() - } - } - } else { - String::new() - }; + let webrtc_sdp_offer = webrtc_offerer + .as_ref() + .and_then(|g| g.stream()) + .map(|stream| stream.local_endpoint().to_owned()) + .unwrap_or_default(); let allow_tcp_punch = tcp_punch_allowed() && request_allows_tcp_punch(&webrtc_sdp_offer); - let punch_type = if udp_nat_port > 0 { - "UDP" - } else if allow_tcp_punch { - "TCP" + // Every direct transport this round carries, not one of them: a round can carry several + // at once (a NAT port and an offer and a v6 address), and since the TCP punch became a + // switch it can carry none — a single name had to misreport both. `relay` is not a punch, + // it is what a round with nothing to punch with can still end as. + let mut transports = Vec::new(); + if udp_nat_port > 0 { + transports.push("UDP"); + } + if allow_tcp_punch { + transports.push("TCP"); + } + if ipv6.1.is_some() { + transports.push("IPv6"); + } + if !webrtc_sdp_offer.is_empty() { + transports.push("WebRTC"); + } + let punch_type = if transports.is_empty() { + "Relay".to_owned() } else { - "WebRTC" + transports.join("+") }; msg_out.set_punch_hole_request(PunchHoleRequest { id: peer.to_owned(), @@ -889,7 +897,7 @@ impl Client { // The offer's envelope itself declares its ICE policy (`ice_policy: "all"` under // pure ws), telling the controlled side its answer may gather every candidate // type despite force_relay instead of requiring TURN. - webrtc_sdp_offer: webrtc_sdp_offer.clone(), + webrtc_sdp_offer, ..Default::default() }); let webrtc_session_key = webrtc_offerer @@ -1310,7 +1318,7 @@ impl Client { webrtc_for_connect, webrtc_bridge_stop, allow_tcp_punch, - punch_type, + &punch_type, ) .await?, (feedback, rendezvous_server), diff --git a/src/rendezvous_mediator.rs b/src/rendezvous_mediator.rs index dfa7339a8..28eeb1b5d 100644 --- a/src/rendezvous_mediator.rs +++ b/src/rendezvous_mediator.rs @@ -700,14 +700,7 @@ impl RendezvousMediator { ) -> ResultType { let mut stream = WebRTCStream::new(&ph.webrtc_sdp_offer, relay_only_ice, CONNECT_TIMEOUT).await?; - let answer = match stream.get_local_endpoint_trickle().await { - Ok(answer) => answer, - Err(e) => { - // Close the freshly-created pc so a failure here doesn't leak it in SESSIONS. - stream.close().await; - return Err(e); - } - }; + let answer = stream.local_endpoint().to_owned(); let session_key = stream.session_key().to_owned(); let return_route = ph.socket_addr.clone();