Skip to content

Commit

Permalink
Merge pull request #214 from zerotier/tl-cargo-fmt
Browse files Browse the repository at this point in the history
cargo fmt
  • Loading branch information
laduke committed Mar 23, 2023
2 parents c063819 + 2bec140 commit b03712b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 28 deletions.
5 changes: 4 additions & 1 deletion src/supervise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ impl Properties {
fn service_name(&self) -> String {
format!(
"com.zerotier.nsd.{}.plist",
self.launcher.network_id.as_ref().expect("network_id missing")
self.launcher
.network_id
.as_ref()
.expect("network_id missing")
)
}

Expand Down
56 changes: 34 additions & 22 deletions tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use zeronsd::utils::{ init_logger };

use zeronsd::utils::init_logger;

mod service;

Expand Down Expand Up @@ -685,8 +684,12 @@ mod all {
.await
.unwrap();

let listen_ips =
get_listen_ips(&authtoken_path(None), &tn.network.clone().id.unwrap(), ZEROTIER_LOCAL_URL.into()).await?;
let listen_ips = get_listen_ips(
&authtoken_path(None),
&tn.network.clone().id.unwrap(),
ZEROTIER_LOCAL_URL.into(),
)
.await?;

eprintln!("My listen IP is {}", listen_ips.first().unwrap());
assert_ne!(*listen_ips.first().unwrap(), String::from(""));
Expand All @@ -701,12 +704,15 @@ mod all {
.unwrap();
ips.sort();

let mut listen_ips: Vec<String> =
get_listen_ips(&authtoken_path(None), &tn.network.clone().id.unwrap(), ZEROTIER_LOCAL_URL.into())
.await?
.iter()
.map(|x| parse_ip_from_cidr(x.clone()).to_string())
.collect();
let mut listen_ips: Vec<String> = get_listen_ips(
&authtoken_path(None),
&tn.network.clone().id.unwrap(),
ZEROTIER_LOCAL_URL.into(),
)
.await?
.iter()
.map(|x| parse_ip_from_cidr(x.clone()).to_string())
.collect();
listen_ips.sort();

assert_eq!(listen_ips, ips);
Expand All @@ -716,12 +722,15 @@ mod all {
.await
.unwrap();

let mut listen_ips: Vec<String> =
get_listen_ips(&authtoken_path(None), &tn.network.clone().id.unwrap(), ZEROTIER_LOCAL_URL.into())
.await?
.iter()
.map(|x| parse_ip_from_cidr(x.clone()).to_string())
.collect();
let mut listen_ips: Vec<String> = get_listen_ips(
&authtoken_path(None),
&tn.network.clone().id.unwrap(),
ZEROTIER_LOCAL_URL.into(),
)
.await?
.iter()
.map(|x| parse_ip_from_cidr(x.clone()).to_string())
.collect();
listen_ips.sort();

let mut ips = vec![tn.member().clone().rfc4193()?.ip().to_string()];
Expand All @@ -736,12 +745,15 @@ mod all {
.await
.unwrap();

let mut listen_ips: Vec<String> =
get_listen_ips(&authtoken_path(None), &tn.network.clone().id.unwrap(), ZEROTIER_LOCAL_URL.into())
.await?
.iter()
.map(|x| parse_ip_from_cidr(x.clone()).to_string())
.collect();
let mut listen_ips: Vec<String> = get_listen_ips(
&authtoken_path(None),
&tn.network.clone().id.unwrap(),
ZEROTIER_LOCAL_URL.into(),
)
.await?
.iter()
.map(|x| parse_ip_from_cidr(x.clone()).to_string())
.collect();
listen_ips.sort();

let mut ips = vec![tn.member().clone().sixplane()?.ip().to_string()];
Expand Down
14 changes: 10 additions & 4 deletions tests/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ use zeronsd::{
authority::{find_members, RecordAuthority, ZTAuthority},
server::Server,
traits::{ToHostname, ToPointerSOA},
utils::{authtoken_path, domain_or_default, get_listen_ips, parse_ip_from_cidr, ZEROTIER_LOCAL_URL},
utils::{
authtoken_path, domain_or_default, get_listen_ips, parse_ip_from_cidr, ZEROTIER_LOCAL_URL,
},
};

use self::{
Expand Down Expand Up @@ -163,9 +165,13 @@ impl Service {
update_interval: Duration,
wildcard_everything: bool,
) -> Vec<SocketAddr> {
let listen_cidrs = get_listen_ips(&authtoken_path(None), &tn.network.clone().id.unwrap(), ZEROTIER_LOCAL_URL.into())
.await
.unwrap();
let listen_cidrs = get_listen_ips(
&authtoken_path(None),
&tn.network.clone().id.unwrap(),
ZEROTIER_LOCAL_URL.into(),
)
.await
.unwrap();

let mut listen_ips = Vec::new();

Expand Down
4 changes: 3 additions & 1 deletion tests/service/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ impl TestNetwork {
let id = self.network.id.clone().unwrap();
let mut count = 0;

while let Err(e) = get_listen_ips(&authtoken_path(None), &id, ZEROTIER_LOCAL_URL.into()).await {
while let Err(e) =
get_listen_ips(&authtoken_path(None), &id, ZEROTIER_LOCAL_URL.into()).await
{
tokio::time::sleep(Duration::new(1, 0)).await;
count += 1;
if count >= 5 {
Expand Down

0 comments on commit b03712b

Please sign in to comment.