mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-01 16:59:21 +00:00
bump version 262 (#2158)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user