Exclude 7681(ttyd) from port forwarding list
Bug: 380058763
Test: Run VmTerminalApp
Change-Id: I8311c1f2506b9b6b2da0c05f39d52a55b76a14f4
diff --git a/guest/forwarder_guest_launcher/src/main.rs b/guest/forwarder_guest_launcher/src/main.rs
index 1da37b4..f6944d6 100644
--- a/guest/forwarder_guest_launcher/src/main.rs
+++ b/guest/forwarder_guest_launcher/src/main.rs
@@ -35,6 +35,7 @@
}
const NON_PREVILEGED_PORT_RANGE_START: i32 = 1024;
+const TTYD_PORT: i32 = 7681;
const TCPSTATES_IP_4: i8 = 4;
const TCPSTATES_STATE_CLOSE: &str = "CLOSE";
const TCPSTATES_STATE_LISTEN: &str = "LISTEN";
@@ -108,6 +109,10 @@
Ok(())
}
+fn is_forwardable_port(port: i32) -> bool {
+ port >= NON_PREVILEGED_PORT_RANGE_START && port != TTYD_PORT
+}
+
async fn report_active_ports(
mut client: DebianServiceClient<Channel>,
) -> Result<(), Box<dyn std::error::Error>> {
@@ -130,7 +135,7 @@
.map(|x| x.socket)
.filter(|x| x.is_ipv4())
.map(|x| x.port().into())
- .filter(|x| *x >= NON_PREVILEGED_PORT_RANGE_START) // Ignore privileged ports
+ .filter(|x| is_forwardable_port(*x))
.collect();
send_active_ports_report(listening_ports.clone(), &mut client).await?;
@@ -140,7 +145,7 @@
if row.ip != TCPSTATES_IP_4 {
continue;
}
- if row.lport < NON_PREVILEGED_PORT_RANGE_START {
+ if !is_forwardable_port(row.lport) {
continue;
}
if row.rport > 0 {