mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-05-07 10:14:35 +00:00
refactor: update custom STUN server settings (#1310)
* refactor: update global context STUN server initialization Modified global context initialization to use a single StunInfoCollector instance with properly configured IPv4 and IPv6 servers instead of creating separate instances. feat: add IPv6 STUN server configuration support Added interface methods and config struct fields to support both IPv4 and IPv6 STUN server configuration. Modified getter and setter methods to handle Option<Vec<String>> type for both server types. feat: enhance StunInfoCollector with IPv6 support Updated StunInfoCollector to support both IPv4 and IPv6 STUN servers. Added new constructor that accepts both server types and methods to set them independently. feat: add CLI argument for IPv6 STUN servers Added command line argument support for configuring IPv6 STUN servers. Updated configuration setup to handle both IPv4 and IPv6 STUN server settings. docs: add localization for STUN server configuration Added English and Chinese localization strings for the new STUN server configuration options, including both IPv4 and IPv6 variants.
This commit is contained in:
@@ -25,7 +25,7 @@ use easytier::{
|
||||
constants::EASYTIER_VERSION,
|
||||
global_ctx::GlobalCtx,
|
||||
set_default_machine_id,
|
||||
stun::MockStunInfoCollector,
|
||||
stun::{MockStunInfoCollector, StunInfoCollector},
|
||||
},
|
||||
connector::create_connector_by_url,
|
||||
instance_manager::NetworkInstanceManager,
|
||||
@@ -572,6 +572,15 @@ struct NetworkOptions {
|
||||
num_args = 0..
|
||||
)]
|
||||
stun_servers: Option<Vec<String>>,
|
||||
|
||||
#[arg(
|
||||
long,
|
||||
env = "ET_STUN_SERVERS_V6",
|
||||
value_delimiter = ',',
|
||||
help = t!("core_clap.stun_servers_v6").to_string(),
|
||||
num_args = 0..
|
||||
)]
|
||||
stun_servers_v6: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
@@ -943,7 +952,23 @@ impl NetworkOptions {
|
||||
cfg.set_udp_whitelist(old_udp_whitelist);
|
||||
|
||||
if let Some(stun_servers) = &self.stun_servers {
|
||||
cfg.set_stun_servers(stun_servers.clone());
|
||||
if stun_servers.is_empty() {
|
||||
cfg.set_stun_servers(None);
|
||||
} else {
|
||||
cfg.set_stun_servers(Some(stun_servers.clone()));
|
||||
}
|
||||
} else {
|
||||
cfg.set_stun_servers(Some(StunInfoCollector::get_default_servers()));
|
||||
}
|
||||
|
||||
if let Some(stun_servers) = &self.stun_servers_v6 {
|
||||
if stun_servers.is_empty() {
|
||||
cfg.set_stun_servers_v6(None);
|
||||
} else {
|
||||
cfg.set_stun_servers_v6(Some(stun_servers.clone()));
|
||||
}
|
||||
} else {
|
||||
cfg.set_stun_servers_v6(Some(StunInfoCollector::get_default_servers_v6()));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user