修改feature名称
This commit is contained in:
+1
-1
@@ -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"]
|
||||
|
||||
+2
-2
@@ -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"]
|
||||
|
||||
@@ -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<Call: VntCallback>(config: Config, callback: Call) -> anyhow::Result<Self> {
|
||||
Vnt::new_device0(config, callback, DeviceAdapter::default())
|
||||
}
|
||||
#[cfg(not(feature = "inner_tun"))]
|
||||
#[cfg(not(feature = "integrated_tun"))]
|
||||
pub fn new_device<Call: VntCallback, Device: DeviceWrite>(
|
||||
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,
|
||||
);
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -93,7 +93,7 @@ impl<Call: VntCallback, Device: DeviceWrite> RecvDataHandler<Call, Device> {
|
||||
#[cfg(feature = "ip_proxy")] ip_proxy_map: Option<IpProxyMap>,
|
||||
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<Call: VntCallback, Device: DeviceWrite> RecvDataHandler<Call, Device> {
|
||||
callback,
|
||||
external_route.clone(),
|
||||
handshake,
|
||||
#[cfg(feature = "inner_tun")]
|
||||
#[cfg(feature = "integrated_tun")]
|
||||
tun_device_helper,
|
||||
);
|
||||
let client = ClientPacketHandler::new(
|
||||
|
||||
@@ -52,7 +52,7 @@ pub struct ServerPacketHandler<Call, Device> {
|
||||
up_key_time: Arc<AtomicCell<Instant>>,
|
||||
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<Call, Device> ServerPacketHandler<Call, Device> {
|
||||
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<Call, Device> ServerPacketHandler<Call, Device> {
|
||||
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<Call: VntCallback, Device: DeviceWrite> ServerPacketHandler<Call, Device> {
|
||||
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(
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2,6 +2,6 @@ use std::io;
|
||||
|
||||
pub trait DeviceWrite: Clone + Send + Sync + 'static {
|
||||
fn write(&self, buf: &[u8]) -> io::Result<usize>;
|
||||
#[cfg(feature = "inner_tun")]
|
||||
#[cfg(feature = "integrated_tun")]
|
||||
fn into_device_adapter(self) -> crate::tun_tap_device::tun_create_helper::DeviceAdapter;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user