mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-12 20:57:26 +08:00
allow proxy packets to be forwarded by system kernel
This commit is contained in:
@@ -96,6 +96,9 @@ core_clap:
|
|||||||
enable_exit_node:
|
enable_exit_node:
|
||||||
en: "allow this node to be an exit node"
|
en: "allow this node to be an exit node"
|
||||||
zh-CN: "允许此节点成为出口节点"
|
zh-CN: "允许此节点成为出口节点"
|
||||||
|
proxy_forward_by_system:
|
||||||
|
en: "forward packet to proxy networks via system kernel, disable internal nat for network proxy"
|
||||||
|
zh-CN: "通过系统内核转发子网代理数据包,禁用内置NAT"
|
||||||
no_tun:
|
no_tun:
|
||||||
en: "do not create TUN device, can use subnet proxy to access node"
|
en: "do not create TUN device, can use subnet proxy to access node"
|
||||||
zh-CN: "不创建TUN设备,可以使用子网代理访问节点"
|
zh-CN: "不创建TUN设备,可以使用子网代理访问节点"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ pub fn gen_default_flags() -> Flags {
|
|||||||
mtu: 1380,
|
mtu: 1380,
|
||||||
latency_first: false,
|
latency_first: false,
|
||||||
enable_exit_node: false,
|
enable_exit_node: false,
|
||||||
|
proxy_forward_by_system: false,
|
||||||
no_tun: false,
|
no_tun: false,
|
||||||
use_smoltcp: false,
|
use_smoltcp: false,
|
||||||
relay_network_whitelist: "*".to_string(),
|
relay_network_whitelist: "*".to_string(),
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ pub struct GlobalCtx {
|
|||||||
running_listeners: Mutex<Vec<url::Url>>,
|
running_listeners: Mutex<Vec<url::Url>>,
|
||||||
|
|
||||||
enable_exit_node: bool,
|
enable_exit_node: bool,
|
||||||
|
proxy_forward_by_system: bool,
|
||||||
no_tun: bool,
|
no_tun: bool,
|
||||||
|
|
||||||
feature_flags: AtomicCell<PeerFeatureFlag>,
|
feature_flags: AtomicCell<PeerFeatureFlag>,
|
||||||
@@ -99,6 +100,7 @@ impl GlobalCtx {
|
|||||||
let stun_info_collection = Arc::new(StunInfoCollector::new_with_default_servers());
|
let stun_info_collection = Arc::new(StunInfoCollector::new_with_default_servers());
|
||||||
|
|
||||||
let enable_exit_node = config_fs.get_flags().enable_exit_node;
|
let enable_exit_node = config_fs.get_flags().enable_exit_node;
|
||||||
|
let proxy_forward_by_system = config_fs.get_flags().proxy_forward_by_system;
|
||||||
let no_tun = config_fs.get_flags().no_tun;
|
let no_tun = config_fs.get_flags().no_tun;
|
||||||
|
|
||||||
let mut feature_flags = PeerFeatureFlag::default();
|
let mut feature_flags = PeerFeatureFlag::default();
|
||||||
@@ -125,6 +127,7 @@ impl GlobalCtx {
|
|||||||
running_listeners: Mutex::new(Vec::new()),
|
running_listeners: Mutex::new(Vec::new()),
|
||||||
|
|
||||||
enable_exit_node,
|
enable_exit_node,
|
||||||
|
proxy_forward_by_system,
|
||||||
no_tun,
|
no_tun,
|
||||||
|
|
||||||
feature_flags: AtomicCell::new(feature_flags),
|
feature_flags: AtomicCell::new(feature_flags),
|
||||||
@@ -273,6 +276,10 @@ impl GlobalCtx {
|
|||||||
self.enable_exit_node
|
self.enable_exit_node
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn proxy_forward_by_system(&self) -> bool {
|
||||||
|
self.proxy_forward_by_system
|
||||||
|
}
|
||||||
|
|
||||||
pub fn no_tun(&self) -> bool {
|
pub fn no_tun(&self) -> bool {
|
||||||
self.no_tun
|
self.no_tun
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,6 +242,13 @@ struct Cli {
|
|||||||
)]
|
)]
|
||||||
enable_exit_node: bool,
|
enable_exit_node: bool,
|
||||||
|
|
||||||
|
#[arg(
|
||||||
|
long,
|
||||||
|
help = t!("core_clap.proxy_forward_by_system").to_string(),
|
||||||
|
default_value = "false"
|
||||||
|
)]
|
||||||
|
proxy_forward_by_system: bool,
|
||||||
|
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
help = t!("core_clap.no_tun").to_string(),
|
help = t!("core_clap.no_tun").to_string(),
|
||||||
@@ -560,6 +567,7 @@ impl TryFrom<&Cli> for TomlConfigLoader {
|
|||||||
f.mtu = mtu as u32;
|
f.mtu = mtu as u32;
|
||||||
}
|
}
|
||||||
f.enable_exit_node = cli.enable_exit_node;
|
f.enable_exit_node = cli.enable_exit_node;
|
||||||
|
f.proxy_forward_by_system = cli.proxy_forward_by_system;
|
||||||
f.no_tun = cli.no_tun || cfg!(not(feature = "tun"));
|
f.no_tun = cli.no_tun || cfg!(not(feature = "tun"));
|
||||||
f.use_smoltcp = cli.use_smoltcp;
|
f.use_smoltcp = cli.use_smoltcp;
|
||||||
if let Some(wl) = cli.relay_network_whitelist.as_ref() {
|
if let Some(wl) = cli.relay_network_whitelist.as_ref() {
|
||||||
|
|||||||
@@ -65,7 +65,9 @@ impl IpProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn start(&self) -> Result<(), Error> {
|
async fn start(&self) -> Result<(), Error> {
|
||||||
if (self.global_ctx.get_proxy_cidrs().is_empty() || self.started.load(Ordering::Relaxed))
|
if (self.global_ctx.get_proxy_cidrs().is_empty()
|
||||||
|
|| self.global_ctx.proxy_forward_by_system()
|
||||||
|
|| self.started.load(Ordering::Relaxed))
|
||||||
&& !self.global_ctx.enable_exit_node()
|
&& !self.global_ctx.enable_exit_node()
|
||||||
&& !self.global_ctx.no_tun()
|
&& !self.global_ctx.no_tun()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ message FlagsInConfig {
|
|||||||
bool disable_kcp_input = 19;
|
bool disable_kcp_input = 19;
|
||||||
// allow relay kcp packets (for public server, this can reduce the throughput)
|
// allow relay kcp packets (for public server, this can reduce the throughput)
|
||||||
bool disable_relay_kcp = 20;
|
bool disable_relay_kcp = 20;
|
||||||
|
bool proxy_forward_by_system = 21;
|
||||||
}
|
}
|
||||||
|
|
||||||
message RpcDescriptor {
|
message RpcDescriptor {
|
||||||
|
|||||||
Reference in New Issue
Block a user