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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab
This commit is contained in:
rustdesk
2026-09-04 01:47:41 +08:00
parent 48fe740ad8
commit 115cbabb10
2 changed files with 7 additions and 4 deletions

View File

@@ -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"));