Merge pull request #1 from erikh/clean-up-build

These are some things I noticed while working in this tree:
This commit is contained in:
joseph-henry
2021-05-26 09:52:09 -07:00
committed by GitHub
8 changed files with 14 additions and 6882 deletions

2
pkg/crate/libzt/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
target
src/libzt.rs

View File

@@ -15,8 +15,7 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![allow(non_snake_case)] #![allow(non_snake_case)]
include!(concat!("./libzt.rs")); pub mod libzt;
pub mod node; pub mod node;
pub mod socket; pub mod socket;
pub mod tcp; pub mod tcp;

File diff suppressed because it is too large Load Diff

View File

@@ -15,12 +15,11 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![allow(non_snake_case)] #![allow(non_snake_case)]
include!(concat!("./libzt.rs")); use crate::libzt::*;
use std::ffi::{c_void, CStr, CString}; use std::ffi::{c_void, CStr, CString};
use std::str::FromStr;
use std::net::{IpAddr,AddrParseError};
use std::io; use std::io;
use std::net::{AddrParseError, IpAddr};
use std::str::FromStr;
extern "C" fn native_event_handler(msg: *mut c_void) { extern "C" fn native_event_handler(msg: *mut c_void) {
let event: &mut zts_event_msg_t = unsafe { &mut *(msg as *mut zts_event_msg_t) }; let event: &mut zts_event_msg_t = unsafe { &mut *(msg as *mut zts_event_msg_t) };
@@ -106,13 +105,13 @@ impl ZeroTierNode {
unsafe { zts_util_delay(interval_ms) } unsafe { zts_util_delay(interval_ms) }
} }
pub fn addr_get(&self, net_id: u64) -> Result<IpAddr,AddrParseError> { pub fn addr_get(&self, net_id: u64) -> Result<IpAddr, AddrParseError> {
unsafe { unsafe {
let mut v = vec![0; (ZTS_INET6_ADDRSTRLEN as usize) + 1]; let mut v = vec![0; (ZTS_INET6_ADDRSTRLEN as usize) + 1];
let ptr = v.as_mut_ptr() as *mut i8; let ptr = v.as_mut_ptr() as *mut i8;
zts_addr_get_str(net_id, ZTS_AF_INET, ptr, ZTS_INET6_ADDRSTRLEN); zts_addr_get_str(net_id, ZTS_AF_INET, ptr, ZTS_INET6_ADDRSTRLEN);
let c_str = CStr::from_ptr(ptr); let c_str = CStr::from_ptr(ptr);
return IpAddr::from_str(&c_str.to_string_lossy().into_owned()) return IpAddr::from_str(&c_str.to_string_lossy().into_owned());
} }
} }
} }

View File

@@ -19,6 +19,9 @@ use std::os::raw::c_int;
use std::time::Duration; use std::time::Duration;
use std::{io, mem}; use std::{io, mem};
type time_t = i64;
use crate::libzt::*;
use crate::utils::*; use crate::utils::*;
// Note: FileDesc and c_int in libc are private so we can't use that. Use i32 instead // Note: FileDesc and c_int in libc are private so we can't use that. Use i32 instead

View File

@@ -19,6 +19,7 @@ use std::os::raw::c_int;
use std::time::Duration; use std::time::Duration;
use std::{cmp, mem}; use std::{cmp, mem};
use crate::libzt::*;
use crate::socket::Socket; use crate::socket::Socket;
use crate::utils::*; use crate::utils::*;

View File

@@ -19,6 +19,7 @@ use std::os::raw::c_int;
use std::time::Duration; use std::time::Duration;
//use std::cmp; //use std::cmp;
use crate::libzt::*;
use crate::socket::Socket; use crate::socket::Socket;
use crate::utils::*; use crate::utils::*;

View File

@@ -15,8 +15,7 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![allow(non_snake_case)] #![allow(non_snake_case)]
include!(concat!("./libzt.rs")); use crate::libzt::*;
use std::ffi::c_void; use std::ffi::c_void;
use std::io::{Error, ErrorKind}; use std::io::{Error, ErrorKind};
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs}; use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};