Skip to content

Commit

Permalink
去除默认绑定网卡的逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
vnt-dev committed Aug 12, 2024
1 parent 2fbdfe9 commit ce02b30
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
14 changes: 2 additions & 12 deletions vnt/src/core/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 3 additions & 1 deletion vnt/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};
Expand Down

0 comments on commit ce02b30

Please sign in to comment.