mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-03 19:13:43 +02:00
First of the cert commands, and fix a Mac build error.
This commit is contained in:
parent
5d75ca0e30
commit
8b945a0e51
9 changed files with 61 additions and 9 deletions
18
rust-zerotier-core/Cargo.lock
generated
18
rust-zerotier-core/Cargo.lock
generated
|
@ -6,6 +6,22 @@ version = "1.0.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
|
||||
|
||||
[[package]]
|
||||
name = "base64-serde"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e964e3e0a930303c7c0bdb28ebf691dd98d9eee4b8b68019d2c995710b58a18"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.4.2"
|
||||
|
@ -114,6 +130,8 @@ checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
|||
name = "zerotier-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64-serde",
|
||||
"hex",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
|
|
|
@ -11,3 +11,5 @@ num-derive = "0.3"
|
|||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
hex = "0.4"
|
||||
base64-serde = "0"
|
||||
base64 = "0"
|
||||
|
|
|
@ -126,7 +126,9 @@ impl<'de> serde::Deserialize<'de> for CertificateUniqueIdType {
|
|||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct CertificateSubjectUniqueIdSecret {
|
||||
#[serde(with = "Base64Standard")]
|
||||
pub public: Vec<u8>,
|
||||
#[serde(with = "Base64Standard")]
|
||||
pub private: Vec<u8>,
|
||||
#[serde(rename = "type")]
|
||||
pub type_: CertificateUniqueIdType,
|
||||
|
@ -385,8 +387,10 @@ pub struct CertificateSubject {
|
|||
#[serde(rename = "updateURLs")]
|
||||
pub update_urls: Vec<String>,
|
||||
pub name: CertificateName,
|
||||
#[serde(with = "Base64Standard")]
|
||||
#[serde(rename = "uniqueId")]
|
||||
pub unique_id: Vec<u8>,
|
||||
#[serde(with = "Base64Standard")]
|
||||
#[serde(rename = "uniqueIdProofSignature")]
|
||||
pub unique_id_proof_signature: Vec<u8>,
|
||||
}
|
||||
|
@ -571,6 +575,7 @@ pub struct Certificate {
|
|||
pub extended_attributes: Vec<u8>,
|
||||
#[serde(rename = "maxPathLength")]
|
||||
pub max_path_length: u32,
|
||||
#[serde(with = "Base64Standard")]
|
||||
pub signature: Vec<u8>,
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
use std::os::raw::{c_char, c_int};
|
||||
use num_derive::{FromPrimitive, ToPrimitive};
|
||||
#[macro_use] extern crate base64_serde;
|
||||
|
||||
#[allow(non_snake_case,non_upper_case_globals,non_camel_case_types,dead_code,improper_ctypes)]
|
||||
mod capi; // bindgen generated
|
||||
|
@ -56,6 +57,8 @@ pub use virtualnetworkconfig::*;
|
|||
pub use multicastgroup::MulticastGroup;
|
||||
pub use dictionary::*;
|
||||
|
||||
base64_serde_type!(Base64Standard, base64::URL_SAFE_NO_PAD);
|
||||
|
||||
/// Recommended minimum thread stack size for background threads.
|
||||
pub const RECOMMENDED_THREAD_STACK_SIZE: usize = 262144;
|
||||
|
||||
|
@ -206,7 +209,6 @@ macro_rules! implement_to_from_json {
|
|||
}
|
||||
Ok(r.unwrap())
|
||||
}
|
||||
|
||||
pub fn to_json(&self) -> String {
|
||||
serde_json::to_string_pretty(self).unwrap()
|
||||
}
|
||||
|
@ -222,7 +224,6 @@ macro_rules! enum_str {
|
|||
enum $name {
|
||||
$($variant = $val),*
|
||||
}
|
||||
|
||||
impl $name {
|
||||
fn name(&self) -> &'static str {
|
||||
match self {
|
||||
|
|
18
rust-zerotier-service/Cargo.lock
generated
18
rust-zerotier-service/Cargo.lock
generated
|
@ -26,6 +26,22 @@ version = "1.0.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
|
||||
|
||||
[[package]]
|
||||
name = "base64-serde"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e964e3e0a930303c7c0bdb28ebf691dd98d9eee4b8b68019d2c995710b58a18"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.2.1"
|
||||
|
@ -816,6 +832,8 @@ checksum = "45af6a010d13e4cf5b54c94ba5a2b2eba5596b9e46bf5875612d332a1f2b3f86"
|
|||
name = "zerotier-core"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"base64-serde",
|
||||
"hex",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
|
|
|
@ -44,6 +44,11 @@ fn newsid<'a>(store: &Store, cli_args: Option<&ArgMatches<'a>>, auth_token: &Opt
|
|||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn newcsr<'a>(store: &Store, cli_args: &ArgMatches<'a>, auth_token: &Option<String>) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn sign<'a>(store: &Store, cli_args: &ArgMatches<'a>, auth_token: &Option<String>) -> i32 {
|
||||
0
|
||||
|
|
|
@ -61,10 +61,6 @@ fn main() {
|
|||
std::process::exit(1);
|
||||
}
|
||||
let store = Arc::new(store.unwrap());
|
||||
if store.write_pid().is_err() {
|
||||
eprintln!("FATAL: error writing to directory '{}': unable to write zerotier.pid", zerotier_path);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
// From this point on we shouldn't call std::process::exit() since that would
|
||||
// fail to erase zerotier.pid from the working directory.
|
||||
|
@ -116,6 +112,5 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
store.erase_pid();
|
||||
std::process::exit(process_exit_value);
|
||||
}
|
||||
|
|
|
@ -415,6 +415,11 @@ async fn run_async(store: &Arc<Store>, auth_token: String, log: &Arc<Log>, local
|
|||
}
|
||||
|
||||
pub(crate) fn run(store: &Arc<Store>, auth_token: Option<String>) -> i32 {
|
||||
if store.write_pid().is_err() {
|
||||
eprintln!("FATAL: error writing to directory '{}': unable to write zerotier.pid", store.base_path.to_str().unwrap());
|
||||
return 1;
|
||||
}
|
||||
|
||||
let local_config = Arc::new(store.read_local_conf(false).unwrap_or_else(|_| { LocalConfig::default() }));
|
||||
|
||||
let log = Arc::new(Log::new(
|
||||
|
@ -457,5 +462,7 @@ pub(crate) fn run(store: &Arc<Store>, auth_token: Option<String>) -> i32 {
|
|||
let process_exit_value = rt.block_on(async move { run_async(store, auth_token, &log, local_config).await });
|
||||
rt.shutdown_timeout(Duration::from_millis(500));
|
||||
|
||||
store.erase_pid();
|
||||
|
||||
process_exit_value
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ use std::collections::BTreeSet;
|
|||
use std::ptr::null_mut;
|
||||
|
||||
use zerotier_core::{MAC, MulticastGroup};
|
||||
use num_traits::cast::AsPrimitive;
|
||||
|
||||
use crate::osdep as osdep;
|
||||
|
||||
|
@ -28,10 +29,10 @@ pub(crate) fn bsd_get_multicast_groups(dev: &str) -> BTreeSet<MulticastGroup> {
|
|||
if osdep::getifmaddrs(&mut maddrs as *mut *mut osdep::ifmaddrs) == 0 {
|
||||
let mut i = maddrs;
|
||||
while !i.is_null() {
|
||||
if !(*i).ifma_name.is_null() && !(*i).ifma_addr.is_null() && (*(*i).ifma_addr).sa_family == osdep::AF_LINK as osdep::sa_family_t {
|
||||
if !(*i).ifma_name.is_null() && !(*i).ifma_addr.is_null() && (*(*i).ifma_addr).sa_family as i32 == osdep::AF_LINK as i32 {
|
||||
let in_: &osdep::sockaddr_dl = &*((*i).ifma_name.cast());
|
||||
let la: &osdep::sockaddr_dl = &*((*i).ifma_addr.cast());
|
||||
if la.sdl_alen == 6 && in_.sdl_nlen <= dev.len() as osdep::u_char && osdep::memcmp(dev.as_ptr().cast(), in_.sdl_data.as_ptr().cast(), in_.sdl_nlen as c_ulong) == 0 {
|
||||
if la.sdl_alen == 6 && in_.sdl_nlen <= dev.len().as_() && osdep::memcmp(dev.as_ptr().cast(), in_.sdl_data.as_ptr().cast(), in_.sdl_nlen.as_()) == 0 {
|
||||
let mi = la.sdl_nlen as usize;
|
||||
groups.insert(MulticastGroup{
|
||||
mac: MAC((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),
|
||||
|
|
Loading…
Add table
Reference in a new issue