From ce02b30b2be908043bab590fd784145a16b402bb Mon Sep 17 00:00:00 2001 From: lbl8603 <49143209+lbl8603@users.noreply.github.com> Date: Mon, 12 Aug 2024 22:04:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=BB=98=E8=AE=A4=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E7=BD=91=E5=8D=A1=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 | 14 ++------------ vnt/src/core/mod.rs | 4 +++- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/vnt/src/core/conn.rs b/vnt/src/core/conn.rs index 7821c85..dfad263 100644 --- a/vnt/src/core/conn.rs +++ b/vnt/src/core/conn.rs @@ -12,7 +12,6 @@ use crate::channel::context::ChannelContext; use crate::channel::idle::Idle; use crate::channel::punch::{NatInfo, Punch}; use crate::channel::sender::IpPacketSender; -use crate::channel::socket::LocalInterface; use crate::channel::{init_channel, init_context, Route, RouteKey}; use crate::cipher::Cipher; #[cfg(feature = "server_encrypt")] @@ -30,7 +29,7 @@ use crate::tun_tap_device::tun_create_helper::{DeviceAdapter, TunDeviceHelper}; use crate::tun_tap_device::vnt_device::DeviceWrite; use crate::util::limit::TrafficMeterMultiAddress; use crate::util::{Scheduler, StopManager}; -use crate::{channel, nat, VntCallback}; +use crate::{nat, VntCallback}; #[derive(Clone)] pub struct Vnt { @@ -138,16 +137,7 @@ impl VntInner { } else { nat::local_ipv4() }; - let default_interface = if config.in_ips.is_empty() { - //没有改变路由,不需要绑定网卡 - LocalInterface::default() - } else { - //vnt的流量都走这个接口 - let default_interface = - channel::socket::get_best_interface(local_ipv4.unwrap_or(Ipv4Addr::UNSPECIFIED))?; - log::info!("default_interface = {:?}", default_interface); - default_interface - }; + let default_interface = config.local_interface.clone(); //基础信息 let config_info = BaseConfigInfo::new( diff --git a/vnt/src/core/mod.rs b/vnt/src/core/mod.rs index 89a578b..ab8b8b7 100644 --- a/vnt/src/core/mod.rs +++ b/vnt/src/core/mod.rs @@ -164,7 +164,9 @@ impl Config { } in_ips.sort_by(|(dest1, _, _), (dest2, _, _)| dest2.cmp(dest1)); let local_interface = if let Some(local_ip) = local_ipv4 { - crate::channel::socket::get_interface(local_ip)? + let default_interface = crate::channel::socket::get_interface(local_ip)?; + log::info!("default_interface = {:?}", default_interface); + default_interface } else { LocalInterface::default() };