From 216b1d99e6799a134aa2352943bfb664f3f66a04 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 4 Sep 2026 01:47:41 +0800 Subject: [PATCH] port forward: fix round 1 review findings Drop the mux default-false assignment now that definite-assignment proves every path that reads it has set it; the enable-port-forward-mux config commit picks up the missing attribution trailers; the default-on test pins the enable- prefix itself rather than option2bool's weaker fallback. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab --- libs/hbb_common | 2 +- src/port_forward.rs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libs/hbb_common b/libs/hbb_common index 26da70418..1e617ddf4 160000 --- a/libs/hbb_common +++ b/libs/hbb_common @@ -1 +1 @@ -Subproject commit 26da70418c1ad560385386da3b0112cdfd63f400 +Subproject commit 1e617ddf4d7e13ee1d24a339154020b1ccf9a940 diff --git a/src/port_forward.rs b/src/port_forward.rs index 2c240eba8..75af68725 100644 --- a/src/port_forward.rs +++ b/src/port_forward.rs @@ -265,7 +265,7 @@ async fn connect_and_login( } let mut buffer = Vec::new(); let mut local_eof = false; - let mut mux = false; + let mux; let mut received = false; let mut challenge = None; let mut pending_login = None; @@ -461,8 +461,11 @@ mod tests { #[test] fn port_forward_mux_defaults_to_on() { use hbb_common::config::{keys, option2bool}; - // The `enable-` prefix is what makes an unset value mean on. Getting the - // key's name wrong silently flips the default, so pin it here. + // option2bool's fallback branch is also "on unless N", so the value + // assertions below would pass for a prefixless key too. The `enable-` + // prefix is what actually guarantees the default, and renaming the key + // to an `allow-` one would silently flip it — pin the prefix itself. + assert!(keys::OPTION_ENABLE_PORT_FORWARD_MUX.starts_with("enable-")); assert!(option2bool(keys::OPTION_ENABLE_PORT_FORWARD_MUX, "")); assert!(option2bool(keys::OPTION_ENABLE_PORT_FORWARD_MUX, "Y")); assert!(!option2bool(keys::OPTION_ENABLE_PORT_FORWARD_MUX, "N"));