From e3443726168fa61b236c3ea1bfa6b37ed60fb999 Mon Sep 17 00:00:00 2001 From: "Sijie.Sun" Date: Wed, 9 Oct 2024 22:39:06 +0800 Subject: [PATCH] fix cone-to-cone punch (#401) --- easytier/src/connector/udp_hole_punch/cone.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/easytier/src/connector/udp_hole_punch/cone.rs b/easytier/src/connector/udp_hole_punch/cone.rs index e8acf20..8822e57 100644 --- a/easytier/src/connector/udp_hole_punch/cone.rs +++ b/easytier/src/connector/udp_hole_punch/cone.rs @@ -110,12 +110,18 @@ impl PunchConeHoleClient { .with_context(|| anyhow::anyhow!("failed to get local port from udp array"))?; let local_port = local_addr.port(); + drop(local_socket); let local_mapped_addr = global_ctx .get_stun_info_collector() .get_udp_port_mapping(local_port) .await .with_context(|| "failed to get udp port mapping")?; + let local_socket = { + let _g = self.peer_mgr.get_global_ctx().net_ns.guard(); + Arc::new(UdpSocket::bind(local_addr).await?) + }; + // client -> server: tell server the mapped port, server will return the mapped address of listening port. let rpc_stub = self .peer_mgr