This commit is contained in:
Christien Rioux 2023-08-27 16:39:50 -05:00
parent 8c366387eb
commit 3125c19f02
6 changed files with 94 additions and 37 deletions

3
build_docs.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
cargo doc --no-deps -p veilid-core
cargo doc --no-deps -p veilid-tools

View File

@ -12,10 +12,11 @@ crate-type = ["cdylib", "staticlib", "rlib"]
[features]
# Common features
default = ["enable-crypto-vld0"]
default = ["enable-crypto-vld0", "rt-tokio"]
rt-async-std = [
"async-std",
"async-std-resolver",
"trust-dns-resolver",
"async_executors/async_std",
"rtnetlink/smol_socket",
"veilid-tools/rt-async-std",
@ -52,7 +53,9 @@ network-result-extra = ["veilid-tools/network-result-extra"]
[dependencies]
# Tools
veilid-tools = { path = "../veilid-tools", features = ["tracing"] }
veilid-tools = { path = "../veilid-tools", features = [
"tracing",
], default-features = false }
paste = "1.0.14"
once_cell = "1.18.0"
owning_ref = "0.4.1"

View File

@ -18,6 +18,7 @@ cfg_if! {
cfg_if! {
if #[cfg(feature="rt-async-std")] {
use async_std_resolver::{config, resolver, resolver_from_system_conf, AsyncStdResolver as AsyncResolver};
use trust_dns_resolver::error::ResolveErrorKind;
} else if #[cfg(feature="rt-tokio")] {
use trust_dns_resolver::{config, TokioAsyncResolver as AsyncResolver, error::ResolveError, error::ResolveErrorKind};

View File

@ -132,6 +132,30 @@ impl Network {
}
};
#[cfg(all(feature = "rt-async-std", unix))]
{
// async-std does not directly support linger on tcpsocket yet
use std::os::fd::AsRawFd;
use std::os::fd::FromRawFd;
if let Err(e) = unsafe { socket2::Socket::from_raw_fd(tcp_stream.as_raw_fd()) }
.set_linger(Some(core::time::Duration::from_secs(0)))
{
log_net!(debug "Couldn't set TCP linger: {}", e);
return;
}
}
#[cfg(all(feature = "rt-async-std", windows))]
{
// async-std does not directly support linger on tcpsocket yet
use std::os::windows::io::AsRawSocket;
if let Err(e) = unsafe { socket2::socket_from_raw(tcp_stream.as_raw_socket()) }
.set_linger(Some(core::time::Duration::from_secs(0)))
{
log_net!(debug "Couldn't set TCP linger: {}", e);
return;
}
}
#[cfg(not(feature = "rt-async-std"))]
if let Err(e) = tcp_stream.set_linger(Some(core::time::Duration::from_secs(0))) {
log_net!(debug "Couldn't set TCP linger: {}", e);
return;

View File

@ -19,7 +19,7 @@ use clap::{Args, Parser};
use server::*;
use settings::LogLevel;
use std::collections::HashMap;
use std::ffi::{OsString, OsStr};
use std::ffi::{OsStr, OsString};
use std::path::Path;
use std::str::FromStr;
use tools::*;
@ -40,7 +40,6 @@ pub struct Logging {
#[derive(Parser, Debug, Clone)]
#[command(author, version, about)]
pub struct CmdlineArgs {
/// Run in daemon mode in the background
#[arg(short, long)]
daemon: bool,
@ -92,7 +91,7 @@ pub struct CmdlineArgs {
/// Set the node ids and secret keys
///
/// Specify node ids in typed key set format ('[VLD0:xxxx,VLD1:xxxx]') on the command line, a prompt appears to enter the secret key set interactively.
/// Specify node ids in typed key set format ('\[VLD0:xxxx,VLD1:xxxx\]') on the command line, a prompt appears to enter the secret key set interactively.
#[arg(long, value_name = "key_set")]
set_node_id: Option<String>,
@ -156,7 +155,7 @@ fn main() -> EyreResult<()> {
// Check for one-off commands
#[cfg(debug_assertions)]
if args.wait_for_debug{
if args.wait_for_debug {
use bugsalot::debugger;
debugger::wait_until_attached(None).expect("state() not implemented on this platform");
}
@ -204,7 +203,9 @@ fn main() -> EyreResult<()> {
println!("Enabling OTLP tracing");
settingsrw.logging.otlp.enabled = true;
settingsrw.logging.otlp.grpc_endpoint = NamedSocketAddrs::from_str(
args.otlp.expect("should not be null because of default missing value").as_str(),
args.otlp
.expect("should not be null because of default missing value")
.as_str(),
)
.wrap_err("failed to parse OTLP address")?;
settingsrw.logging.otlp.level = LogLevel::Trace;
@ -222,10 +223,16 @@ fn main() -> EyreResult<()> {
settingsrw.core.table_store.delete = true;
}
if let Some(password) = args.password {
settingsrw.core.protected_store.device_encryption_key_password = password;
settingsrw
.core
.protected_store
.device_encryption_key_password = password;
}
if let Some(new_password) = args.new_password {
settingsrw.core.protected_store.new_device_encryption_key_password = Some(new_password);
settingsrw
.core
.protected_store
.new_device_encryption_key_password = Some(new_password);
}
if let Some(network_key) = args.network_key {
settingsrw.core.network.network_key_password = Some(network_key);
@ -241,8 +248,8 @@ fn main() -> EyreResult<()> {
settingsrw.logging.terminal.enabled = false;
// Split or get secret
let tks =
TypedKeyGroup::from_str(&key_set).wrap_err("failed to decode node id set from command line")?;
let tks = TypedKeyGroup::from_str(&key_set)
.wrap_err("failed to decode node id set from command line")?;
let buffer = rpassword::prompt_password("Enter secret key set (will not echo): ")
.wrap_err("invalid secret key")?;
@ -299,8 +306,8 @@ fn main() -> EyreResult<()> {
let mut tks = veilid_core::TypedKeyGroup::new();
let mut tss = veilid_core::TypedSecretGroup::new();
for ck in veilid_core::VALID_CRYPTO_KINDS {
let tkp = veilid_core::Crypto::generate_keypair(ck)
.wrap_err("invalid crypto kind")?;
let tkp =
veilid_core::Crypto::generate_keypair(ck).wrap_err("invalid crypto kind")?;
tks.add(veilid_core::TypedKey::new(tkp.kind, tkp.value.key));
tss.add(veilid_core::TypedSecret::new(tkp.kind, tkp.value.secret));
}
@ -312,8 +319,7 @@ fn main() -> EyreResult<()> {
} else {
let ck: veilid_core::CryptoKind =
veilid_core::FourCC::from_str(&ckstr).wrap_err("couldn't parse crypto kind")?;
let tkp =
veilid_core::Crypto::generate_keypair(ck).wrap_err("invalid crypto kind")?;
let tkp = veilid_core::Crypto::generate_keypair(ck).wrap_err("invalid crypto kind")?;
println!("{}", tkp.to_string());
}
return Ok(());

View File

@ -7,29 +7,40 @@ edition = "2021"
[lib]
# staticlib for iOS tests, cydlib for android tests, rlib for everything else
crate-type = [ "cdylib", "staticlib", "rlib" ]
crate-type = ["cdylib", "staticlib", "rlib"]
[features]
default = []
rt-async-std = [ "async-std", "async_executors/async_std" ]
rt-tokio = [ "tokio", "tokio-util", "async_executors/tokio_tp", "async_executors/tokio_io", "async_executors/tokio_timer" ]
rt-wasm-bindgen = [ "async_executors/bindgen", "async_executors/timer"]
default = ["rt-tokio"]
rt-async-std = ["async-std", "async_executors/async_std"]
rt-tokio = [
"tokio",
"tokio-util",
"async_executors/tokio_tp",
"async_executors/tokio_io",
"async_executors/tokio_timer",
]
rt-wasm-bindgen = ["async_executors/bindgen", "async_executors/timer"]
veilid_tools_android_tests = [ "dep:paranoid-android" ]
veilid_tools_ios_tests = [ "dep:oslog", "dep:tracing-oslog" ]
tracing = [ "dep:tracing", "dep:tracing-subscriber" ]
veilid_tools_android_tests = ["dep:paranoid-android"]
veilid_tools_ios_tests = ["dep:oslog", "dep:tracing-oslog"]
tracing = ["dep:tracing", "dep:tracing-subscriber"]
network-result-extra = []
network-result-info = []
[dependencies]
tracing = { version = "0.1.37", features = ["log", "attributes"], optional = true }
tracing = { version = "0.1.37", features = [
"log",
"attributes",
], optional = true }
tracing-subscriber = { version = "0.3.17", optional = true }
log = { version = "0.4.20" }
eyre = "0.6.8"
static_assertions = "1.1.0"
cfg-if = "1.0.0"
thiserror = "1.0.47"
futures-util = { version = "0.3.28", default_features = false, features = ["alloc"] }
futures-util = { version = "0.3.28", default_features = false, features = [
"alloc",
] }
parking_lot = "0.12.1"
once_cell = "1.18.0"
stop-token = { version = "0.7.0", default-features = false }
@ -43,10 +54,15 @@ flume = { version = "0.11.0", features = ["async"] }
# Dependencies for native builds only
# Linux, Windows, Mac, iOS, Android
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
async-std = { version = "1.12.0", features = ["unstable"], optional = true}
tokio = { version = "1.32.0", features = ["full"], optional = true}
tokio-util = { version = "0.7.8", features = ["compat"], optional = true}
futures-util = { version = "0.3.28", default-features = false, features = ["async-await", "sink", "std", "io"] }
async-std = { version = "1.12.0", features = ["unstable"], optional = true }
tokio = { version = "1.32.0", features = ["full"], optional = true }
tokio-util = { version = "0.7.8", features = ["compat"], optional = true }
futures-util = { version = "0.3.28", default-features = false, features = [
"async-await",
"sink",
"std",
"io",
] }
chrono = "0.4.26"
libc = "0.2.147"
@ -57,7 +73,7 @@ nix = "0.26.2"
wasm-bindgen = "0.2.87"
js-sys = "0.3.64"
wasm-bindgen-futures = "0.4.37"
async_executors = { version = "0.7.0", default-features = false}
async_executors = { version = "0.7.0", default-features = false }
async-lock = "2.8.0"
send_wrapper = { version = "0.6.0", features = ["futures"] }
@ -85,7 +101,7 @@ tracing-oslog = { version = "0.1.2", optional = true }
[dev-dependencies]
serial_test = "^2.0.0"
simplelog = { version = "0.12.1", features = [ "test" ] }
simplelog = { version = "0.12.1", features = ["test"] }
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
console_error_panic_hook = "0.1.7"
@ -100,6 +116,10 @@ tracing-wasm = { version = "0.2.1" }
wasm-opt = ["-O", "--enable-mutable-globals"]
[package.metadata.ios]
build_targets = ["aarch64-apple-ios", "aarch64-apple-ios-sim", "x86_64-apple-ios"]
build_targets = [
"aarch64-apple-ios",
"aarch64-apple-ios-sim",
"x86_64-apple-ios",
]
deployment_target = "12.0"
build_id_prefix = "com.veilid.veilidtools"