diff --git a/easytier/src/connector/udp_hole_punch/common.rs b/easytier/src/connector/udp_hole_punch/common.rs index cd225af..7aaba64 100644 --- a/easytier/src/connector/udp_hole_punch/common.rs +++ b/easytier/src/connector/udp_hole_punch/common.rs @@ -499,17 +499,27 @@ impl PunchHoleServerCommon { use_last = true; } - let locked = all_listener_sockets.lock().await; + let mut locked = all_listener_sockets.lock().await; let listener = if use_last { - locked.last()? + locked.last_mut()? } else { // use the listener that is active most recently locked - .iter() + .iter_mut() .max_by_key(|listener| listener.last_active_time.load())? }; + if listener.mapped_addr.ip().is_unspecified() { + tracing::info!("listener mapped addr is unspecified, trying to get mapped addr"); + listener.mapped_addr = self + .get_global_ctx() + .get_stun_info_collector() + .get_udp_port_mapping(listener.mapped_addr.port()) + .await + .ok()?; + } + Some((listener.get_socket().await, listener.mapped_addr)) } diff --git a/easytier/src/peers/peer_conn.rs b/easytier/src/peers/peer_conn.rs index 2cb8284..0389c91 100644 --- a/easytier/src/peers/peer_conn.rs +++ b/easytier/src/peers/peer_conn.rs @@ -282,9 +282,7 @@ impl PeerConn { tracing::error!(?e, "peer conn send ctrl resp error"); } } else { - if zc_packet.is_lossy() { - let _ = sender.try_send(zc_packet); - } else if sender.send(zc_packet).await.is_err() { + if sender.send(zc_packet).await.is_err() { break; } } diff --git a/easytier/src/peers/peer_manager.rs b/easytier/src/peers/peer_manager.rs index 7139661..0a7ac78 100644 --- a/easytier/src/peers/peer_manager.rs +++ b/easytier/src/peers/peer_manager.rs @@ -185,7 +185,7 @@ impl PeerManager { ) -> Self { let my_peer_id = rand::random(); - let (packet_send, packet_recv) = mpsc::channel(100); + let (packet_send, packet_recv) = mpsc::channel(128); let peers = Arc::new(PeerMap::new( packet_send.clone(), global_ctx.clone(),