Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(cua-mesh): a mesh forward keeps its UDP port when Windows excludes a UDP range (#6418)
injaneityd6855806e6ee
diff --git a/libs/cua/crates/cua-mesh/src/node.rs b/libs/cua/crates/cua-mesh/src/node.rsindex fbacd5d17f..496de0153b 100644--- a/libs/cua/crates/cua-mesh/src/node.rs+++ b/libs/cua/crates/cua-mesh/src/node.rs@@ -1051,22 +1051,43 @@ impl Drop for Forward {}}+/// A TCP listener and a UDP socket on one port of `ip`. TCP and UDP have+/// separate port spaces, and Windows excludes ranges per protocol and hands+/// ports out in order, so TCP-first picks can all land in a block that+/// refuses UDP: picks alternate which protocol chooses the number, and+/// refused ones stay bound until the end so they are not handed out again.async fn bind_pair(ip: std::net::IpAddr) -> Result<(TcpListener, Option<UdpSocket>)> {- for _ in 0..16 {- let tcp = TcpListener::bind((ip, 0))- .await- .map_err(|e| Error::Io(e.to_string()))?;- let port = tcp- .local_addr()- .map_err(|e| Error::Io(e.to_string()))?- .port();- if let Ok(udp) = UdpSocket::bind((ip, port)).await {- return Ok((tcp, Some(udp)));+ let io = |e: std::io::Error| Error::Io(e.to_string());+ let mut refused_tcp = Vec::new();+ let mut refused_udp = Vec::new();+ let mut last_err = None;+ for pick in 0..16 {+ if pick % 2 == 0 {+ let tcp = TcpListener::bind((ip, 0)).await.map_err(io)?;+ let port = tcp.local_addr().map_err(io)?.port();+ match UdpSocket::bind((ip, port)).await {+ Ok(udp) => return Ok((tcp, Some(udp))),+ Err(e) => {+ last_err = Some(e);+ refused_tcp.push(tcp);+ }+ }+ } else if let Ok(udp) = UdpSocket::bind((ip, 0)).await {+ let port = udp.local_addr().map_err(io)?.port();+ match TcpListener::bind((ip, port)).await {+ Ok(tcp) => return Ok((tcp, Some(udp))),+ Err(e) => {+ last_err = Some(e);+ refused_udp.push(udp);+ }+ }}}- let tcp = TcpListener::bind((ip, 0))- .await- .map_err(|e| Error::Io(e.to_string()))?;+ tracing::warn!(+ %ip, error = ?last_err,+ "mesh forward without UDP: no port free for both TCP and UDP"+ );+ let tcp = TcpListener::bind((ip, 0)).await.map_err(io)?;Ok((tcp, None))}