fix listener may have no mapped addr (#389)
Some checks are pending
EasyTier Core / pre_job (push) Waiting to run
EasyTier Core / build (freebsd-13.2-x86_64, 13.2, ubuntu-latest, x86_64-unknown-freebsd) (push) Blocked by required conditions
EasyTier Core / build (linux-aarch64, ubuntu-latest, aarch64-unknown-linux-musl) (push) Blocked by required conditions
EasyTier Core / build (linux-arm, ubuntu-latest, arm-unknown-linux-musleabi) (push) Blocked by required conditions
EasyTier Core / build (linux-armhf, ubuntu-latest, arm-unknown-linux-musleabihf) (push) Blocked by required conditions
EasyTier Core / build (linux-armv7, ubuntu-latest, armv7-unknown-linux-musleabi) (push) Blocked by required conditions
EasyTier Core / build (linux-armv7hf, ubuntu-latest, armv7-unknown-linux-musleabihf) (push) Blocked by required conditions
EasyTier Core / build (linux-mips, ubuntu-latest, mips-unknown-linux-musl) (push) Blocked by required conditions
EasyTier Core / build (linux-mipsel, ubuntu-latest, mipsel-unknown-linux-musl) (push) Blocked by required conditions
EasyTier Core / build (linux-x86_64, ubuntu-latest, x86_64-unknown-linux-musl) (push) Blocked by required conditions
EasyTier Core / build (macos-aarch64, macos-latest, aarch64-apple-darwin) (push) Blocked by required conditions
EasyTier Core / build (macos-x86_64, macos-latest, x86_64-apple-darwin) (push) Blocked by required conditions
EasyTier Core / build (windows-x86_64, windows-latest, x86_64-pc-windows-msvc) (push) Blocked by required conditions
EasyTier Core / core-result (push) Blocked by required conditions
EasyTier GUI / pre_job (push) Waiting to run
EasyTier GUI / build-gui (linux-aarch64, aarch64-unknown-linux-gnu, ubuntu-latest, aarch64-unknown-linux-musl) (push) Blocked by required conditions
EasyTier GUI / build-gui (linux-x86_64, x86_64-unknown-linux-gnu, ubuntu-latest, x86_64-unknown-linux-musl) (push) Blocked by required conditions
EasyTier GUI / build-gui (macos-aarch64, aarch64-apple-darwin, macos-latest, aarch64-apple-darwin) (push) Blocked by required conditions
EasyTier GUI / build-gui (macos-x86_64, x86_64-apple-darwin, macos-latest, x86_64-apple-darwin) (push) Blocked by required conditions
EasyTier GUI / build-gui (windows-x86_64, x86_64-pc-windows-msvc, windows-latest, x86_64-pc-windows-msvc) (push) Blocked by required conditions
EasyTier GUI / gui-result (push) Blocked by required conditions
EasyTier Mobile / pre_job (push) Waiting to run
EasyTier Mobile / build-mobile (android, ubuntu-latest, android) (push) Blocked by required conditions
EasyTier Mobile / mobile-result (push) Blocked by required conditions
EasyTier Test / pre_job (push) Waiting to run
EasyTier Test / test (push) Blocked by required conditions

This commit is contained in:
Sijie.Sun 2024-10-07 12:15:20 +08:00 committed by GitHub
parent 37ceb77bf6
commit d4e59ffc40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 7 deletions

View File

@ -499,17 +499,27 @@ impl PunchHoleServerCommon {
use_last = true; use_last = true;
} }
let locked = all_listener_sockets.lock().await; let mut locked = all_listener_sockets.lock().await;
let listener = if use_last { let listener = if use_last {
locked.last()? locked.last_mut()?
} else { } else {
// use the listener that is active most recently // use the listener that is active most recently
locked locked
.iter() .iter_mut()
.max_by_key(|listener| listener.last_active_time.load())? .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)) Some((listener.get_socket().await, listener.mapped_addr))
} }

View File

@ -282,9 +282,7 @@ impl PeerConn {
tracing::error!(?e, "peer conn send ctrl resp error"); tracing::error!(?e, "peer conn send ctrl resp error");
} }
} else { } else {
if zc_packet.is_lossy() { if sender.send(zc_packet).await.is_err() {
let _ = sender.try_send(zc_packet);
} else if sender.send(zc_packet).await.is_err() {
break; break;
} }
} }

View File

@ -185,7 +185,7 @@ impl PeerManager {
) -> Self { ) -> Self {
let my_peer_id = rand::random(); 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( let peers = Arc::new(PeerMap::new(
packet_send.clone(), packet_send.clone(),
global_ctx.clone(), global_ctx.clone(),