Skip to content

Commit

Permalink
增加绑定网卡
Browse files Browse the repository at this point in the history
  • Loading branch information
vnt-dev committed Aug 8, 2024
1 parent 7901407 commit 2fbdfe9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions vnt/src/core/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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 @@ -29,7 +30,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::{nat, VntCallback};
use crate::{channel, nat, VntCallback};

#[derive(Clone)]
pub struct Vnt {
Expand Down Expand Up @@ -137,9 +138,16 @@ impl VntInner {
} else {
nat::local_ipv4()
};

let default_interface = config.local_interface.clone();
log::info!("default_interface = {:?}", default_interface);
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 config_info = BaseConfigInfo::new(
Expand Down

0 comments on commit 2fbdfe9

Please sign in to comment.