支持--no-default-features编译
This commit is contained in:
@@ -84,6 +84,7 @@ features说明
|
|||||||
| sm4_cbc | 支持sm4_cbc加密 | 是 |
|
| sm4_cbc | 支持sm4_cbc加密 | 是 |
|
||||||
| server_encrypt | 支持服务端加密 | 是 |
|
| server_encrypt | 支持服务端加密 | 是 |
|
||||||
| ip_proxy | 内置ip代理 | 是 |
|
| ip_proxy | 内置ip代理 | 是 |
|
||||||
|
| port_mapping | 端口映射 | 是 |
|
||||||
|
|
||||||
### ip转发/代理
|
### ip转发/代理
|
||||||
如果编译时去除了内置的ip代理(或使用--no-proxy关闭了代理),则可以使用网卡NAT转发来实现点对网,
|
如果编译时去除了内置的ip代理(或使用--no-proxy关闭了代理),则可以使用网卡NAT转发来实现点对网,
|
||||||
|
|||||||
@@ -185,7 +185,10 @@ pub fn command_info(vnt: &Vnt) -> Info {
|
|||||||
.unwrap_or("None".to_string());
|
.unwrap_or("None".to_string());
|
||||||
let up = vnt.up_stream();
|
let up = vnt.up_stream();
|
||||||
let down = vnt.down_stream();
|
let down = vnt.down_stream();
|
||||||
|
#[cfg(feature = "port_mapping")]
|
||||||
let port_mapping_list = vnt.config().port_mapping_list.clone();
|
let port_mapping_list = vnt.config().port_mapping_list.clone();
|
||||||
|
#[cfg(not(feature = "port_mapping"))]
|
||||||
|
let port_mapping_list = vec![];
|
||||||
let in_ips = vnt.config().in_ips.clone();
|
let in_ips = vnt.config().in_ips.clone();
|
||||||
let out_ips = vnt.config().out_ips.clone();
|
let out_ips = vnt.config().out_ips.clone();
|
||||||
Info {
|
Info {
|
||||||
|
|||||||
@@ -52,9 +52,13 @@ pub enum CipherModel {
|
|||||||
impl Display for CipherModel {
|
impl Display for CipherModel {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
let str = match self {
|
let str = match self {
|
||||||
|
#[cfg(any(feature = "aes_gcm", feature = "server_encrypt"))]
|
||||||
CipherModel::AesGcm => "aes_gcm".to_string(),
|
CipherModel::AesGcm => "aes_gcm".to_string(),
|
||||||
|
#[cfg(feature = "aes_cbc")]
|
||||||
CipherModel::AesCbc => "aes_cbc".to_string(),
|
CipherModel::AesCbc => "aes_cbc".to_string(),
|
||||||
|
#[cfg(feature = "aes_ecb")]
|
||||||
CipherModel::AesEcb => "aes_ecb".to_string(),
|
CipherModel::AesEcb => "aes_ecb".to_string(),
|
||||||
|
#[cfg(feature = "sm4_cbc")]
|
||||||
CipherModel::Sm4Cbc => "sm4_cbc".to_string(),
|
CipherModel::Sm4Cbc => "sm4_cbc".to_string(),
|
||||||
CipherModel::None => "none".to_string(),
|
CipherModel::None => "none".to_string(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use std::time::Duration;
|
|||||||
use crossbeam_utils::atomic::AtomicCell;
|
use crossbeam_utils::atomic::AtomicCell;
|
||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use rsa::signature::digest::Digest;
|
use sha2::Digest;
|
||||||
#[cfg(not(target_os = "android"))]
|
#[cfg(not(target_os = "android"))]
|
||||||
use tun::device::IFace;
|
use tun::device::IFace;
|
||||||
|
|
||||||
@@ -167,7 +167,10 @@ impl Vnt {
|
|||||||
let down_counter =
|
let down_counter =
|
||||||
U64Adder::with_capacity(config.ports.as_ref().map(|v| v.len()).unwrap_or_default() + 8);
|
U64Adder::with_capacity(config.ports.as_ref().map(|v| v.len()).unwrap_or_default() + 8);
|
||||||
let down_count_watcher = down_counter.watch();
|
let down_count_watcher = down_counter.watch();
|
||||||
let handshake = Handshake::new(rsa_cipher.clone());
|
let handshake = Handshake::new(
|
||||||
|
#[cfg(feature = "server_encrypt")]
|
||||||
|
rsa_cipher.clone(),
|
||||||
|
);
|
||||||
let up_counter = SingleU64Adder::new();
|
let up_counter = SingleU64Adder::new();
|
||||||
let up_count_watcher = up_counter.watch();
|
let up_count_watcher = up_counter.watch();
|
||||||
let tun_helper = TunDeviceHelper::new(
|
let tun_helper = TunDeviceHelper::new(
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use std::sync::Arc;
|
|||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use crossbeam_utils::atomic::AtomicCell;
|
use crossbeam_utils::atomic::AtomicCell;
|
||||||
|
#[cfg(feature = "server_encrypt")]
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use protobuf::Message;
|
use protobuf::Message;
|
||||||
|
|
||||||
@@ -28,12 +29,16 @@ pub enum HandshakeEnum {
|
|||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Handshake {
|
pub struct Handshake {
|
||||||
time: Arc<AtomicCell<Instant>>,
|
time: Arc<AtomicCell<Instant>>,
|
||||||
|
#[cfg(feature = "server_encrypt")]
|
||||||
rsa_cipher: Arc<Mutex<Option<RsaCipher>>>,
|
rsa_cipher: Arc<Mutex<Option<RsaCipher>>>,
|
||||||
}
|
}
|
||||||
impl Handshake {
|
impl Handshake {
|
||||||
pub fn new(rsa_cipher: Arc<Mutex<Option<RsaCipher>>>) -> Self {
|
pub fn new(
|
||||||
|
#[cfg(feature = "server_encrypt")] rsa_cipher: Arc<Mutex<Option<RsaCipher>>>,
|
||||||
|
) -> Self {
|
||||||
Handshake {
|
Handshake {
|
||||||
time: Arc::new(AtomicCell::new(Instant::now() - Duration::from_secs(60))),
|
time: Arc::new(AtomicCell::new(Instant::now() - Duration::from_secs(60))),
|
||||||
|
#[cfg(feature = "server_encrypt")]
|
||||||
rsa_cipher,
|
rsa_cipher,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,6 +59,7 @@ impl Handshake {
|
|||||||
let mut request = HandshakeRequest::new();
|
let mut request = HandshakeRequest::new();
|
||||||
request.secret = secret;
|
request.secret = secret;
|
||||||
request.version = crate::VNT_VERSION.to_string();
|
request.version = crate::VNT_VERSION.to_string();
|
||||||
|
#[cfg(feature = "server_encrypt")]
|
||||||
if let Some(finger) = self.rsa_cipher.lock().as_ref().map(|v| v.finger().clone()) {
|
if let Some(finger) = self.rsa_cipher.lock().as_ref().map(|v| v.finger().clone()) {
|
||||||
request.key_finger = finger;
|
request.key_finger = finger;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ impl<Call: VntCallback> PacketHandler for ServerPacketHandler<Call> {
|
|||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "server_encrypt")]
|
||||||
if let Ok(rsa_cipher) = RsaCipher::new(&response.public_key) {
|
if let Ok(rsa_cipher) = RsaCipher::new(&response.public_key) {
|
||||||
self.rsa_cipher.lock().replace(rsa_cipher);
|
self.rsa_cipher.lock().replace(rsa_cipher);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use crate::handle::tun_tap::channel_group::channel_group;
|
|||||||
use crate::handle::{check_dest, CurrentDeviceInfo, PeerDeviceInfo};
|
use crate::handle::{check_dest, CurrentDeviceInfo, PeerDeviceInfo};
|
||||||
#[cfg(feature = "ip_proxy")]
|
#[cfg(feature = "ip_proxy")]
|
||||||
use crate::ip_proxy::IpProxyMap;
|
use crate::ip_proxy::IpProxyMap;
|
||||||
|
#[cfg(feature = "ip_proxy")]
|
||||||
use crate::ip_proxy::ProxyHandler;
|
use crate::ip_proxy::ProxyHandler;
|
||||||
use crate::protocol;
|
use crate::protocol;
|
||||||
use crate::protocol::body::ENCRYPTION_RESERVED;
|
use crate::protocol::body::ENCRYPTION_RESERVED;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use crate::cipher::Cipher;
|
|||||||
use crate::external_route::ExternalRoute;
|
use crate::external_route::ExternalRoute;
|
||||||
use crate::handle::tun_tap::channel_group::GroupSyncSender;
|
use crate::handle::tun_tap::channel_group::GroupSyncSender;
|
||||||
use crate::handle::{CurrentDeviceInfo, PeerDeviceInfo};
|
use crate::handle::{CurrentDeviceInfo, PeerDeviceInfo};
|
||||||
|
#[cfg(feature = "ip_proxy")]
|
||||||
use crate::ip_proxy::IpProxyMap;
|
use crate::ip_proxy::IpProxyMap;
|
||||||
use crate::util::{SingleU64Adder, StopManager};
|
use crate::util::{SingleU64Adder, StopManager};
|
||||||
use crossbeam_utils::atomic::AtomicCell;
|
use crossbeam_utils::atomic::AtomicCell;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use crate::channel::context::ChannelContext;
|
|||||||
use crate::cipher::Cipher;
|
use crate::cipher::Cipher;
|
||||||
use crate::external_route::ExternalRoute;
|
use crate::external_route::ExternalRoute;
|
||||||
use crate::handle::{CurrentDeviceInfo, PeerDeviceInfo};
|
use crate::handle::{CurrentDeviceInfo, PeerDeviceInfo};
|
||||||
|
#[cfg(feature = "ip_proxy")]
|
||||||
use crate::ip_proxy::IpProxyMap;
|
use crate::ip_proxy::IpProxyMap;
|
||||||
use crate::util::{SingleU64Adder, StopManager};
|
use crate::util::{SingleU64Adder, StopManager};
|
||||||
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
#[cfg(any(target_os = "windows", target_os = "linux", target_os = "macos"))]
|
||||||
@@ -98,6 +99,7 @@ impl TunDeviceHelper {
|
|||||||
context,
|
context,
|
||||||
current_device,
|
current_device,
|
||||||
ip_route,
|
ip_route,
|
||||||
|
#[cfg(feature = "ip_proxy")]
|
||||||
ip_proxy_map,
|
ip_proxy_map,
|
||||||
client_cipher,
|
client_cipher,
|
||||||
server_cipher,
|
server_cipher,
|
||||||
|
|||||||
Reference in New Issue
Block a user