bump version 262 (#2158)

This commit is contained in:
KKRainbow
2026-04-25 10:22:24 +08:00
committed by GitHub
parent b4666be696
commit 2fb41ccbba
14 changed files with 88 additions and 41 deletions
+19
View File
@@ -5,6 +5,9 @@ use std::{
time::Duration,
};
#[cfg(test)]
use std::sync::atomic::{AtomicUsize, Ordering};
use anyhow::{Context, anyhow, bail};
use igd_next::{
AddAnyPortError, PortMappingProtocol, SearchOptions,
@@ -35,6 +38,19 @@ const PORT_MAPPING_BACKEND_IGD: &str = "igd";
type TokioGateway = Gateway<Tokio>;
#[cfg(test)]
static UDP_PORT_MAPPING_ATTEMPTS: AtomicUsize = AtomicUsize::new(0);
#[cfg(test)]
pub(crate) fn reset_udp_port_mapping_attempts_for_test() {
UDP_PORT_MAPPING_ATTEMPTS.store(0, Ordering::Relaxed);
}
#[cfg(test)]
pub(crate) fn udp_port_mapping_attempts_for_test() -> usize {
UDP_PORT_MAPPING_ATTEMPTS.load(Ordering::Relaxed)
}
enum PortMappingBackend {
NatPmp { gateway: Ipv4Addr },
Igd { gateway: TokioGateway },
@@ -262,6 +278,9 @@ async fn try_start_udp_port_mapping(
return Ok(None);
}
#[cfg(test)]
UDP_PORT_MAPPING_ATTEMPTS.fetch_add(1, Ordering::Relaxed);
let mapping = discover_udp_port_mapping(global_ctx.clone(), local_listener.clone()).await?;
tracing::info!(
%local_listener,