From 0552d587a0241575fe078c671a991d561af3938a Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 16 Sep 2022 14:16:13 -0400 Subject: [PATCH] Get things building again --- network-hypervisor/src/vl2/mod.rs | 5 +-- service/src/localconfig.rs | 62 ++----------------------------- service/src/main.rs | 11 +++--- vl1-service/src/sys/udp.rs | 1 + 4 files changed, 11 insertions(+), 68 deletions(-) diff --git a/network-hypervisor/src/vl2/mod.rs b/network-hypervisor/src/vl2/mod.rs index c858d64da..6a4f1f248 100644 --- a/network-hypervisor/src/vl2/mod.rs +++ b/network-hypervisor/src/vl2/mod.rs @@ -2,9 +2,8 @@ mod multicastgroup; mod networkid; - -pub(crate) mod switch; +mod switch; pub use multicastgroup::MulticastGroup; pub use networkid::NetworkId; -pub use switch::SwitchInterface; +pub use switch::{Switch, SwitchInterface}; diff --git a/service/src/localconfig.rs b/service/src/localconfig.rs index c2720ad83..a406afa64 100644 --- a/service/src/localconfig.rs +++ b/service/src/localconfig.rs @@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize}; use zerotier_network_hypervisor::vl1::{Address, Endpoint, InetAddress}; use zerotier_network_hypervisor::vl2::NetworkId; +use zerotier_vl1_service::Settings; /// Default primary ZeroTier port. pub const DEFAULT_PORT: u16 = 9993; @@ -62,63 +63,6 @@ impl Default for NetworkSettings { } } -#[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] -#[serde(default)] -pub struct GlobalSettings { - /// Primary ZeroTier port that is always bound, default is 9993. - #[serde(rename = "primaryPort")] - pub primary_port: u16, - - /// Enable uPnP, NAT-PMP, and other router port mapping technologies? - #[serde(rename = "portMapping")] - pub port_mapping: bool, - - /// Interface name prefix blacklist for local bindings (not remote IPs). - #[serde(rename = "interfacePrefixBlacklist")] - pub interface_prefix_blacklist: Vec, - - /// IP/bits CIDR blacklist for local bindings (not remote IPs). - #[serde(rename = "cidrBlacklist")] - pub cidr_blacklist: Vec, -} - -impl Default for GlobalSettings { - fn default() -> Self { - let mut bl: Vec = Vec::new(); - bl.reserve(Self::DEFAULT_PREFIX_BLACKLIST.len()); - for n in Self::DEFAULT_PREFIX_BLACKLIST.iter() { - bl.push(String::from(*n)); - } - - Self { - primary_port: DEFAULT_PORT, - port_mapping: true, - interface_prefix_blacklist: bl, - cidr_blacklist: Vec::new(), - } - } -} - -impl GlobalSettings { - #[cfg(target_os = "macos")] - pub const DEFAULT_PREFIX_BLACKLIST: [&'static str; 10] = ["lo", "utun", "gif", "stf", "iptap", "pktap", "feth", "zt", "llw", "anpi"]; - - #[cfg(target_os = "linux")] - pub const DEFAULT_PREFIX_BLACKLIST: [&'static str; 5] = ["lo", "tun", "tap", "ipsec", "zt"]; - - #[cfg(windows)] - pub const DEFAULT_PREFIX_BLACKLIST: [&'static str; 0] = []; - - pub fn is_interface_blacklisted(&self, ifname: &str) -> bool { - for p in self.interface_prefix_blacklist.iter() { - if ifname.starts_with(p.as_str()) { - return true; - } - } - false - } -} - #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] #[serde(default)] pub struct Config { @@ -126,7 +70,7 @@ pub struct Config { #[serde(rename = "virtual")] pub virtual_: BTreeMap, pub network: BTreeMap, - pub settings: GlobalSettings, + pub settings: Settings, } impl Default for Config { @@ -135,7 +79,7 @@ impl Default for Config { physical: BTreeMap::new(), virtual_: BTreeMap::new(), network: BTreeMap::new(), - settings: GlobalSettings::default(), + settings: Settings::default(), } } } diff --git a/service/src/main.rs b/service/src/main.rs index 393c1914d..85751cdd5 100644 --- a/service/src/main.rs +++ b/service/src/main.rs @@ -4,14 +4,8 @@ pub mod cli; pub mod cmdline_help; pub mod datadir; pub mod exitcode; -pub mod getifaddrs; -pub mod ipv6; pub mod jsonformatter; pub mod localconfig; -pub mod localinterface; -pub mod localsocket; -pub mod service; -pub mod udp; pub mod utils; pub mod vnic; @@ -20,6 +14,7 @@ use std::io::Write; use clap::error::{ContextKind, ContextValue}; use clap::{Arg, ArgMatches, Command}; +use zerotier_network_hypervisor::vl2::Switch; use zerotier_network_hypervisor::{VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION}; pub fn print_help() { @@ -63,6 +58,8 @@ async fn async_main(flags: Flags, global_args: Box) -> i32 { Some(("leave", cmd_args)) => todo!(), Some(("service", _)) => { drop(global_args); // free unnecessary heap before starting service as we're done with CLI args + + /* let svc = service::Service::new(tokio::runtime::Handle::current(), &flags.base_path, true).await; if svc.is_ok() { let _ = tokio::signal::ctrl_c().await; @@ -72,6 +69,8 @@ async fn async_main(flags: Flags, global_args: Box) -> i32 { println!("FATAL: error launching service: {}", svc.err().unwrap().to_string()); exitcode::ERR_IOERR } + */ + todo!() } Some(("identity", cmd_args)) => todo!(), Some(("rootset", cmd_args)) => cli::rootset::cmd(flags, cmd_args).await, diff --git a/vl1-service/src/sys/udp.rs b/vl1-service/src/sys/udp.rs index 7a0ccbd2a..ec9f3b40b 100644 --- a/vl1-service/src/sys/udp.rs +++ b/vl1-service/src/sys/udp.rs @@ -163,6 +163,7 @@ impl BoundUdpPort { address: addr_with_port, socket: Arc::new(s.unwrap()), interface: interface.clone(), + associated_tasks: parking_lot::Mutex::new(Vec::new()), last_receive_time: AtomicI64::new(i64::MIN), fd, });