Build fixes and a fix to the UDP socket implementation.

This commit is contained in:
Adam Ierymenko 2021-11-03 12:09:26 -04:00
parent 7318a188b2
commit 6c504af012
No known key found for this signature in database
GPG key ID: C8877CF2D7A5D7F3
5 changed files with 27 additions and 11 deletions

View file

@ -2,6 +2,8 @@
name = "zerotier-core-crypto" name = "zerotier-core-crypto"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
license = "MPL-2.0"
authors = ["ZeroTier, Inc. <contact@zerotier.com>", "Adam Ierymenko <adam.ierymenko@zerotier.com>"]
[dependencies] [dependencies]
rand_core = "0.5" rand_core = "0.5"

View file

@ -2,6 +2,8 @@
name = "zerotier-network-hypervisor" name = "zerotier-network-hypervisor"
version = "2.0.0" version = "2.0.0"
edition = "2018" edition = "2018"
license = "MPL-2.0"
authors = ["ZeroTier, Inc. <contact@zerotier.com>", "Adam Ierymenko <adam.ierymenko@zerotier.com>"]
[profile.release] [profile.release]
lto = true lto = true

View file

@ -330,11 +330,17 @@ impl<const L: usize> Buffer<L> {
/// Get the next variable length integer and advance the cursor by its length in bytes. /// Get the next variable length integer and advance the cursor by its length in bytes.
#[inline(always)] #[inline(always)]
pub fn read_varint(&self, cursor: &mut usize) -> std::io::Result<u64> { pub fn read_varint(&self, cursor: &mut usize) -> std::io::Result<u64> {
let mut a = &self.1[*cursor..]; let c = *cursor;
crate::util::varint::read(&mut a).map(|r| { if c < self.0 {
*cursor += r.1; let mut a = &self.1[c..];
r.0 crate::util::varint::read(&mut a).map(|r| {
}) *cursor = c + r.1;
debug_assert!(*cursor < self.0);
r.0
})
} else {
Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, OVERFLOW_ERR_MSG))
}
} }
/// Get the next u8 and advance the cursor. /// Get the next u8 and advance the cursor.

View file

@ -1,8 +1,9 @@
[package] [package]
name = "zerotier-system-service" name = "zerotier-system-service"
version = "0.1.0" version = "0.1.0"
authors = ["Adam Ierymenko <adam.ierymenko@zerotier.com>"] authors = ["ZeroTier, Inc. <contact@zerotier.com>", "Adam Ierymenko <adam.ierymenko@zerotier.com>"]
edition = "2018" edition = "2018"
license = "MPL-2.0"
[profile.release] [profile.release]
opt-level = 'z' opt-level = 'z'
@ -13,16 +14,16 @@ panic = 'abort'
[dependencies] [dependencies]
zerotier-network-hypervisor = { path = "../zerotier-network-hypervisor" } zerotier-network-hypervisor = { path = "../zerotier-network-hypervisor" }
num_cpus = "^1" num_cpus = "^1"
tokio = { version = "1", features = ["rt", "net", "time", "signal", "macros"] } tokio = { version = "^1", features = ["rt", "net", "time", "signal", "macros"] }
serde = { version = "1", features = ["derive"] } serde = { version = "^1", features = ["derive"] }
serde_json = "^1" serde_json = "^1"
futures = "0" futures = "^0"
clap = { version = "2", features = ["suggestions", "wrap_help"] } clap = { version = "^2", features = ["suggestions", "wrap_help"] }
chrono = "^0" chrono = "^0"
lazy_static = "^1" lazy_static = "^1"
num-traits = "^0" num-traits = "^0"
num-derive = "^0" num-derive = "^0"
hyper = { version = "0", features = ["http1", "runtime", "server", "client", "tcp", "stream"] } hyper = { version = "^0", features = ["http1", "runtime", "server", "client", "tcp", "stream"] }
socket2 = { version = "^0", features = ["reuseport", "unix", "pair"] } socket2 = { version = "^0", features = ["reuseport", "unix", "pair"] }
dialoguer = "^0" dialoguer = "^0"
digest_auth = "^0" digest_auth = "^0"

View file

@ -48,8 +48,13 @@ fn bind_udp_socket(_device_name: &str, address: &InetAddress) -> Result<FastUDPR
fl = 1; fl = 1;
setsockopt_results |= libc::setsockopt(s, libc::SOL_SOCKET.as_(), libc::SO_REUSEPORT.as_(), (&mut fl as *mut c_int).cast(), fl_size); setsockopt_results |= libc::setsockopt(s, libc::SOL_SOCKET.as_(), libc::SO_REUSEPORT.as_(), (&mut fl as *mut c_int).cast(), fl_size);
fl = 0;
setsockopt_results |= libc::setsockopt(s, libc::SOL_SOCKET.as_(), libc::SO_LINGER.as_(), (&mut fl as *mut c_int).cast(), fl_size);
//fl = 1; //fl = 1;
//setsockopt_results |= libc::setsockopt(s, libc::SOL_SOCKET, libc::SO_REUSEADDR, (&mut fl as *mut c_int).cast(), fl_size); //setsockopt_results |= libc::setsockopt(s, libc::SOL_SOCKET, libc::SO_REUSEADDR, (&mut fl as *mut c_int).cast(), fl_size);
fl = 1; fl = 1;
setsockopt_results |= libc::setsockopt(s, libc::SOL_SOCKET.as_(), libc::SO_BROADCAST.as_(), (&mut fl as *mut c_int).cast(), fl_size); setsockopt_results |= libc::setsockopt(s, libc::SOL_SOCKET.as_(), libc::SO_BROADCAST.as_(), (&mut fl as *mut c_int).cast(), fl_size);
if af == libc::AF_INET6 { if af == libc::AF_INET6 {