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 c8dee3a20..a1019cf21 100644 Binary files a/network-hypervisor/default-rootset/test-root.bin and b/network-hypervisor/default-rootset/test-root.bin differ diff --git a/network-hypervisor/default-rootset/test-root.json b/network-hypervisor/default-rootset/test-root.json index 24e887994..e24e47251 100644 --- a/network-hypervisor/default-rootset/test-root.json +++ b/network-hypervisor/default-rootset/test-root.json @@ -4,8 +4,8 @@ "revision": 1, "members": [ { "identity": "bc47f54ab2:0:cfb92160bab1da37f31247ded76d8327c00c4d3e49d8a424c6ba16fe3e77b949ab782426584b0169e7b38f7679ea24f38cea637a7a93a9272bfcb0ff461c1e97", - "endpoints": [ "udp:207.148.9.48/19993" ], - "signature": [ 1, 245, 109, 237, 214, 63, 96, 169, 196, 122, 200, 142, 64, 240, 230, 212, 109, 84, 136, 72, 101, 127, 75, 243, 56, 4, 140, 117, 131, 184, 94, 156, 153, 33, 8, 70, 12, 108, 107, 240, 180, 30, 7, 32, 161, 85, 15, 151, 247, 91, 197, 68, 30, 157, 229, 245, 162, 120, 123, 2, 191, 104, 255, 212, 6 ], + "endpoints": [ "udp:155.138.155.187/9994", "udp:2001:19f0:b002:97d:5400:4ff:fe23:8b4f/9994" ], + "signature": [ 1, 113, 131, 214, 145, 253, 53, 42, 191, 16, 109, 100, 128, 235, 154, 127, 188, 108, 120, 147, 151, 5, 33, 116, 162, 162, 35, 214, 88, 242, 61, 184, 14, 49, 33, 153, 210, 140, 175, 252, 108, 220, 1, 121, 20, 88, 56, 42, 196, 19, 159, 200, 57, 219, 103, 229, 42, 149, 170, 39, 239, 8, 32, 159, 9 ], "priority": 0, "protocol_version": 0 } ] diff --git a/network-hypervisor/src/vl1/node.rs b/network-hypervisor/src/vl1/node.rs index 0b8615f9c..758f5d94c 100644 --- a/network-hypervisor/src/vl1/node.rs +++ b/network-hypervisor/src/vl1/node.rs @@ -820,6 +820,15 @@ impl 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