diff --git a/vnt-cli/Cargo.toml b/vnt-cli/Cargo.toml index c7ece4d..96dcfdf 100644 --- a/vnt-cli/Cargo.toml +++ b/vnt-cli/Cargo.toml @@ -30,7 +30,7 @@ signal-hook = "0.3.17" winapi = { version = "0.3.9", features = ["handleapi", "processthreadsapi", "winnt", "securitybaseapi", "impl-default"] } [features] -default = ["vnt/inner_tun","server_encrypt", "aes_gcm", "aes_cbc", "aes_ecb", "sm4_cbc", "chacha20_poly1305", "ip_proxy", "port_mapping", "log", "command", "file_config", "lz4"] +default = ["vnt/integrated_tun","server_encrypt", "aes_gcm", "aes_cbc", "aes_ecb", "sm4_cbc", "chacha20_poly1305", "ip_proxy", "port_mapping", "log", "command", "file_config", "lz4"] openssl = ["vnt/openssl"] openssl-vendored = ["vnt/openssl-vendored"] ring-cipher = ["vnt/ring-cipher"] diff --git a/vnt/Cargo.toml b/vnt/Cargo.toml index bc5c186..684c471 100644 --- a/vnt/Cargo.toml +++ b/vnt/Cargo.toml @@ -53,7 +53,7 @@ protoc-bin-vendored = "3.0.0" cfg_aliases = "0.2.1" [features] -default = ["server_encrypt", "aes_gcm", "aes_cbc", "aes_ecb", "sm4_cbc", "chacha20_poly1305", "ip_proxy", "port_mapping", "lz4_compress", "zstd_compress","inner_tun"] +default = ["server_encrypt", "aes_gcm", "aes_cbc", "aes_ecb", "sm4_cbc", "chacha20_poly1305", "ip_proxy", "port_mapping", "lz4_compress", "zstd_compress","integrated_tun"] openssl = ["openssl-sys"] # 从源码编译 openssl-vendored = ["openssl-sys/vendored"] @@ -68,4 +68,4 @@ ip_proxy = ["tokio"] port_mapping = ["tokio"] lz4_compress = ["lz4_flex"] zstd_compress = ["zstd"] -inner_tun = ["tun"] +integrated_tun = ["tun"] diff --git a/vnt/src/core/conn.rs b/vnt/src/core/conn.rs index 7d14533..f7f03e0 100644 --- a/vnt/src/core/conn.rs +++ b/vnt/src/core/conn.rs @@ -21,7 +21,7 @@ use crate::handle::maintain::PunchReceiver; use crate::handle::recv_data::RecvDataHandler; use crate::handle::{maintain, BaseConfigInfo, ConnectStatus, CurrentDeviceInfo, PeerDeviceInfo}; use crate::nat::NatTest; -#[cfg(feature = "inner_tun")] +#[cfg(feature = "integrated_tun")] use crate::tun_tap_device::tun_create_helper::{DeviceAdapter, TunDeviceHelper}; use crate::tun_tap_device::vnt_device::DeviceWrite; use crate::util::{ @@ -44,11 +44,11 @@ pub struct Vnt { } impl Vnt { - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] pub fn new(config: Config, callback: Call) -> anyhow::Result { Vnt::new_device0(config, callback, DeviceAdapter::default()) } - #[cfg(not(feature = "inner_tun"))] + #[cfg(not(feature = "integrated_tun"))] pub fn new_device( config: Config, callback: Call, @@ -175,7 +175,7 @@ impl Vnt { ); let up_counter = SingleU64Adder::new(); let up_count_watcher = up_counter.watch(); - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] let tun_device_helper = { TunDeviceHelper::new( stop_manager.clone(), @@ -212,7 +212,7 @@ impl Vnt { proxy_map.clone(), down_counter, handshake.clone(), - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] tun_device_helper, ); diff --git a/vnt/src/handle/callback.rs b/vnt/src/handle/callback.rs index 4e4d0ae..fe52fa3 100644 --- a/vnt/src/handle/callback.rs +++ b/vnt/src/handle/callback.rs @@ -284,7 +284,7 @@ pub trait VntCallback: Clone + Send + Sync + 'static { /// 创建网卡的信息 #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))] - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] fn create_tun(&self, _info: DeviceInfo) {} /// 连接 fn connect(&self, _info: ConnectInfo) {} @@ -296,7 +296,7 @@ pub trait VntCallback: Clone + Send + Sync + 'static { fn register(&self, _info: RegisterInfo) -> bool { true } - #[cfg(not(feature = "inner_tun"))] + #[cfg(not(feature = "integrated_tun"))] fn create_device( &self, _channel_sender: crate::channel::sender::ChannelSender, @@ -304,7 +304,7 @@ pub trait VntCallback: Clone + Send + Sync + 'static { ) { } #[cfg(target_os = "android")] - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] fn generate_tun(&self, _info: DeviceConfig) -> usize { 0 } diff --git a/vnt/src/handle/mod.rs b/vnt/src/handle/mod.rs index 208b63d..047f691 100644 --- a/vnt/src/handle/mod.rs +++ b/vnt/src/handle/mod.rs @@ -7,7 +7,7 @@ pub mod handshaker; pub mod maintain; pub mod recv_data; pub mod registrar; -#[cfg(feature = "inner_tun")] +#[cfg(feature = "integrated_tun")] pub mod tun_tap; const SELF_IP: Ipv4Addr = Ipv4Addr::new(0, 0, 0, 2); diff --git a/vnt/src/handle/recv_data/mod.rs b/vnt/src/handle/recv_data/mod.rs index 95e7f5d..41574b4 100644 --- a/vnt/src/handle/recv_data/mod.rs +++ b/vnt/src/handle/recv_data/mod.rs @@ -93,7 +93,7 @@ impl RecvDataHandler { #[cfg(feature = "ip_proxy")] ip_proxy_map: Option, counter: U64Adder, handshake: Handshake, - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] tun_device_helper: crate::tun_tap_device::tun_create_helper::TunDeviceHelper, ) -> Self { let server = ServerPacketHandler::new( @@ -108,7 +108,7 @@ impl RecvDataHandler { callback, external_route.clone(), handshake, - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] tun_device_helper, ); let client = ClientPacketHandler::new( diff --git a/vnt/src/handle/recv_data/server.rs b/vnt/src/handle/recv_data/server.rs index 0e253d2..234b951 100644 --- a/vnt/src/handle/recv_data/server.rs +++ b/vnt/src/handle/recv_data/server.rs @@ -52,7 +52,7 @@ pub struct ServerPacketHandler { up_key_time: Arc>, external_route: ExternalRoute, handshake: Handshake, - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] tun_device_helper: crate::tun_tap_device::tun_create_helper::TunDeviceHelper, } @@ -68,7 +68,7 @@ impl ServerPacketHandler { callback: Call, external_route: ExternalRoute, handshake: Handshake, - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] tun_device_helper: crate::tun_tap_device::tun_create_helper::TunDeviceHelper, ) -> Self { Self { @@ -85,7 +85,7 @@ impl ServerPacketHandler { up_key_time: Arc::new(AtomicCell::new(Instant::now() - Duration::from_secs(60))), external_route, handshake, - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] tun_device_helper, } } @@ -321,9 +321,9 @@ impl ServerPacketHandler { virtual_network, self.external_route.to_route(), ); - #[cfg(not(feature = "inner_tun"))] + #[cfg(not(feature = "integrated_tun"))] self.callback.create_device(context.sender(), device_config); - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] { self.tun_device_helper.stop(); #[cfg(any( diff --git a/vnt/src/tun_tap_device/mod.rs b/vnt/src/tun_tap_device/mod.rs index 2db7f75..9519ae4 100644 --- a/vnt/src/tun_tap_device/mod.rs +++ b/vnt/src/tun_tap_device/mod.rs @@ -1,11 +1,11 @@ #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))] -#[cfg(feature = "inner_tun")] +#[cfg(feature = "integrated_tun")] pub use create_device::create_device; #[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))] -#[cfg(feature = "inner_tun")] +#[cfg(feature = "integrated_tun")] mod create_device; -#[cfg(feature = "inner_tun")] +#[cfg(feature = "integrated_tun")] pub mod tun_create_helper; pub mod vnt_device; diff --git a/vnt/src/tun_tap_device/vnt_device.rs b/vnt/src/tun_tap_device/vnt_device.rs index 27e2549..9c3e8cc 100644 --- a/vnt/src/tun_tap_device/vnt_device.rs +++ b/vnt/src/tun_tap_device/vnt_device.rs @@ -2,6 +2,6 @@ use std::io; pub trait DeviceWrite: Clone + Send + Sync + 'static { fn write(&self, buf: &[u8]) -> io::Result; - #[cfg(feature = "inner_tun")] + #[cfg(feature = "integrated_tun")] fn into_device_adapter(self) -> crate::tun_tap_device::tun_create_helper::DeviceAdapter; }