diff --git a/zerotier-core-crypto/src/p384.rs b/zerotier-core-crypto/src/p384.rs index 016c3bd72..a76432f69 100644 --- a/zerotier-core-crypto/src/p384.rs +++ b/zerotier-core-crypto/src/p384.rs @@ -76,9 +76,16 @@ impl P384PublicKey { let r = BigNum::from_slice(&signature[0..48]); let s = BigNum::from_slice(&signature[48..96]); if r.is_ok() && s.is_ok() { - let sig = EcdsaSig::from_private_components(r.unwrap(), s.unwrap()); - if sig.is_ok() { - return sig.unwrap().verify(&SHA384::hash(msg), self.key.as_ref()).unwrap_or(false); + let r = r.unwrap(); + let s = s.unwrap(); + let z = BigNum::from_u32(0).unwrap(); + // Check that r and s are >=1 just in case the OpenSSL version or an OpenSSL API lookalike is + // vulnerable to this, since a bunch of vulnerabilities involving zero r/s just made the rounds. + if r.gt(&z) && s.gt(&z) { + let sig = EcdsaSig::from_private_components(r, s); + if sig.is_ok() { + return sig.unwrap().verify(&SHA384::hash(msg), self.key.as_ref()).unwrap_or(false); + } } } } diff --git a/zerotier-network-hypervisor/Cargo.toml b/zerotier-network-hypervisor/Cargo.toml index f44416ca2..5d56f6f73 100644 --- a/zerotier-network-hypervisor/Cargo.toml +++ b/zerotier-network-hypervisor/Cargo.toml @@ -18,7 +18,6 @@ lz4_flex = { version = "^0", features = ["safe-encode", "safe-decode", "checked- dashmap = "^4" parking_lot = "^0" lazy_static = "^1" -highway = "^0" serde = "^1" serde_derive = "^1" serde_json = "^1" diff --git a/zerotier-network-hypervisor/src/util/buffer.rs b/zerotier-network-hypervisor/src/util/buffer.rs index d92199a32..25738af19 100644 --- a/zerotier-network-hypervisor/src/util/buffer.rs +++ b/zerotier-network-hypervisor/src/util/buffer.rs @@ -6,7 +6,6 @@ * https://www.zerotier.com/ */ -use crate::util::{array_range, array_range_mut}; use std::io::Write; use std::mem::{size_of, MaybeUninit}; @@ -77,7 +76,7 @@ impl Buffer { #[inline(always)] pub fn as_range_fixed(&self) -> &[u8; LEN] { - array_range::(&self.1) + crate::util::byte_array_range::(&self.1) } #[inline(always)] @@ -92,7 +91,7 @@ impl Buffer { #[inline(always)] pub fn as_mut_range_fixed(&mut self) -> &mut [u8; LEN] { - array_range_mut::(&mut self.1) + crate::util::byte_array_range_mut::(&mut self.1) } /// Get all bytes after a given position. diff --git a/zerotier-network-hypervisor/src/util/mod.rs b/zerotier-network-hypervisor/src/util/mod.rs index d18a656a0..966f6ab98 100644 --- a/zerotier-network-hypervisor/src/util/mod.rs +++ b/zerotier-network-hypervisor/src/util/mod.rs @@ -15,35 +15,18 @@ pub use zerotier_core_crypto::varint; pub(crate) const ZEROES: [u8; 64] = [0_u8; 64]; -/// Obtain a reference to a sub-array within an existing array. +/// Obtain a reference to a sub-array within an existing byte array. #[inline(always)] -pub(crate) fn array_range(a: &[T; A]) -> &[T; LEN] { +pub(crate) fn byte_array_range(a: &[u8; A]) -> &[u8; LEN] { assert!((START + LEN) <= A); - unsafe { &*a.as_ptr().add(START).cast::<[T; LEN]>() } + unsafe { &*a.as_ptr().add(START).cast::<[u8; LEN]>() } } -/// Obtain a reference to a sub-array within an existing array. +/// Obtain a reference to a sub-array within an existing byte array. #[inline(always)] -pub(crate) fn array_range_mut(a: &mut [T; A]) -> &mut [T; LEN] { +pub(crate) fn byte_array_range_mut(a: &mut [u8; A]) -> &mut [u8; LEN] { assert!((START + LEN) <= A); - unsafe { &mut *a.as_mut_ptr().add(START).cast::<[T; LEN]>() } -} - -/// Cast a u64 to a byte array. -#[inline(always)] -pub(crate) fn u64_as_bytes(i: &u64) -> &[u8; 8] { - unsafe { &*(i as *const u64).cast() } -} - -lazy_static! { - static ref HIGHWAYHASHER_KEY: [u64; 4] = [zerotier_core_crypto::random::next_u64_secure(), zerotier_core_crypto::random::next_u64_secure(), zerotier_core_crypto::random::next_u64_secure(), zerotier_core_crypto::random::next_u64_secure()]; -} - -/// Get an instance of HighwayHasher initialized with a secret per-process random salt. -/// The random salt is generated at process start and so will differ for each invocation of whatever process this is inside. -#[inline(always)] -pub(crate) fn highwayhasher() -> highway::HighwayHasher { - highway::HighwayHasher::new(highway::Key(HIGHWAYHASHER_KEY.clone())) + unsafe { &mut *a.as_mut_ptr().add(START).cast::<[u8; LEN]>() } } /// Non-cryptographic 64-bit bit mixer for things like local hashing. @@ -56,7 +39,8 @@ pub(crate) fn hash64_noncrypt(mut x: u64) -> u64 { x ^ x.wrapping_shr(31) } -/// A hasher for maps that just returns u64 values as-is. +/// A hasher for u64 maps that just returns u64 values as-is. +/// /// Used with things like ZeroTier addresses and network IDs that are already randomly distributed. #[derive(Copy, Clone)] pub(crate) struct U64NoOpHasher(u64); diff --git a/zerotier-network-hypervisor/src/vl1/address.rs b/zerotier-network-hypervisor/src/vl1/address.rs index a5d31dca2..d2e5c0a88 100644 --- a/zerotier-network-hypervisor/src/vl1/address.rs +++ b/zerotier-network-hypervisor/src/vl1/address.rs @@ -56,14 +56,7 @@ impl Address { #[inline(always)] pub(crate) fn marshal(&self, buf: &mut Buffer) -> std::io::Result<()> { - let b = buf.append_bytes_fixed_get_mut::()?; - let i = self.0.get(); - (*b)[0] = (i >> 32) as u8; - (*b)[1] = (i >> 24) as u8; - (*b)[2] = (i >> 16) as u8; - (*b)[3] = (i >> 8) as u8; - (*b)[4] = i as u8; - Ok(()) + buf.append_bytes(&self.0.get().to_be_bytes()[8 - ADDRESS_SIZE..]) } #[inline(always)] diff --git a/zerotier-network-hypervisor/src/vl1/identity.rs b/zerotier-network-hypervisor/src/vl1/identity.rs index 7d5668232..fe098e888 100644 --- a/zerotier-network-hypervisor/src/vl1/identity.rs +++ b/zerotier-network-hypervisor/src/vl1/identity.rs @@ -20,7 +20,7 @@ use lazy_static::lazy_static; use serde_derive::{Deserialize, Serialize}; use zerotier_core_crypto::c25519::*; -use zerotier_core_crypto::hash::{hmac_sha512, SHA384, SHA384_HASH_SIZE, SHA512, SHA512_HASH_SIZE}; +use zerotier_core_crypto::hash::*; use zerotier_core_crypto::hex; use zerotier_core_crypto::p384::*; use zerotier_core_crypto::salsa::Salsa; @@ -811,6 +811,7 @@ mod tests { use crate::vl1::identity::{Identity, IDENTITY_ALGORITHM_ALL}; use std::str::FromStr; use std::time::{Duration, SystemTime}; + #[allow(unused_imports)] use zerotier_core_crypto::hex; const GOOD_V0_IDENTITIES: [&'static str; 10] = [ diff --git a/zerotier-network-hypervisor/src/vl1/inetaddress.rs b/zerotier-network-hypervisor/src/vl1/inetaddress.rs index f07dafd6c..f05a7e8a2 100644 --- a/zerotier-network-hypervisor/src/vl1/inetaddress.rs +++ b/zerotier-network-hypervisor/src/vl1/inetaddress.rs @@ -9,10 +9,12 @@ use std::cmp::Ordering; use std::hash::{Hash, Hasher}; use std::mem::{size_of, transmute_copy, zeroed, MaybeUninit}; -use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; +use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6}; use std::ptr::{copy_nonoverlapping, null, slice_from_raw_parts, write_bytes}; use std::str::FromStr; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + #[cfg(windows)] use winapi::um::winsock2; @@ -62,6 +64,10 @@ pub enum IpScope { /// The ZeroTier core uses this in preference to std::net stuff so this can be /// directly used via the C API or with C socket I/O functions. /// +/// This supports into() and from() the std::net types and also has a custom +/// serde serializer that serializes it in ZT protocol binary form for binary +/// formats and canonical ZT string form for string formats. +/// /// Unfortunately this is full of unsafe because it's a union, but the code is /// not complex and doesn't allocate anything. #[repr(C)] @@ -72,16 +78,168 @@ pub union InetAddress { ss: sockaddr_storage, // some external code may expect the struct to be this full length } -impl Into for InetAddress { - fn into(self) -> IpAddr { - if self.is_ipv4() { - IpAddr::V4(Ipv4Addr::from(self.to_bytes::<4>())) - } else { - IpAddr::V6(Ipv6Addr::from(self.to_bytes::<16>())) +impl TryInto for InetAddress { + type Error = crate::error::InvalidParameterError; + + fn try_into(self) -> Result { + match unsafe { self.sa.sa_family } { + AF_INET => Ok(IpAddr::V4(Ipv4Addr::from(unsafe { self.sin.sin_addr.s_addr.to_ne_bytes() }))), + AF_INET6 => Ok(IpAddr::V6(Ipv6Addr::from(unsafe { self.sin6.sin6_addr.s6_addr }))), + _ => Err(crate::error::InvalidParameterError("not an IP address")), } } } +impl TryInto for InetAddress { + type Error = crate::error::InvalidParameterError; + + fn try_into(self) -> Result { + match unsafe { self.sa.sa_family } { + AF_INET => Ok(Ipv4Addr::from(unsafe { self.sin.sin_addr.s_addr.to_ne_bytes() })), + _ => Err(crate::error::InvalidParameterError("not an IPv4 address")), + } + } +} + +impl TryInto for InetAddress { + type Error = crate::error::InvalidParameterError; + + fn try_into(self) -> Result { + match unsafe { self.sa.sa_family } { + AF_INET6 => Ok(Ipv6Addr::from(unsafe { self.sin6.sin6_addr.s6_addr })), + _ => Err(crate::error::InvalidParameterError("not an IPv6 address")), + } + } +} + +impl TryInto for InetAddress { + type Error = crate::error::InvalidParameterError; + + fn try_into(self) -> Result { + unsafe { + match self.sa.sa_family { + AF_INET => Ok(SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::from(self.sin.sin_addr.s_addr.to_ne_bytes()), u16::from_be(self.sin.sin_port as u16)))), + AF_INET6 => Ok(SocketAddr::V6(SocketAddrV6::new(Ipv6Addr::from(self.sin6.sin6_addr.s6_addr), u16::from_be(self.sin6.sin6_port as u16), 0, 0))), + _ => Err(crate::error::InvalidParameterError("not an IP address")), + } + } + } +} + +impl TryInto for InetAddress { + type Error = crate::error::InvalidParameterError; + + fn try_into(self) -> Result { + unsafe { + match self.sa.sa_family { + AF_INET => Ok(SocketAddrV4::new(Ipv4Addr::from(self.sin.sin_addr.s_addr.to_ne_bytes()), u16::from_be(self.sin.sin_port as u16))), + _ => Err(crate::error::InvalidParameterError("not an IPv4 address")), + } + } + } +} + +impl TryInto for InetAddress { + type Error = crate::error::InvalidParameterError; + + fn try_into(self) -> Result { + unsafe { + match self.sa.sa_family { + AF_INET6 => Ok(SocketAddrV6::new(Ipv6Addr::from(self.sin6.sin6_addr.s6_addr), u16::from_be(self.sin6.sin6_port as u16), 0, 0)), + _ => Err(crate::error::InvalidParameterError("not an IPv6 address")), + } + } + } +} + +impl From<&IpAddr> for InetAddress { + fn from(ip: &IpAddr) -> Self { + match ip { + IpAddr::V4(ip4) => Self::from(ip4), + IpAddr::V6(ip6) => Self::from(ip6), + } + } +} + +impl From for InetAddress { + #[inline(always)] + fn from(ip: IpAddr) -> Self { + Self::from(&ip) + } +} + +impl From<&Ipv4Addr> for InetAddress { + #[inline(always)] + fn from(ip4: &Ipv4Addr) -> Self { + Self::from_ip_port(&ip4.octets(), 0) + } +} + +impl From for InetAddress { + #[inline(always)] + fn from(ip4: Ipv4Addr) -> Self { + Self::from_ip_port(&ip4.octets(), 0) + } +} + +impl From<&Ipv6Addr> for InetAddress { + #[inline(always)] + fn from(ip6: &Ipv6Addr) -> Self { + Self::from_ip_port(&ip6.octets(), 0) + } +} + +impl From for InetAddress { + #[inline(always)] + fn from(ip6: Ipv6Addr) -> Self { + Self::from_ip_port(&ip6.octets(), 0) + } +} + +impl From<&SocketAddr> for InetAddress { + fn from(sa: &SocketAddr) -> Self { + match sa { + SocketAddr::V4(sa4) => Self::from(sa4), + SocketAddr::V6(sa6) => Self::from(sa6), + } + } +} + +impl From for InetAddress { + #[inline(always)] + fn from(sa: SocketAddr) -> Self { + Self::from(&sa) + } +} + +impl From<&SocketAddrV4> for InetAddress { + #[inline(always)] + fn from(sa: &SocketAddrV4) -> Self { + Self::from_ip_port(&sa.ip().octets(), sa.port()) + } +} + +impl From for InetAddress { + #[inline(always)] + fn from(sa: SocketAddrV4) -> Self { + Self::from_ip_port(&sa.ip().octets(), sa.port()) + } +} + +impl From<&SocketAddrV6> for InetAddress { + #[inline(always)] + fn from(sa: &SocketAddrV6) -> Self { + Self::from_ip_port(&sa.ip().octets(), sa.port()) + } +} + +impl From for InetAddress { + #[inline(always)] + fn from(sa: SocketAddrV6) -> Self { + Self::from_ip_port(&sa.ip().octets(), sa.port()) + } +} + impl Clone for InetAddress { #[inline(always)] fn clone(&self) -> Self { @@ -91,8 +249,8 @@ impl Clone for InetAddress { impl Default for InetAddress { #[inline(always)] - fn default() -> InetAddress { - unsafe { zeroed() } + fn default() -> Self { + Self::new() } } @@ -102,6 +260,68 @@ impl std::fmt::Debug for InetAddress { } } +// Just has to be large enough to store any binary marshalled InetAddress +const TEMP_SERIALIZE_BUFFER_SIZE: usize = 24; + +impl Serialize for InetAddress { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + if serializer.is_human_readable() { + serializer.serialize_str(self.to_string().as_str()) + } else { + let mut tmp: Buffer = Buffer::new(); + assert!(self.marshal(&mut tmp).is_ok()); + serializer.serialize_bytes(tmp.as_bytes()) + } + } +} + +struct InetAddressVisitor; + +impl<'de> serde::de::Visitor<'de> for InetAddressVisitor { + type Value = InetAddress; + + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + formatter.write_str("an InetAddress") + } + + fn visit_bytes(self, v: &[u8]) -> Result + where + E: serde::de::Error, + { + if v.len() <= TEMP_SERIALIZE_BUFFER_SIZE { + let mut tmp: Buffer = Buffer::new(); + let _ = tmp.append_bytes(v); + let mut cursor = 0; + InetAddress::unmarshal(&tmp, &mut cursor).map_err(|e| E::custom(e.to_string())) + } else { + Err(E::custom("object too large")) + } + } + + fn visit_str(self, v: &str) -> Result + where + E: serde::de::Error, + { + InetAddress::from_str(v).map_err(|e| E::custom(e.to_string())) + } +} + +impl<'de> Deserialize<'de> for InetAddress { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + if deserializer.is_human_readable() { + deserializer.deserialize_str(InetAddressVisitor) + } else { + deserializer.deserialize_bytes(InetAddressVisitor) + } + } +} + impl InetAddress { /// Get a new zero/nil InetAddress. #[inline(always)] @@ -114,7 +334,7 @@ impl InetAddress { #[inline(always)] pub fn from_ip_port(ip: &[u8], port: u16) -> InetAddress { unsafe { - let mut c = MaybeUninit::::uninit().assume_init(); + let mut c = MaybeUninit::::uninit().assume_init(); // gets zeroed in set() c.set(ip, port); c } @@ -178,6 +398,13 @@ impl InetAddress { unsafe { self.sa.sa_family as u8 == AF_INET6 } } + /// Check if this is either an IPv4 or an IPv6 address. + #[inline(always)] + pub fn is_ip(&self) -> bool { + let family = unsafe { self.sa.sa_family }; + family == AF_INET || family == AF_INET6 + } + /// Get the address family of this InetAddress: AF_INET, AF_INET6, or 0 if uninitialized. #[inline(always)] #[cfg(not(target_os = "linux"))] @@ -242,21 +469,6 @@ impl InetAddress { } } - pub fn to_bytes(&self) -> [u8; LEN] { - if LEN != 4 && LEN != 16 { - panic!("LEN was not 4 or 16, cannot convert"); - } - - let mut res = [0u8; LEN]; - - if LEN == 4 && !self.is_ipv4() { - panic!("Non-IPv4 address expected for 4 byte array"); - } - - res.copy_from_slice(&self.ip_bytes()[0..LEN]); - res - } - /// Get raw IP bytes packed into a u128. /// Bytes are packed in native endian so the resulting u128 may not be the same between systems. /// This value is intended for local lookup use only. @@ -499,39 +711,44 @@ impl ToString for InetAddress { impl FromStr for InetAddress { type Err = InvalidFormatError; - fn from_str(s: &str) -> Result { + fn from_str(ip_string: &str) -> Result { let mut addr = InetAddress::new(); - let (ip_str, port) = s.find('/').map_or_else( - || (s, 0), - |pos| { - let ss = s.split_at(pos); - let mut port_str = ss.1; - if port_str.starts_with('/') { - port_str = &port_str[1..]; - } - (ss.0, u16::from_str_radix(port_str, 10).unwrap_or(0).to_be()) - }, - ); - IpAddr::from_str(ip_str).map_or_else( - |_| Err(InvalidFormatError), - |ip| { - unsafe { - match ip { - IpAddr::V4(v4) => { - addr.sin.sin_family = AF_INET.into(); - addr.sin.sin_port = port.into(); - copy_nonoverlapping(v4.octets().as_ptr(), (&mut (addr.sin.sin_addr.s_addr) as *mut u32).cast(), 4); - } - IpAddr::V6(v6) => { - addr.sin6.sin6_family = AF_INET6.into(); - addr.sin6.sin6_port = port.into(); - copy_nonoverlapping(v6.octets().as_ptr(), (&mut (addr.sin6.sin6_addr) as *mut in6_addr).cast(), 16); + let s = ip_string.trim(); + if !s.is_empty() { + let (ip_str, port) = s.find('/').map_or_else( + || (s, 0), + |pos| { + let ss = s.split_at(pos); + let mut port_str = ss.1; + if port_str.starts_with('/') { + port_str = &port_str[1..]; + } + (ss.0, u16::from_str_radix(port_str, 10).unwrap_or(0).to_be()) + }, + ); + IpAddr::from_str(ip_str).map_or_else( + |_| Err(InvalidFormatError), + |ip| { + unsafe { + match ip { + IpAddr::V4(v4) => { + addr.sin.sin_family = AF_INET.into(); + addr.sin.sin_port = port.into(); + copy_nonoverlapping(v4.octets().as_ptr(), (&mut (addr.sin.sin_addr.s_addr) as *mut u32).cast(), 4); + } + IpAddr::V6(v6) => { + addr.sin6.sin6_family = AF_INET6.into(); + addr.sin6.sin6_port = port.into(); + copy_nonoverlapping(v6.octets().as_ptr(), (&mut (addr.sin6.sin6_addr) as *mut in6_addr).cast(), 16); + } } } - } - Ok(addr) - }, - ) + Ok(addr) + }, + ) + } else { + Ok(addr) + } } } @@ -643,6 +860,8 @@ impl Hash for InetAddress { } } +unsafe impl Send for InetAddress {} + #[cfg(test)] mod tests { use std::mem::size_of; diff --git a/zerotier-network-hypervisor/src/vl1/mac.rs b/zerotier-network-hypervisor/src/vl1/mac.rs index 8d40031c1..f2c296567 100644 --- a/zerotier-network-hypervisor/src/vl1/mac.rs +++ b/zerotier-network-hypervisor/src/vl1/mac.rs @@ -57,15 +57,7 @@ impl MAC { #[inline(always)] pub(crate) fn marshal(&self, buf: &mut Buffer) -> std::io::Result<()> { - let b = buf.append_bytes_fixed_get_mut::<6>()?; - let i = self.0.get(); - (*b)[0] = (i >> 40) as u8; - (*b)[1] = (i >> 32) as u8; - (*b)[2] = (i >> 24) as u8; - (*b)[3] = (i >> 16) as u8; - (*b)[4] = (i >> 8) as u8; - (*b)[5] = i as u8; - Ok(()) + buf.append_bytes(&self.0.get().to_be_bytes()[2..]) } #[inline(always)] diff --git a/zerotier-network-hypervisor/src/vl1/mod.rs b/zerotier-network-hypervisor/src/vl1/mod.rs index f7ebae691..0538cd007 100644 --- a/zerotier-network-hypervisor/src/vl1/mod.rs +++ b/zerotier-network-hypervisor/src/vl1/mod.rs @@ -21,7 +21,6 @@ pub(crate) mod peer; #[allow(unused)] pub(crate) mod protocol; pub(crate) mod symmetricsecret; -pub(crate) mod system_interface; pub(crate) mod whoisqueue; pub use address::Address; @@ -33,6 +32,5 @@ pub use mac::MAC; pub use node::{Node, SystemInterface}; pub use path::Path; pub use peer::Peer; -pub use system_interface::VL1SystemInterface; pub use protocol::{PACKET_FRAGMENT_COUNT_MAX, PACKET_SIZE_MAX}; diff --git a/zerotier-network-hypervisor/src/vl1/node.rs b/zerotier-network-hypervisor/src/vl1/node.rs index a399cbe8f..0054faf61 100644 --- a/zerotier-network-hypervisor/src/vl1/node.rs +++ b/zerotier-network-hypervisor/src/vl1/node.rs @@ -82,8 +82,8 @@ pub trait SystemInterface: Sync + Send { /// Interface between VL1 and higher/inner protocol layers. /// /// This is implemented by Switch in VL2. It's usually not used outside of VL2 in the core but -/// it could also be implemented for testing or "off label" use of VL1. -pub trait VL1VirtualInterface: Sync + Send { +/// it could also be implemented for testing or "off label" use of VL1 to carry different protocols. +pub trait InnerProtocolInterface: Sync + Send { /// Handle a packet, returning true if it was handled by the next layer. /// /// Do not attempt to handle OK or ERROR. Instead implement handle_ok() and handle_error(). @@ -232,7 +232,7 @@ impl Node { } /// Called when a packet is received on the physical wire. - pub fn wire_receive(&self, si: &SI, ph: &PH, source_endpoint: &Endpoint, source_local_socket: Option, source_local_interface: Option, mut data: PacketBuffer) { + pub fn wire_receive(&self, si: &SI, ph: &PH, source_endpoint: &Endpoint, source_local_socket: Option, source_local_interface: Option, mut data: PacketBuffer) { if let Ok(fragment_header) = data.struct_mut_at::(0) { if let Some(dest) = Address::from_bytes(&fragment_header.dest) { let time_ticks = si.time_ticks(); diff --git a/zerotier-network-hypervisor/src/vl1/path.rs b/zerotier-network-hypervisor/src/vl1/path.rs index bdc0e5bdf..7f55afee7 100644 --- a/zerotier-network-hypervisor/src/vl1/path.rs +++ b/zerotier-network-hypervisor/src/vl1/path.rs @@ -8,16 +8,14 @@ use std::collections::HashMap; use std::hash::Hasher; -use std::io::Write; use std::num::NonZeroI64; use std::sync::atomic::{AtomicI64, Ordering}; use std::sync::Arc; -use highway::HighwayHash; use parking_lot::Mutex; use zerotier_core_crypto::hash::SHA384_HASH_SIZE; -use crate::util::{array_range, highwayhasher, U64NoOpHasher}; +use crate::util::*; use crate::vl1::fragmentedpacket::FragmentedPacket; use crate::vl1::node::SystemInterface; use crate::vl1::protocol::*; @@ -27,10 +25,13 @@ use crate::PacketBuffer; /// Keepalive interval for paths in milliseconds. pub(crate) const PATH_KEEPALIVE_INTERVAL: i64 = 20000; +// A bunch of random values used to randomize the local_lookup_key() function's mappings of addresses to 128-bit internal keys. lazy_static! { static ref RANDOM_64BIT_SALT_0: u64 = zerotier_core_crypto::random::next_u64_secure(); static ref RANDOM_64BIT_SALT_1: u64 = zerotier_core_crypto::random::next_u64_secure(); static ref RANDOM_64BIT_SALT_2: u64 = zerotier_core_crypto::random::next_u64_secure(); + static ref RANDOM_128BIT_SALT_0: u128 = (zerotier_core_crypto::random::next_u64_secure().wrapping_shl(64) as u128) ^ (zerotier_core_crypto::random::next_u64_secure() as u128); + static ref RANDOM_128BIT_SALT_1: u128 = (zerotier_core_crypto::random::next_u64_secure().wrapping_shl(64) as u128) ^ (zerotier_core_crypto::random::next_u64_secure() as u128); } /// A remote endpoint paired with a local socket and a local interface. @@ -55,7 +56,7 @@ impl Path { let lsi = (local_socket as u128).wrapping_shl(64) | (local_interface as u128); match endpoint { Endpoint::Nil => 0, - Endpoint::ZeroTier(_, h) => u128::from_ne_bytes(*array_range::(h)), + Endpoint::ZeroTier(_, h) => u128::from_ne_bytes(*byte_array_range::(h)), Endpoint::Ethernet(m) => (m.to_u64() | 0x0100000000000000) as u128 ^ lsi, Endpoint::WifiDirect(m) => (m.to_u64() | 0x0200000000000000) as u128 ^ lsi, Endpoint::Bluetooth(m) => (m.to_u64() | 0x0400000000000000) as u128 ^ lsi, @@ -63,24 +64,23 @@ impl Path { Endpoint::IpUdp(ip) => ip.ip_as_native_u128().wrapping_add(lsi), // UDP maintains one path per IP but merely learns the most recent port Endpoint::IpTcp(ip) => ip.ip_as_native_u128().wrapping_sub(crate::util::hash64_noncrypt((ip.port() as u64).wrapping_add(*RANDOM_64BIT_SALT_2)) as u128).wrapping_sub(lsi), Endpoint::Http(s) => { - let mut hh = highwayhasher(); - let _ = hh.write_all(s.as_bytes()); - let _ = hh.write_u64(local_socket); - let _ = hh.write_u64(local_interface); - u128::from_ne_bytes(unsafe { *hh.finalize128().as_ptr().cast() }) + let mut hh = std::collections::hash_map::DefaultHasher::new(); + hh.write_u64(local_socket); + hh.write_u64(local_interface); + hh.write(s.as_bytes()); + RANDOM_128BIT_SALT_0.wrapping_add(hh.finish() as u128) } Endpoint::WebRTC(b) => { - let mut hh = highwayhasher(); - let _ = hh.write_u64(local_socket); - let _ = hh.write_u64(local_interface); - let _ = hh.write_all(b.as_slice()); - u128::from_ne_bytes(unsafe { *hh.finalize128().as_ptr().cast() }) + let mut hh = std::collections::hash_map::DefaultHasher::new(); + hh.write_u64(local_socket); + hh.write_u64(local_interface); + hh.write(b.as_slice()); + RANDOM_128BIT_SALT_1.wrapping_add(hh.finish() as u128) } - Endpoint::ZeroTierEncap(_, h) => u128::from_ne_bytes(*array_range::(h)), + Endpoint::ZeroTierEncap(_, h) => u128::from_ne_bytes(*byte_array_range::(h)), } } - #[inline(always)] pub fn new(endpoint: Endpoint, local_socket: Option, local_interface: Option) -> Self { Self { endpoint: Mutex::new(Arc::new(endpoint)), @@ -119,7 +119,6 @@ impl Path { /// Receive a fragment and return a FragmentedPacket if the entire packet was assembled. /// This returns None if more fragments are needed to assemble the packet. - #[inline(always)] pub(crate) fn receive_fragment(&self, packet_id: u64, fragment_no: u8, fragment_expecting_count: u8, packet: PacketBuffer, time_ticks: i64) -> Option { let mut fp = self.fragmented_packets.lock(); @@ -150,7 +149,6 @@ impl Path { self.last_receive_time_ticks.store(time_ticks, Ordering::Relaxed); } - #[inline(always)] pub(crate) fn log_receive_authenticated_packet(&self, _bytes: usize, source_endpoint: &Endpoint) { let mut replace = false; match source_endpoint { @@ -180,7 +178,6 @@ impl Path { pub(crate) const CALL_EVERY_INTERVAL_MS: i64 = PATH_KEEPALIVE_INTERVAL; - #[inline(always)] pub(crate) fn call_every_interval(&self, _si: &SI, time_ticks: i64) { self.fragmented_packets.lock().retain(|_, frag| (time_ticks - frag.ts_ticks) < PACKET_FRAGMENT_EXPIRATION); } diff --git a/zerotier-network-hypervisor/src/vl1/peer.rs b/zerotier-network-hypervisor/src/vl1/peer.rs index 234dc98fb..a264e45db 100644 --- a/zerotier-network-hypervisor/src/vl1/peer.rs +++ b/zerotier-network-hypervisor/src/vl1/peer.rs @@ -18,13 +18,13 @@ use zerotier_core_crypto::aes_gmac_siv::AesCtr; use zerotier_core_crypto::hash::*; use zerotier_core_crypto::kbkdf::zt_kbkdf_hmac_sha384; use zerotier_core_crypto::poly1305::Poly1305; -use zerotier_core_crypto::random::{fill_bytes_secure, get_bytes_secure, next_u64_secure}; +use zerotier_core_crypto::random::{get_bytes_secure, next_u64_secure}; use zerotier_core_crypto::salsa::Salsa; use zerotier_core_crypto::secret::Secret; use crate::util::buffer::Buffer; -use crate::util::{array_range, u64_as_bytes}; -use crate::vl1::hybridkey::{HybridKeyPair, HybridPublicKey}; +use crate::util::byte_array_range; +use crate::vl1::hybridkey::HybridKeyPair; use crate::vl1::identity::{IDENTITY_ALGORITHM_ALL, IDENTITY_ALGORITHM_X25519}; use crate::vl1::node::*; use crate::vl1::protocol::*; @@ -172,7 +172,7 @@ fn try_aead_decrypt(secret: &SymmetricSecret, packet_frag0_payload_bytes: &[u8], // AES-GMAC-SIV encrypts the packet ID too as part of its computation of a single // opaque 128-bit tag, so to get the original packet ID we have to grab it from the // decrypted tag. - Some(u64::from_ne_bytes(*array_range::(tag))) + Some(u64::from_ne_bytes(*byte_array_range::<16, 0, 8>(tag))) }) } @@ -221,7 +221,7 @@ impl Peer { /// /// If the packet comes in multiple fragments, the fragments slice should contain all /// those fragments after the main packet header and first chunk. - pub(crate) fn receive(&self, node: &Node, si: &SI, vi: &VI, time_ticks: i64, source_endpoint: &Endpoint, source_path: &Arc, header: &PacketHeader, frag0: &Buffer<{ PACKET_SIZE_MAX }>, fragments: &[Option]) { + pub(crate) fn receive(&self, node: &Node, si: &SI, vi: &VI, time_ticks: i64, source_endpoint: &Endpoint, source_path: &Arc, header: &PacketHeader, frag0: &Buffer<{ PACKET_SIZE_MAX }>, fragments: &[Option]) { let _ = frag0.as_bytes_starting_at(PACKET_VERB_INDEX).map(|packet_frag0_payload_bytes| { let mut payload: Buffer = unsafe { Buffer::new_without_memzero() }; @@ -502,7 +502,7 @@ impl Peer { // Add extended HMAC-SHA512 authentication. let mut hmac = HMACSHA512::new(self.identity_symmetric_key.packet_hmac_key.as_bytes()); - hmac.update(u64_as_bytes(&message_id)); + hmac.update(&message_id.to_ne_bytes()); hmac.update(&packet.as_bytes()[PACKET_HEADER_SIZE..]); assert!(packet.append_bytes_fixed(&hmac.finish()).is_ok()); @@ -537,7 +537,7 @@ impl Peer { fn receive_hello(&self, si: &SI, node: &Node, time_ticks: i64, source_path: &Arc, payload: &Buffer<{ PACKET_SIZE_MAX }>) {} #[inline(always)] - fn receive_error(&self, si: &SI, ph: &PH, node: &Node, time_ticks: i64, source_path: &Arc, forward_secrecy: bool, extended_authentication: bool, payload: &Buffer<{ PACKET_SIZE_MAX }>) { + fn receive_error(&self, si: &SI, ph: &PH, node: &Node, time_ticks: i64, source_path: &Arc, forward_secrecy: bool, extended_authentication: bool, payload: &Buffer<{ PACKET_SIZE_MAX }>) { let mut cursor: usize = 0; let _ = payload.read_struct::(&mut cursor).map(|error_header| { let in_re_message_id = u64::from_ne_bytes(error_header.in_re_message_id); @@ -553,7 +553,7 @@ impl Peer { } #[inline(always)] - fn receive_ok(&self, si: &SI, ph: &PH, node: &Node, time_ticks: i64, source_path: &Arc, forward_secrecy: bool, extended_authentication: bool, payload: &Buffer<{ PACKET_SIZE_MAX }>) { + fn receive_ok(&self, si: &SI, ph: &PH, node: &Node, time_ticks: i64, source_path: &Arc, forward_secrecy: bool, extended_authentication: bool, payload: &Buffer<{ PACKET_SIZE_MAX }>) { let mut cursor: usize = 0; let _ = payload.read_struct::(&mut cursor).map(|ok_header| { let in_re_message_id = u64::from_ne_bytes(ok_header.in_re_message_id); diff --git a/zerotier-network-hypervisor/src/vl1/system_interface.rs b/zerotier-network-hypervisor/src/vl1/system_interface.rs deleted file mode 100644 index 89d6b386b..000000000 --- a/zerotier-network-hypervisor/src/vl1/system_interface.rs +++ /dev/null @@ -1,17 +0,0 @@ -use super::{Endpoint, Identity}; -use std::num::NonZeroI64; - -pub trait VL1SystemInterface { - fn event_node_is_up(&self); - fn event_node_is_down(&self); - fn event_identity_collision(&self); - fn event_online_status_change(&self, online: bool); - fn event_user_message(&self, source: &Identity, message_type: u64, message: &[u8]); - fn load_node_identity(&self) -> Option>; - fn save_node_identity(&self, _: &Identity, public: &[u8], secret: &[u8]); - fn wire_send(&self, endpoint: &Endpoint, local_socket: Option, local_interface: Option, data: &[&[u8]], packet_ttl: u8) -> bool; - fn check_path(&self, id: &Identity, endpoint: &Endpoint, local_socket: Option, local_interface: Option) -> bool; - fn get_path_hints(&self, id: &Identity) -> Option<&[(&Endpoint, Option, Option)]>; - fn time_ticks(&self) -> i64; - fn time_clock(&self) -> i64; -} diff --git a/zerotier-network-hypervisor/src/vl2/switch.rs b/zerotier-network-hypervisor/src/vl2/switch.rs index 0c46216e6..c7f136f89 100644 --- a/zerotier-network-hypervisor/src/vl2/switch.rs +++ b/zerotier-network-hypervisor/src/vl2/switch.rs @@ -9,7 +9,7 @@ use std::sync::Arc; use crate::util::buffer::Buffer; -use crate::vl1::node::VL1VirtualInterface; +use crate::vl1::node::InnerProtocolInterface; use crate::vl1::protocol::*; use crate::vl1::{Identity, Path, Peer}; @@ -17,7 +17,7 @@ pub trait SwitchInterface: Sync + Send {} pub struct Switch {} -impl VL1VirtualInterface for Switch { +impl InnerProtocolInterface for Switch { fn handle_packet(&self, peer: &Peer, source_path: &Arc, forward_secrecy: bool, extended_authentication: bool, verb: u8, payload: &Buffer<{ PACKET_SIZE_MAX }>) -> bool { false } diff --git a/zerotier-system-service/Cargo.lock b/zerotier-system-service/Cargo.lock index 203cb5e18..abb7e88a2 100644 --- a/zerotier-system-service/Cargo.lock +++ b/zerotier-system-service/Cargo.lock @@ -2,40 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "aead" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" -dependencies = [ - "generic-array", -] - -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher", -] - -[[package]] -name = "aes-gcm" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5278b5fabbb9bd46e24aa69b2fdea62c99088e0a950a9be40e3e0101298f88da" -dependencies = [ - "aead", - "aes", - "cipher", - "ctr", - "ghash", - "subtle", -] - [[package]] name = "aes-gmac-siv" version = "0.5.0" @@ -43,26 +9,6 @@ dependencies = [ "openssl", ] -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher", - "opaque-debug", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher", - "opaque-debug", -] - [[package]] name = "aho-corasick" version = "0.7.18" @@ -72,223 +18,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - -[[package]] -name = "anyhow" -version = "1.0.56" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" - -[[package]] -name = "async-channel" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-dup" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7427a12b8dc09291528cfb1da2447059adb4a257388c2acd6497a79d55cf6f7c" -dependencies = [ - "futures-io", - "simple-mutex", -] - -[[package]] -name = "async-executor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" -dependencies = [ - "async-task", - "concurrent-queue", - "fastrand", - "futures-lite", - "once_cell", - "slab", -] - -[[package]] -name = "async-fs" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b3ca4f8ff117c37c278a2f7415ce9be55560b846b5bc4412aaa5d29c1c3dae2" -dependencies = [ - "async-lock", - "blocking", - "futures-lite", -] - -[[package]] -name = "async-global-executor" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c290043c9a95b05d45e952fb6383c67bcb61471f60cfa21e890dba6654234f43" -dependencies = [ - "async-channel", - "async-executor", - "async-io", - "async-mutex", - "blocking", - "futures-lite", - "num_cpus", - "once_cell", -] - -[[package]] -name = "async-h1" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8101020758a4fc3a7c326cb42aa99e9fa77cbfb76987c128ad956406fe1f70a7" -dependencies = [ - "async-channel", - "async-dup", - "async-std", - "futures-core", - "http-types", - "httparse", - "log", - "pin-project", -] - -[[package]] -name = "async-io" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" -dependencies = [ - "concurrent-queue", - "futures-lite", - "libc", - "log", - "once_cell", - "parking", - "polling", - "slab", - "socket2", - "waker-fn", - "winapi", -] - -[[package]] -name = "async-lock" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97a171d191782fba31bb902b14ad94e24a68145032b7eedf871ab0bc0d077b6" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-mutex" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479db852db25d9dbf6204e6cb6253698f175c15726470f78af0d918e99d6156e" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-net" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5373304df79b9b4395068fb080369ec7178608827306ce4d081cba51cac551df" -dependencies = [ - "async-io", - "blocking", - "futures-lite", -] - -[[package]] -name = "async-process" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83137067e3a2a6a06d67168e49e68a0957d215410473a740cea95a2425c0b7c6" -dependencies = [ - "async-io", - "blocking", - "cfg-if", - "event-listener", - "futures-lite", - "libc", - "once_cell", - "signal-hook", - "winapi", -] - -[[package]] -name = "async-sse" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53bba003996b8fd22245cd0c59b869ba764188ed435392cf2796d03b805ade10" -dependencies = [ - "async-channel", - "async-std", - "http-types", - "log", - "memchr", - "pin-project-lite 0.1.12", -] - -[[package]] -name = "async-std" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52580991739c5cdb36cde8b2a516371c0a3b70dda36d916cc08b82372916808c" -dependencies = [ - "async-channel", - "async-global-executor", - "async-io", - "async-lock", - "async-process", - "crossbeam-utils", - "futures-channel", - "futures-core", - "futures-io", - "futures-lite", - "gloo-timers", - "kv-log-macro", - "log", - "memchr", - "num_cpus", - "once_cell", - "pin-project-lite 0.2.8", - "pin-utils", - "slab", - "wasm-bindgen-futures", -] - -[[package]] -name = "async-task" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" - -[[package]] -name = "async-trait" -version = "0.1.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6aa3524a2dfcf9fe180c51eae2b58738348d819517ceadf95789c51fff7600" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "atomic-polyfill" version = "0.1.7" @@ -298,23 +27,6 @@ dependencies = [ "critical-section", ] -[[package]] -name = "atomic-waker" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -336,12 +48,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" -[[package]] -name = "base-x" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" - [[package]] name = "base64" version = "0.13.0" @@ -375,38 +81,12 @@ dependencies = [ "generic-array", ] -[[package]] -name = "blocking" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc" -dependencies = [ - "async-channel", - "async-task", - "atomic-waker", - "fastrand", - "futures-lite", - "once_cell", -] - -[[package]] -name = "bumpalo" -version = "3.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" - [[package]] name = "byteorder" version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "cache-padded" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" - [[package]] name = "cc" version = "1.0.73" @@ -419,87 +99,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "time 0.1.43", - "winapi", -] - -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array", -] - -[[package]] -name = "clap" -version = "2.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" -dependencies = [ - "ansi_term", - "atty", - "bitflags", - "strsim", - "term_size", - "textwrap", - "unicode-width", - "vec_map", -] - -[[package]] -name = "colored" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" -dependencies = [ - "atty", - "lazy_static", - "winapi", -] - -[[package]] -name = "concurrent-queue" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" -dependencies = [ - "cache-padded", -] - -[[package]] -name = "const_fn" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" - -[[package]] -name = "cookie" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a5d7b21829bc7b4bf4754a978a241ae54ea55a40f92bb20216e54096f4b951" -dependencies = [ - "aes-gcm", - "base64", - "hkdf", - "hmac", - "percent-encoding", - "rand 0.8.5", - "sha2", - "time 0.2.27", - "version_check", -] - [[package]] name = "cortex-m" version = "0.7.4" @@ -521,12 +120,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cpuid-bool" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" - [[package]] name = "critical-section" version = "0.2.7" @@ -539,45 +132,6 @@ dependencies = [ "riscv", ] -[[package]] -name = "crossbeam-utils" -version = "0.8.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" -dependencies = [ - "cfg-if", - "lazy_static", -] - -[[package]] -name = "crypto-mac" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" -dependencies = [ - "generic-array", - "subtle", -] - -[[package]] -name = "ctor" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "ctr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" -dependencies = [ - "cipher", -] - [[package]] name = "curve25519-dalek" version = "3.2.1" @@ -586,7 +140,7 @@ checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" dependencies = [ "byteorder", "digest", - "rand_core 0.5.1", + "rand_core", "subtle", "zeroize", ] @@ -610,25 +164,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "digest_auth" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa30657988b2ced88f68fe490889e739bf98d342916c33ed3100af1d6f1cbc9c" -dependencies = [ - "digest", - "hex", - "md-5", - "rand 0.8.5", - "sha2", -] - -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - [[package]] name = "ed25519" version = "1.4.1" @@ -646,7 +181,7 @@ checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek", "ed25519", - "rand 0.7.3", + "rand", "serde", "sha2", "zeroize", @@ -662,21 +197,6 @@ dependencies = [ "void", ] -[[package]] -name = "event-listener" -version = "2.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" - -[[package]] -name = "fastrand" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" -dependencies = [ - "instant", -] - [[package]] name = "foreign-types" version = "0.3.2" @@ -692,83 +212,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" -[[package]] -name = "form_urlencoded" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" -dependencies = [ - "matches", - "percent-encoding", -] - -[[package]] -name = "futures-channel" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" -dependencies = [ - "futures-core", -] - -[[package]] -name = "futures-core" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" - -[[package]] -name = "futures-io" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" - -[[package]] -name = "futures-lite" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite 0.2.8", - "waker-fn", -] - -[[package]] -name = "futures-macro" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-task" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" - -[[package]] -name = "futures-util" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" -dependencies = [ - "futures-core", - "futures-macro", - "futures-task", - "pin-project-lite 0.2.8", - "pin-utils", - "slab", -] - [[package]] name = "generic-array" version = "0.14.5" @@ -787,40 +230,7 @@ checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if", "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.10.2+wasi-snapshot-preview1", -] - -[[package]] -name = "ghash" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" -dependencies = [ - "opaque-debug", - "polyval", -] - -[[package]] -name = "gloo-timers" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d12a7f4e95cfe710f1d624fb1210b7d961a5fb05c4fd942f4feab06e61f590e" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", + "wasi", ] [[package]] @@ -853,129 +263,12 @@ dependencies = [ "libc", ] -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "highway" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3688f13e7735ae5ca93edc490f6c5885b77d473255bc1fed92b9c805f972bf94" - -[[package]] -name = "hkdf" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f" -dependencies = [ - "digest", - "hmac", -] - -[[package]] -name = "hmac" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" -dependencies = [ - "crypto-mac", - "digest", -] - -[[package]] -name = "http-client" -version = "6.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea880b03c18a7e981d7fb3608b8904a98425d53c440758fcebf7d934aa56547c" -dependencies = [ - "async-trait", - "cfg-if", - "dashmap", - "http-types", - "log", -] - -[[package]] -name = "http-types" -version = "2.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e9b187a72d63adbfba487f48095306ac823049cb504ee195541e91c7775f5ad" -dependencies = [ - "anyhow", - "async-channel", - "async-std", - "base64", - "cookie", - "futures-lite", - "infer", - "pin-project-lite 0.2.8", - "rand 0.7.3", - "serde", - "serde_json", - "serde_qs", - "serde_urlencoded", - "url", -] - -[[package]] -name = "httparse" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" - -[[package]] -name = "idna" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "infer" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e9829a50b42bb782c1df523f78d332fe371b10c661e78b7a3c34b0198e9fac" - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - [[package]] name = "itoa" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" -[[package]] -name = "js-sys" -version = "0.3.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "671a26f820db17c2a2750743f1dd03bafd15b98c9f30c7c2628c024c05d73397" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "kv-log-macro" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" -dependencies = [ - "log", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -998,16 +291,6 @@ dependencies = [ "scopeguard", ] -[[package]] -name = "log" -version = "0.4.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" -dependencies = [ - "cfg-if", - "value-bag", -] - [[package]] name = "lz4_flex" version = "0.9.2" @@ -1017,32 +300,6 @@ dependencies = [ "twox-hash", ] -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", -] - -[[package]] -name = "matches" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" - -[[package]] -name = "md-5" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5a279bb9607f9f53c22d496eade00d138d1bdcccd07d74650387cf94942a15" -dependencies = [ - "block-buffer", - "digest", - "opaque-debug", -] - [[package]] name = "memchr" version = "2.4.1" @@ -1064,16 +321,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" -[[package]] -name = "num-integer" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" -dependencies = [ - "autocfg", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.14" @@ -1132,12 +379,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "parking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" - [[package]] name = "parking_lot" version = "0.12.0" @@ -1161,69 +402,12 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "percent-encoding" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" - -[[package]] -name = "pin-project" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" - -[[package]] -name = "pin-project-lite" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - [[package]] name = "pkg-config" version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" -[[package]] -name = "polling" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685404d509889fade3e86fe3a5803bca2ec09b0c0778d5ada6ec8bf7a8de5259" -dependencies = [ - "cfg-if", - "libc", - "log", - "wepoll-ffi", - "winapi", -] - [[package]] name = "poly1305" version = "0.7.2" @@ -1235,29 +419,12 @@ dependencies = [ "universal-hash", ] -[[package]] -name = "polyval" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" -dependencies = [ - "cpuid-bool", - "opaque-debug", - "universal-hash", -] - [[package]] name = "ppv-lite86" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - [[package]] name = "proc-macro2" version = "1.0.37" @@ -1282,24 +449,13 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom 0.1.16", + "getrandom", "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", "rand_hc", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.3", -] - [[package]] name = "rand_chacha" version = "0.2.2" @@ -1307,17 +463,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.3", + "rand_core", ] [[package]] @@ -1326,16 +472,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom 0.2.6", + "getrandom", ] [[package]] @@ -1344,7 +481,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core 0.5.1", + "rand_core", ] [[package]] @@ -1394,12 +531,6 @@ dependencies = [ "regex", ] -[[package]] -name = "route-recognizer" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56770675ebc04927ded3e60633437841581c285dc6236109ea25fbf3beb7b59e" - [[package]] name = "rustc_version" version = "0.2.3" @@ -1467,44 +598,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_qs" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7715380eec75f029a4ef7de39a9200e0a63823176b759d055b613f5a87df6a6" -dependencies = [ - "percent-encoding", - "serde", - "thiserror", -] - -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sha1" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" -dependencies = [ - "sha1_smol", -] - -[[package]] -name = "sha1_smol" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" - [[package]] name = "sha2" version = "0.9.9" @@ -1518,80 +611,18 @@ dependencies = [ "opaque-debug", ] -[[package]] -name = "signal-hook" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "647c97df271007dcea485bb74ffdb57f2e683f1306c854f468a0c244badabf2d" -dependencies = [ - "libc", - "signal-hook-registry", -] - -[[package]] -name = "signal-hook-registry" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" -dependencies = [ - "libc", -] - [[package]] name = "signature" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f054c6c1a6e95179d6f23ed974060dcefb2d9388bb7256900badad682c499de4" -[[package]] -name = "simple-mutex" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38aabbeafa6f6dead8cebf246fe9fae1f9215c8d29b3a69f93bd62a9e4a3dcd6" -dependencies = [ - "event-listener", -] - -[[package]] -name = "slab" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" - [[package]] name = "smallvec" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" -[[package]] -name = "smol" -version = "1.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cf3b5351f3e783c1d79ab5fc604eeed8b8ae9abd36b166e8b87a089efd85e4" -dependencies = [ - "async-channel", - "async-executor", - "async-fs", - "async-io", - "async-lock", - "async-net", - "async-process", - "blocking", - "futures-lite", - "once_cell", -] - -[[package]] -name = "socket2" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "spin" version = "0.9.2" @@ -1607,88 +638,18 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "standback" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" -dependencies = [ - "version_check", -] - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "serde_derive", - "syn", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2", - "quote", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" - [[package]] name = "subtle" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" -[[package]] -name = "sval" -version = "1.0.0-alpha.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45f6ee7c7b87caf59549e9fe45d6a69c75c8019e79e212a835c5da0e92f0ba08" - [[package]] name = "syn" version = "1.0.91" @@ -1712,130 +673,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "term_size" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e4129646ca0ed8f45d09b929036bafad5377103edd06e50bf574b353d2b08d9" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "term_size", - "unicode-width", -] - -[[package]] -name = "thiserror" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tide" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c459573f0dd2cc734b539047f57489ea875af8ee950860ded20cf93a79a1dee0" -dependencies = [ - "async-h1", - "async-sse", - "async-std", - "async-trait", - "futures-util", - "http-client", - "http-types", - "kv-log-macro", - "log", - "pin-project-lite 0.2.8", - "route-recognizer", - "serde", - "serde_json", -] - -[[package]] -name = "time" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "time" -version = "0.2.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" -dependencies = [ - "const_fn", - "libc", - "standback", - "stdweb", - "time-macros", - "version_check", - "winapi", -] - -[[package]] -name = "time-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] - -[[package]] -name = "time-macros-impl" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" -dependencies = [ - "proc-macro-hack", - "proc-macro2", - "quote", - "standback", - "syn", -] - -[[package]] -name = "tinyvec" -version = "1.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" - [[package]] name = "twox-hash" version = "1.6.2" @@ -1852,27 +689,6 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" -[[package]] -name = "unicode-bidi" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" - -[[package]] -name = "unicode-normalization" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-width" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" - [[package]] name = "unicode-xid" version = "0.2.2" @@ -1889,30 +705,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "url" -version = "2.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" -dependencies = [ - "form_urlencoded", - "idna", - "matches", - "percent-encoding", - "serde", -] - -[[package]] -name = "value-bag" -version = "1.0.0-alpha.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79923f7731dc61ebfba3633098bf3ac533bbd35ccd8c57e7088d9a5eebe0263f" -dependencies = [ - "ctor", - "sval", - "version_check", -] - [[package]] name = "vcell" version = "0.1.3" @@ -1925,12 +717,6 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" -[[package]] -name = "vec_map" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" - [[package]] name = "version_check" version = "0.9.4" @@ -1952,109 +738,12 @@ dependencies = [ "vcell", ] -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" - -[[package]] -name = "wasm-bindgen" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27370197c907c55e3f1a9fbe26f44e937fe6451368324e009cba39e139dc08ad" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e04185bfa3a779273da532f5025e33398409573f348985af9a1cbf3774d3f4" -dependencies = [ - "bumpalo", - "lazy_static", - "log", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f741de44b75e14c35df886aff5f1eb73aa114fa5d4d00dcd37b5e01259bf3b2" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cae7ff784d7e83a2fe7611cfe766ecf034111b49deb850a3dc7699c08251f5" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99ec0dc7a4756fffc231aab1b9f2f578d23cd391390ab27f952ae0c9b3ece20b" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d554b7f530dee5964d9a9468d95c1f8b8acae4f282807e7d27d4b03099a46744" - -[[package]] -name = "web-sys" -version = "0.3.57" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b17e741662c70c8bd24ac5c5b18de314a2c26c32bf8346ee1e6f53de919c283" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "wepoll-ffi" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" -dependencies = [ - "cc", -] - [[package]] name = "winapi" version = "0.3.9" @@ -2127,7 +816,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2392b6b94a576b4e2bf3c5b2757d63f10ada8020a2e4d08ac849ebcf6ea8e077" dependencies = [ "curve25519-dalek", - "rand_core 0.5.1", + "rand_core", "zeroize", ] @@ -2163,7 +852,7 @@ dependencies = [ "lazy_static", "openssl", "poly1305", - "rand_core 0.5.1", + "rand_core", "subtle", "x25519-dalek", ] @@ -2174,12 +863,12 @@ version = "2.0.0" dependencies = [ "base64", "dashmap", - "highway", "lazy_static", "libc", "lz4_flex", "parking_lot", "serde", + "serde_derive", "serde_json", "winapi", "zerotier-core-crypto", @@ -2189,21 +878,13 @@ dependencies = [ name = "zerotier-system-service" version = "0.1.0" dependencies = [ - "chrono", - "clap", - "colored", - "digest_auth", - "hex", + "lazy_static", "libc", - "mach", "num-traits", "num_cpus", "parking_lot", - "rand 0.7.3", "serde", "serde_json", - "smol", - "tide", "winapi", "zerotier-core-crypto", "zerotier-network-hypervisor", diff --git a/zerotier-system-service/Cargo.toml b/zerotier-system-service/Cargo.toml index 027bec424..b725db770 100644 --- a/zerotier-system-service/Cargo.toml +++ b/zerotier-system-service/Cargo.toml @@ -17,22 +17,12 @@ zerotier-network-hypervisor = { path = "../zerotier-network-hypervisor" } zerotier-core-crypto = { path = "../zerotier-core-crypto" } serde = { version = "^1", features = ["derive"], default-features = false } serde_json = { version = "^1", features = [], default-features = false } -clap = { version = "^2", features = ["suggestions", "wrap_help"] } -colored = "^2" num_cpus = "^1" parking_lot = "^0" -smol = "^1" -tide = { version = "^0", features = ["h1-server"], default-features = false } -digest_auth = "^0" -chrono = "^0" -hex = "^0" -rand = "^0" +lazy_static = "^1" [target."cfg(windows)".dependencies] winapi = { version = "^0", features = ["handleapi", "ws2ipdef", "ws2tcpip"] } [target."cfg(not(windows))".dependencies] libc = "^0" - -[target."cfg(any(target_os = \"macos\", target_os = \"ios\"))".dependencies] -mach = "^0" diff --git a/zerotier-system-service/src/store.rs b/zerotier-system-service/src/store.rs index 6db6e7687..1f9076dea 100644 --- a/zerotier-system-service/src/store.rs +++ b/zerotier-system-service/src/store.rs @@ -128,7 +128,7 @@ impl Store { if token2.is_empty() { if generate_if_missing { let mut rb = [0_u8; 32]; - unsafe { rb.fill_with(rand::random) }; + zerotier_core_crypto::random::fill_bytes_secure(&mut rb); token.reserve(rb.len()); for b in rb.iter() { if *b > 127_u8 { diff --git a/zerotier-system-service/src/utils.rs b/zerotier-system-service/src/utils.rs index 106cf7391..d3e89fa98 100644 --- a/zerotier-system-service/src/utils.rs +++ b/zerotier-system-service/src/utils.rs @@ -25,24 +25,7 @@ pub fn ms_since_epoch() -> i64 { std::time::SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis() as i64 } -#[cfg(any(target_os = "macos", target_os = "ios"))] -pub fn ms_monotonic() -> i64 { - unsafe { - let mut tb: mach::mach_time::mach_timebase_info_data_t = std::mem::zeroed(); - if mach::mach_time::mach_timebase_info(&mut tb) == 0 { - let mt = mach::mach_time::mach_continuous_approximate_time(); // ZT doesn't need it to be *that* exact, and this is faster - (((mt as u128) * tb.numer as u128 * 1000000_u128) / (tb.denom as u128)) as i64 - // milliseconds since X - } else { - panic!("FATAL: mach_timebase_info() failed"); - } - } -} - -#[cfg(not(any(target_os = "macos", target_os = "ios")))] -pub fn ms_monotonic() -> i64 { - std::time::SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis() as i64 -} +pub fn ms_monotonic() -> i64 {} pub fn parse_bool(v: &str) -> Result { if !v.is_empty() { diff --git a/zerotier-system-service/src/vnic/common.rs b/zerotier-system-service/src/vnic/common.rs index de76fe841..560afcfa7 100644 --- a/zerotier-system-service/src/vnic/common.rs +++ b/zerotier-system-service/src/vnic/common.rs @@ -43,7 +43,7 @@ pub fn get_l2_multicast_subscriptions(dev: &str) -> HashSet { if !(*i).ifma_name.is_null() && !(*i).ifma_addr.is_null() && (*(*i).ifma_addr).sa_family as i32 == libc::AF_LINK as i32 { let in_: &libc::sockaddr_dl = &*((*i).ifma_name.cast()); let la: &libc::sockaddr_dl = &*((*i).ifma_addr.cast()); - if la.sdl_alen == 6 && in_.sdl_nlen <= dev.len().as_() && crate::libc::memcmp(dev.as_ptr().cast(), in_.sdl_data.as_ptr().cast(), in_.sdl_nlen.as_()) == 0 { + if la.sdl_alen == 6 && in_.sdl_nlen <= dev.len().as_() && libc::memcmp(dev.as_ptr().cast(), in_.sdl_data.as_ptr().cast(), in_.sdl_nlen.as_()) == 0 { let mi = la.sdl_nlen as usize; MAC::from_u64((la.sdl_data[mi] as u64) << 40 | (la.sdl_data[mi + 1] as u64) << 32 | (la.sdl_data[mi + 2] as u64) << 24 | (la.sdl_data[mi + 3] as u64) << 16 | (la.sdl_data[mi + 4] as u64) << 8 | la.sdl_data[mi + 5] as u64).map(|mac| groups.insert(mac)); } diff --git a/zerotier-system-service/src/vnic/mac_feth_tap.rs b/zerotier-system-service/src/vnic/mac_feth_tap.rs index d2e585abd..84aebd9ff 100644 --- a/zerotier-system-service/src/vnic/mac_feth_tap.rs +++ b/zerotier-system-service/src/vnic/mac_feth_tap.rs @@ -31,18 +31,16 @@ */ use std::cell::Cell; -use std::collections::HashSet; -use std::error::Error; +use std::collections::{BTreeSet, HashSet}; use std::ffi::CString; use std::mem::{transmute, zeroed}; use std::os::raw::{c_char, c_int, c_short, c_uchar, c_uint, c_void}; use std::process::Command; -use std::ptr::{copy_nonoverlapping, null_mut}; -use std::sync::Mutex; +use std::ptr::copy_nonoverlapping; use std::thread::JoinHandle; use lazy_static::lazy_static; -use num_traits::cast::AsPrimitive; +use parking_lot::Mutex; use zerotier_network_hypervisor::vl1::{InetAddress, MAC}; @@ -178,6 +176,7 @@ struct in6_ifreq { */ #[allow(non_camel_case_types)] +#[derive(Clone, Copy)] #[repr(C)] struct icmp6_ifstat { ifs6_in_msg: u64, @@ -217,6 +216,7 @@ struct icmp6_ifstat { } #[allow(non_camel_case_types)] +#[derive(Clone, Copy)] #[repr(C)] struct in6_ifstat { ifs6_in_receive: u64, @@ -247,6 +247,7 @@ struct in6_ifstat { } #[allow(non_camel_case_types)] +#[derive(Clone, Copy)] #[repr(C)] struct in6_addrlifetime { ia6t_expire: libc::time_t, @@ -422,6 +423,7 @@ struct sockaddr_ndrv { */ #[allow(non_camel_case_types)] +#[derive(Clone, Copy)] #[repr(C)] struct ifkpi { ifk_module_id: c_uint, @@ -430,6 +432,7 @@ struct ifkpi { } #[allow(non_camel_case_types)] +#[derive(Clone, Copy)] #[repr(C)] struct ifdevmtu { ifdm_current: c_int, @@ -480,7 +483,7 @@ impl MacFethTap { /// given will not remain valid after it returns. Also note that F will be called /// from another thread that is spawned here, so all its bound references must /// be "Send" and "Sync" e.g. Arc<>. - pub fn new(nwid: &NetworkId, mac: &MAC, mtu: i32, metric: i32, eth_frame_func: F) -> Result { + pub fn new(nwid: u64, mac: &MAC, mtu: i32, metric: i32, eth_frame_func: F) -> Result { // This tracks BPF devices we are using so we don't try to reopen them, and also // doubles as a global lock to ensure that only one feth tap is created at once per // ZeroTier process per system. @@ -668,7 +671,7 @@ impl MacFethTap { } // Create BPF listener thread, which calls the supplied function on each incoming packet. - let t = std::thread::Builder::new().stack_size(zerotier_core::RECOMMENDED_THREAD_STACK_SIZE).spawn(move || { + let t = std::thread::Builder::new().stack_size(524288).spawn(move || { let mut buf: [u8; BPF_BUFFER_SIZE] = [0_u8; BPF_BUFFER_SIZE]; let hdr_struct_size = std::mem::size_of::() as isize; loop { @@ -808,7 +811,7 @@ impl VNIC for MacFethTap { } #[inline(always)] - fn put(&self, source_mac: &zerotier_core::MAC, dest_mac: &zerotier_core::MAC, ethertype: u16, _vlan_id: u16, data: *const u8, len: usize) -> bool { + fn put(&self, source_mac: &zerotier_network_hypervisor::vl1::MAC, dest_mac: &zerotier_network_hypervisor::vl1::MAC, ethertype: u16, _vlan_id: u16, data: *const u8, len: usize) -> bool { let dm = dest_mac.0; let sm = source_mac.0; let mut hdr: [u8; 14] = [(dm >> 40) as u8, (dm >> 32) as u8, (dm >> 24) as u8, (dm >> 16) as u8, (dm >> 8) as u8, dm as u8, (sm >> 40) as u8, (sm >> 32) as u8, (sm >> 24) as u8, (sm >> 16) as u8, (sm >> 8) as u8, sm as u8, (ethertype >> 8) as u8, ethertype as u8];