Get things building again

This commit is contained in:
Adam Ierymenko 2022-09-16 14:16:13 -04:00
parent b4c74ce7bb
commit 0552d587a0
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
4 changed files with 11 additions and 68 deletions

View file

@ -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};

View file

@ -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<String>,
/// IP/bits CIDR blacklist for local bindings (not remote IPs).
#[serde(rename = "cidrBlacklist")]
pub cidr_blacklist: Vec<InetAddress>,
}
impl Default for GlobalSettings {
fn default() -> Self {
let mut bl: Vec<String> = 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<Address, VirtualPathSettings>,
pub network: BTreeMap<NetworkId, NetworkSettings>,
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(),
}
}
}

View file

@ -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<ArgMatches>) -> 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<ArgMatches>) -> 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,

View file

@ -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,
});