Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a command line option no-configure-network #213

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<crate::log::LevelFilter>,

/// Don't configure the ZeroTier network's dns servers and domain. Default: False
#[clap(long = "no-configure-network")]
pub no_configure_network: bool,
}

impl Into<Launcher> for StartArgs {
Expand Down Expand Up @@ -109,6 +113,7 @@ impl Into<Launcher> 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,
}
}
}
Expand Down
23 changes: 14 additions & 9 deletions src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub struct Launcher {
pub local_url: String,
#[serde(skip_deserializing)]
pub network_id: Option<String>,
#[serde(default = "bool::default")]
pub no_configure_network: bool,
}

#[derive(Debug, Clone, Serialize, PartialEq)]
Expand Down Expand Up @@ -72,6 +74,7 @@ impl Default for Launcher {
network_id: None,
log_level: None,
local_url: ZEROTIER_LOCAL_URL.to_string(),
no_configure_network: false,
}
}
}
Expand Down Expand Up @@ -122,15 +125,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();
Expand Down