From a943f5bffc74d75b3a2a129fbe7e8e4f3fc34fd4 Mon Sep 17 00:00:00 2001 From: lubeilin <1791778603@qq.com> Date: Sun, 3 Sep 2023 17:24:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E5=88=87=E6=8D=A2NAT?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnt/src/channel/punch.rs | 3 ++- vnt/src/core/mod.rs | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/vnt/src/channel/punch.rs b/vnt/src/channel/punch.rs index 5e2f909..b093152 100644 --- a/vnt/src/channel/punch.rs +++ b/vnt/src/channel/punch.rs @@ -77,10 +77,11 @@ impl Punch { .await; } if !nat_info.ipv6_addr.ip().is_unspecified() && nat_info.ipv6_addr.port() != 0 { - let _ = self + let rs = self .context .send_main_udp(buf, SocketAddr::V6(nat_info.ipv6_addr)) .await; + log::info!("发送到ipv6地址:{:?},rs={:?}", nat_info.ipv6_addr, rs); } match nat_info.nat_type { NatType::Symmetric => { diff --git a/vnt/src/core/mod.rs b/vnt/src/core/mod.rs index 70bffbd..b8f2d23 100644 --- a/vnt/src/core/mod.rs +++ b/vnt/src/core/mod.rs @@ -439,8 +439,14 @@ impl VntUtil { if let Some(udp_proxy) = udp_proxy { tokio::spawn(udp_proxy.start()); } + let context = context.clone(); + let nat_test = nat_test.clone(); + //延迟切换类型,避免无效流量 + tokio::spawn(async move { + tokio::time::sleep(Duration::from_secs(15)).await; + context.switch(nat_test.nat_info().nat_type); + }); } - context.switch(nat_test.nat_info().nat_type); Ok(Vnt { config: self.config, current_device,