From aafac271f5f8ed449c964f08b6afce775d22bef2 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 16 Sep 2022 17:02:21 -0400 Subject: [PATCH] Says hello to a root again! --- PROTOCOL.md => attic/PROTOCOL.md | 0 .../default-rootset/make-root-set.sh | 4 ++-- .../default-rootset/test-root.bin | Bin 205 -> 224 bytes .../default-rootset/test-root.json | 4 ++-- network-hypervisor/src/vl1/node.rs | 9 +++++++++ network-hypervisor/src/vl1/rootset.rs | 8 +++----- service/src/cmdline_help.rs | 6 +++--- service/src/localconfig.rs | 2 +- service/src/main.rs | 2 ++ vl1-service/src/vl1service.rs | 8 +++++++- 10 files changed, 29 insertions(+), 14 deletions(-) rename PROTOCOL.md => attic/PROTOCOL.md (100%) diff --git a/PROTOCOL.md b/attic/PROTOCOL.md similarity index 100% rename from PROTOCOL.md rename to attic/PROTOCOL.md diff --git a/network-hypervisor/default-rootset/make-root-set.sh b/network-hypervisor/default-rootset/make-root-set.sh index 723a45b94..6786a7ff5 100755 --- a/network-hypervisor/default-rootset/make-root-set.sh +++ b/network-hypervisor/default-rootset/make-root-set.sh @@ -6,9 +6,9 @@ for i in $*; do echo $i - ../../zerotier-system-service/target/debug/zerotier-system-service rootset sign root.zerotier.com.json $i >tmp.json + ../../target/debug/zerotier rootset sign root.zerotier.com.json $i >tmp.json mv -f tmp.json root.zerotier.com.json - ../../zerotier-system-service/target/debug/zerotier-system-service rootset marshal root.zerotier.com.json >root.zerotier.com.bin + ../../target/debug/zerotier rootset marshal root.zerotier.com.json >root.zerotier.com.bin done cat root.zerotier.com.json diff --git a/network-hypervisor/default-rootset/test-root.bin b/network-hypervisor/default-rootset/test-root.bin index c8dee3a206cba27a4d807ff3d7794adf63baa2ad..a1019cf2114a9241d9014fa93a19917cd4306e1c 100644 GIT binary patch delta 105 zcmV-v0G9vF0pJ0Ueqw?In~IyeCkh520U7YH0ttOo00jU3Ba2Tb3c&$!gVvG#H7dUl zZDfG!nt!}(c$1d}A#|dmBi2~*J-7}rA(_&Qul#J>0eKWyI4Z;wpU64eXXPrDsweLV LAfE|<004l17=SFf delta 86 zcmV-c0IC1r0nGuBeouh}&y)!;P8q=g^=<9eKVYfEddQAI@aEKQRES7re@pW?1dMfq sxL%x@AqYkcY-{ke9tR+yRS%c Node { self.roots.read().sets.iter().any(|rs| !rs.1.members.is_empty()) } + /// Initialize with default roots if there are no roots defined, otherwise do nothing. + pub fn init_default_roots(&self) -> bool { + if !self.has_roots_defined() { + self.add_update_root_set(RootSet::zerotier_default()) + } else { + false + } + } + /// Get the root sets that this node trusts. pub fn root_sets(&self) -> Vec { self.roots.read().sets.values().cloned().collect() diff --git a/network-hypervisor/src/vl1/rootset.rs b/network-hypervisor/src/vl1/rootset.rs index 4cc975179..36c7ac130 100644 --- a/network-hypervisor/src/vl1/rootset.rs +++ b/network-hypervisor/src/vl1/rootset.rs @@ -90,11 +90,9 @@ impl RootSet { /// Get the ZeroTier default root set, which contains roots run by ZeroTier Inc. pub fn zerotier_default() -> Self { let mut cursor = 0; - let rs = Self::unmarshal( - &Buffer::from(include_bytes!("../../default-rootset/root.zerotier.com.bin")), - &mut cursor, - ) - .unwrap(); + //let rs = include_bytes!("../../default-rootset/root.zerotier.com.bin"); + let rs = include_bytes!("../../default-rootset/test-root.bin"); + let rs = Self::unmarshal(&Buffer::from(rs), &mut cursor).unwrap(); assert!(rs.verify()); rs } diff --git a/service/src/cmdline_help.rs b/service/src/cmdline_help.rs index 0ad7d022a..464756bed 100644 --- a/service/src/cmdline_help.rs +++ b/service/src/cmdline_help.rs @@ -73,9 +73,9 @@ Advanced Operations: service Start local service (usually not invoked manually) - · Command requires a running node to control. - @ Argument is the path to a file containing the object. - ? Argument can be either the object or a path to it (auto-detected). +· Command requires a running node to control. +@ Argument is the path to a file containing the object. +? Argument can be either the object or a path to it (auto-detected). "###, VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, diff --git a/service/src/localconfig.rs b/service/src/localconfig.rs index a406afa64..90553a24c 100644 --- a/service/src/localconfig.rs +++ b/service/src/localconfig.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; -use zerotier_network_hypervisor::vl1::{Address, Endpoint, InetAddress}; +use zerotier_network_hypervisor::vl1::{Address, Endpoint}; use zerotier_network_hypervisor::vl2::NetworkId; use zerotier_vl1_service::Settings; diff --git a/service/src/main.rs b/service/src/main.rs index f4928ada5..5bd037c60 100644 --- a/service/src/main.rs +++ b/service/src/main.rs @@ -80,6 +80,8 @@ async fn async_main(flags: Flags, global_args: Box) -> i32 { let datadir = open_datadir(&flags).await; let svc = VL1Service::new(datadir, test_inner, test_path_filter, zerotier_vl1_service::Settings::default()).await; if svc.is_ok() { + let svc = svc.unwrap(); + svc.node().init_default_roots(); let _ = tokio::signal::ctrl_c().await; println!("Terminate signal received, shutting down..."); exitcode::OK diff --git a/vl1-service/src/vl1service.rs b/vl1-service/src/vl1service.rs index 17ca7d35e..d689086b8 100644 --- a/vl1-service/src/vl1service.rs +++ b/vl1-service/src/vl1service.rs @@ -135,7 +135,10 @@ impl) { + tokio::time::sleep(Duration::from_secs(1)).await; loop { tokio::time::sleep(self.node().do_background_tasks(self.as_ref()).await).await; } @@ -238,7 +242,9 @@ impl