From b4edc62d54898e359ca13c5f57e63f159656bdea Mon Sep 17 00:00:00 2001 From: travis laduke Date: Thu, 23 Mar 2023 15:43:36 -0700 Subject: [PATCH 1/3] Create a command line option no-configure-network For #205 Makes it not configure the dns servers and domain on the zerotier network in my.zerotier.com --- src/cli.rs | 5 +++++ src/init.rs | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index e8ad500..0e81df5 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -80,6 +80,10 @@ pub struct StartArgs { /// Log Level to print [off, trace, debug, error, warn, info] #[clap(short = 'l', long = "log-level", value_name = "LEVEL")] pub log_level: Option, + + /// Configure the ZeroTier network with the configured dns servers and domain + #[clap(long = "no-configure-network")] + pub no_configure_network: bool, } impl Into for StartArgs { @@ -109,6 +113,7 @@ impl Into for StartArgs { log_level: self.log_level, network_id: Some(self.network_id), local_url: self.local_url, + no_configure_network: self.no_configure_network, } } } diff --git a/src/init.rs b/src/init.rs index 70fe5fa..6d8f54b 100644 --- a/src/init.rs +++ b/src/init.rs @@ -34,6 +34,7 @@ pub struct Launcher { pub local_url: String, #[serde(skip_deserializing)] pub network_id: Option, + pub no_configure_network: bool, } #[derive(Debug, Clone, Serialize, PartialEq)] @@ -72,6 +73,7 @@ impl Default for Launcher { network_id: None, log_level: None, local_url: ZEROTIER_LOCAL_URL.to_string(), + no_configure_network: false, } } } @@ -122,15 +124,17 @@ impl Launcher { // more or less the setup for the "main loop" if !ips.is_empty() { - update_central_dns( - domain_name.clone(), - ips.iter() - .map(|i| parse_ip_from_cidr(i.clone()).to_string()) - .collect(), - client.clone(), - self.network_id.clone().unwrap(), - ) - .await?; + if !self.no_configure_network { + update_central_dns( + domain_name.clone(), + ips.iter() + .map(|i| parse_ip_from_cidr(i.clone()).to_string()) + .collect(), + client.clone(), + self.network_id.clone().unwrap(), + ) + .await?; + } let mut listen_ips = Vec::new(); let mut ipmap = HashMap::new(); From 6f203e8eb2cac0068ee6afae38027c5cf53192d6 Mon Sep 17 00:00:00 2001 From: travis laduke Date: Fri, 24 Mar 2023 08:15:38 -0700 Subject: [PATCH 2/3] Update doc comment --- src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.rs b/src/cli.rs index 0e81df5..4204cda 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -81,7 +81,7 @@ pub struct StartArgs { #[clap(short = 'l', long = "log-level", value_name = "LEVEL")] pub log_level: Option, - /// Configure the ZeroTier network with the configured dns servers and domain + /// Don't configure the ZeroTier network's dns servers and domain. #[clap(long = "no-configure-network")] pub no_configure_network: bool, } From cb8c34d11d3b1f1b5ede7ab252f4d32f86c211df Mon Sep 17 00:00:00 2001 From: travis laduke Date: Fri, 24 Mar 2023 15:17:19 -0700 Subject: [PATCH 3/3] Make no-configure-network optional in config files --- src/cli.rs | 2 +- src/init.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cli.rs b/src/cli.rs index 4204cda..4988c65 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -81,7 +81,7 @@ pub struct StartArgs { #[clap(short = 'l', long = "log-level", value_name = "LEVEL")] pub log_level: Option, - /// Don't configure the ZeroTier network's dns servers and domain. + /// Don't configure the ZeroTier network's dns servers and domain. Default: False #[clap(long = "no-configure-network")] pub no_configure_network: bool, } diff --git a/src/init.rs b/src/init.rs index 6d8f54b..308fae3 100644 --- a/src/init.rs +++ b/src/init.rs @@ -34,6 +34,7 @@ pub struct Launcher { pub local_url: String, #[serde(skip_deserializing)] pub network_id: Option, + #[serde(default = "bool::default")] pub no_configure_network: bool, }