From 4215488cb66e7c0dc56064abe55517fdf8924c23 Mon Sep 17 00:00:00 2001 From: lbl8603 <49143209+lbl8603@users.noreply.github.com> Date: Thu, 9 May 2024 20:16:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=AD=E7=BB=A7=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnt/src/core/conn.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/vnt/src/core/conn.rs b/vnt/src/core/conn.rs index 6feb6b3..9ed9b68 100644 --- a/vnt/src/core/conn.rs +++ b/vnt/src/core/conn.rs @@ -103,13 +103,17 @@ impl Vnt { stop_manager.clone(), config.port_mapping_list.clone(), )?; - let ports = config.ports.as_ref().map_or(vec![0, 0], |v| { + let mut ports = config.ports.as_ref().map_or(vec![0, 0], |v| { if v.is_empty() { vec![0, 0] } else { v.clone() } }); + if config.use_channel_type.is_only_relay() { + //中继模式下只监听一个端口就够了 + ports.truncate(1); + } //通道上下文 let (context, tcp_listener) = init_context( ports, @@ -327,15 +331,16 @@ pub fn start( client_cipher.clone(), ); } - // 定时地址探测 - maintain::addr_request( - &scheduler, - context.clone(), - current_device.clone(), - server_cipher.clone(), - config_info.clone(), - ); + if !context.use_channel_type().is_only_relay() { + // 定时地址探测 + maintain::addr_request( + &scheduler, + context.clone(), + current_device.clone(), + server_cipher.clone(), + config_info.clone(), + ); // 定时打洞 maintain::punch( &scheduler,