fix cone-to-cone punch (#401)

This commit is contained in:
Sijie.Sun 2024-10-09 22:39:06 +08:00 committed by GitHub
parent 63821e56bc
commit e344372616
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -110,12 +110,18 @@ impl PunchConeHoleClient {
.with_context(|| anyhow::anyhow!("failed to get local port from udp array"))?; .with_context(|| anyhow::anyhow!("failed to get local port from udp array"))?;
let local_port = local_addr.port(); let local_port = local_addr.port();
drop(local_socket);
let local_mapped_addr = global_ctx let local_mapped_addr = global_ctx
.get_stun_info_collector() .get_stun_info_collector()
.get_udp_port_mapping(local_port) .get_udp_port_mapping(local_port)
.await .await
.with_context(|| "failed to get udp port mapping")?; .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. // client -> server: tell server the mapped port, server will return the mapped address of listening port.
let rpc_stub = self let rpc_stub = self
.peer_mgr .peer_mgr