mirror of
https://mirror.suhoan.cn/https://github.com/EasyTier/EasyTier.git
synced 2025-12-15 22:27:26 +08:00
tune command line args
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use std::borrow::BorrowMut;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::pin::Pin;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, Weak};
|
||||
|
||||
use anyhow::Context;
|
||||
@@ -44,6 +45,8 @@ struct IpProxy {
|
||||
tcp_proxy: Arc<TcpProxy>,
|
||||
icmp_proxy: Arc<IcmpProxy>,
|
||||
udp_proxy: Arc<UdpProxy>,
|
||||
global_ctx: ArcGlobalCtx,
|
||||
started: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
impl IpProxy {
|
||||
@@ -57,10 +60,17 @@ impl IpProxy {
|
||||
tcp_proxy,
|
||||
icmp_proxy,
|
||||
udp_proxy,
|
||||
global_ctx,
|
||||
started: Arc::new(AtomicBool::new(false)),
|
||||
})
|
||||
}
|
||||
|
||||
async fn start(&self) -> Result<(), Error> {
|
||||
if self.global_ctx.get_proxy_cidrs().is_empty() || self.started.load(Ordering::Relaxed) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
self.started.store(true, Ordering::Relaxed);
|
||||
self.tcp_proxy.start().await?;
|
||||
self.icmp_proxy.start().await?;
|
||||
self.udp_proxy.start().await?;
|
||||
@@ -297,7 +307,7 @@ impl Instance {
|
||||
self.get_global_ctx(),
|
||||
self.get_peer_manager(),
|
||||
)?);
|
||||
self.ip_proxy.as_ref().unwrap().start().await?;
|
||||
self.run_ip_proxy().await?;
|
||||
|
||||
self.udp_hole_puncher.lock().await.run().await?;
|
||||
|
||||
@@ -317,6 +327,14 @@ impl Instance {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn run_ip_proxy(&mut self) -> Result<(), Error> {
|
||||
if self.ip_proxy.is_none() {
|
||||
return Err(anyhow::anyhow!("ip proxy not enabled.").into());
|
||||
}
|
||||
self.ip_proxy.as_ref().unwrap().start().await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn run_vpn_portal(&mut self) -> Result<(), Error> {
|
||||
if self.global_ctx.get_vpn_portal_cidr().is_none() {
|
||||
return Err(anyhow::anyhow!("vpn portal cidr not set.").into());
|
||||
|
||||
Reference in New Issue
Block a user