mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
core: hide default STUN servers from cli (#1334)
This commit is contained in:
@@ -10,6 +10,7 @@ use cidr::IpCidr;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
common::stun::StunInfoCollector,
|
||||||
proto::{
|
proto::{
|
||||||
acl::Acl,
|
acl::Acl,
|
||||||
common::{CompressionAlgoPb, PortForwardConfigPb, SocketType},
|
common::{CompressionAlgoPb, PortForwardConfigPb, SocketType},
|
||||||
@@ -833,6 +834,12 @@ impl ConfigLoader for TomlConfigLoader {
|
|||||||
|
|
||||||
let mut config = self.config.lock().unwrap().clone();
|
let mut config = self.config.lock().unwrap().clone();
|
||||||
config.flags = Some(flag_map);
|
config.flags = Some(flag_map);
|
||||||
|
if config.stun_servers == Some(StunInfoCollector::get_default_servers()) {
|
||||||
|
config.stun_servers = None;
|
||||||
|
}
|
||||||
|
if config.stun_servers_v6 == Some(StunInfoCollector::get_default_servers_v6()) {
|
||||||
|
config.stun_servers_v6 = None;
|
||||||
|
}
|
||||||
toml::to_string_pretty(&config).unwrap()
|
toml::to_string_pretty(&config).unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1061,6 +1061,18 @@ fn win_service_event_loop(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_cli() -> Cli {
|
||||||
|
let mut cli = Cli::parse();
|
||||||
|
// for --stun-servers="", we want vec![], but clap will give vec![""], hack for that
|
||||||
|
if let Some(stun_servers) = &mut cli.network_options.stun_servers {
|
||||||
|
stun_servers.retain(|s| !s.trim().is_empty());
|
||||||
|
}
|
||||||
|
if let Some(stun_servers_v6) = &mut cli.network_options.stun_servers_v6 {
|
||||||
|
stun_servers_v6.retain(|s| !s.trim().is_empty());
|
||||||
|
}
|
||||||
|
cli
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
fn win_service_main(arg: Vec<std::ffi::OsString>) {
|
fn win_service_main(arg: Vec<std::ffi::OsString>) {
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@@ -1071,7 +1083,7 @@ fn win_service_main(arg: Vec<std::ffi::OsString>) {
|
|||||||
|
|
||||||
_ = win_service_set_work_dir(&arg[0]);
|
_ = win_service_set_work_dir(&arg[0]);
|
||||||
|
|
||||||
let cli = Cli::parse();
|
let cli = parse_cli();
|
||||||
|
|
||||||
let stop_notify_send = Arc::new(Notify::new());
|
let stop_notify_send = Arc::new(Notify::new());
|
||||||
let stop_notify_recv = Arc::clone(&stop_notify_send);
|
let stop_notify_recv = Arc::clone(&stop_notify_send);
|
||||||
@@ -1279,7 +1291,8 @@ async fn main() -> ExitCode {
|
|||||||
set_prof_active(true);
|
set_prof_active(true);
|
||||||
let _monitor = std::thread::spawn(memory_monitor);
|
let _monitor = std::thread::spawn(memory_monitor);
|
||||||
|
|
||||||
let cli = Cli::parse();
|
let cli = parse_cli();
|
||||||
|
|
||||||
if let Some(shell) = cli.gen_autocomplete {
|
if let Some(shell) = cli.gen_autocomplete {
|
||||||
let mut cmd = Cli::command();
|
let mut cmd = Cli::command();
|
||||||
easytier::print_completions(shell, &mut cmd, "easytier-core");
|
easytier::print_completions(shell, &mut cmd, "easytier-core");
|
||||||
|
|||||||
Reference in New Issue
Block a user