refact(port-forward): comments and logs

Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
fufesou
2026-03-03 20:47:56 +08:00
parent 3b225b7c6c
commit a563976239

View File

@@ -1368,7 +1368,20 @@ impl Connection {
self.port_forward_socket = Some(Framed::new(sock, BytesCodec::new()));
true
}
_ => {
Ok(Err(e)) => {
log::warn!("Port forward connect failed for {}: {}", addr, e);
if is_rdp {
addr = "RDP".to_owned();
}
self.send_login_error(format!(
"Failed to access remote {}. Please make sure it is reachable/open.",
addr
))
.await;
false
}
Err(e) => {
log::warn!("Port forward connect timed out for {}: {}", addr, e);
if is_rdp {
addr = "RDP".to_owned();
}
@@ -1382,6 +1395,8 @@ impl Connection {
}
}
// Returns whether this connection should be kept alive.
// `true` does not necessarily mean authorization succeeded (e.g. REQUIRE_2FA case).
async fn send_logon_response_and_keep_alive(&mut self) -> bool {
if self.authorized {
return true;
@@ -1415,6 +1430,7 @@ impl Connection {
}
});
self.send_login_error(crate::client::REQUIRE_2FA).await;
// Keep the connection alive so the client can continue with 2FA.
return true;
}
if !self.connect_port_forward_if_needed().await {