From e31aa84db058e018a661a74bf1a86b41242e3f30 Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 2 Jul 2022 11:41:25 -0400 Subject: [PATCH] cli fix --- Cargo.lock | 47 +++++-------------- veilid-cli/Cargo.toml | 11 ++--- veilid-cli/src/main.rs | 1 + veilid-cli/src/settings.rs | 2 +- veilid-cli/src/ui.rs | 32 +++---------- .../native/utils/network_interfaces/mod.rs | 1 - veilid-core/src/xx/tools.rs | 12 ++--- veilid-server/src/windows.rs | 3 +- 8 files changed, 32 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5cedf7e3..1de11e28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -369,7 +369,7 @@ dependencies = [ "futures-io", "futures-util", "log", - "pin-project 0.4.29", + "pin-project 0.4.30", "tungstenite 0.11.1", ] @@ -1217,10 +1217,8 @@ dependencies = [ "lazy_static", "libc", "log", - "maplit", - "ncurses", "signal-hook", - "term_size", + "tokio", "unicode-segmentation", "unicode-width", ] @@ -1265,6 +1263,7 @@ dependencies = [ "num 0.4.0", "owning_ref", "time 0.3.11", + "tokio", "toml", "unicode-segmentation", "unicode-width", @@ -2641,17 +2640,6 @@ dependencies = [ "socket2", ] -[[package]] -name = "ncurses" -version = "5.101.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e2c5d34d72657dc4b638a1c25d40aae81e4f1c699062f72f467237920752032" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "ndk" version = "0.6.0" @@ -3273,11 +3261,11 @@ dependencies = [ [[package]] name = "pin-project" -version = "0.4.29" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9615c18d31137579e9ff063499264ddc1278e7b1982757ebc111028c4d1dc909" +checksum = "3ef0f924a5ee7ea9cbcea77529dba45f8a9ba9f622419fe3386ca581a3ae9d5a" dependencies = [ - "pin-project-internal 0.4.29", + "pin-project-internal 0.4.30", ] [[package]] @@ -3291,9 +3279,9 @@ dependencies = [ [[package]] name = "pin-project-internal" -version = "0.4.29" +version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "044964427019eed9d49d9d5bbce6047ef18f37100ea400912a9fa4a3523ab12a" +checksum = "851c8d0ce9bebe43790dedfc86614c23494ac9f423dd618d3a61fc693eafe61e" dependencies = [ "proc-macro2", "quote", @@ -4348,16 +4336,6 @@ dependencies = [ "winapi", ] -[[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 = "termcolor" version = "1.1.3" @@ -4549,6 +4527,7 @@ checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" dependencies = [ "bytes 1.1.0", "futures-core", + "futures-io", "futures-sink", "pin-project-lite", "tokio", @@ -5004,7 +4983,7 @@ dependencies = [ "flexi_logger", "futures", "log", - "parking_lot 0.12.1", + "parking_lot 0.11.2", "serde", "serde_derive", "serial_test", @@ -5090,7 +5069,7 @@ dependencies = [ "thiserror", "tokio", "tokio-stream", - "tokio-util 0.6.10", + "tokio-util 0.7.3", "tracing", "tracing-error", "tracing-subscriber", @@ -5131,7 +5110,7 @@ dependencies = [ "serde_json", "tokio", "tokio-stream", - "tokio-util 0.6.10", + "tokio-util 0.7.3", "tracing", "tracing-opentelemetry", "tracing-subscriber", @@ -5174,7 +5153,7 @@ dependencies = [ "stop-token", "tokio", "tokio-stream", - "tokio-util 0.6.10", + "tokio-util 0.7.3", "tracing", "tracing-appender", "tracing-journald", diff --git a/veilid-cli/Cargo.toml b/veilid-cli/Cargo.toml index dd7f24c4..1162b14c 100644 --- a/veilid-cli/Cargo.toml +++ b/veilid-cli/Cargo.toml @@ -12,16 +12,11 @@ path = "src/main.rs" [features] default = [ "rt-tokio" ] -rt-async-std = [ "async-std", "veilid-core/rt-async-std" ] -rt-tokio = [ "tokio", "tokio-util", "veilid-core/rt-tokio" ] - -[target.'cfg(unix)'.dependencies] -cursive = { path = "../external/cursive/cursive", default-features = false, features = ["ncurses-backend", "toml", "rt-async-std"]} - -[target.'cfg(not(unix))'.dependencies] -cursive = { path = "../external/cursive/cursive", default-features = false, features = ["crossterm-backend", "toml", "rt-async-std"]} +rt-async-std = [ "async-std", "veilid-core/rt-async-std", "cursive/rt-async-std" ] +rt-tokio = [ "tokio", "tokio-util", "veilid-core/rt-tokio", "cursive/rt-tokio" ] [dependencies] +cursive = { path = "../external/cursive/cursive", default-features = false, features = [ "crossterm", "toml"]} async-std = { version = "^1.9", features = ["unstable", "attributes"], optional = true } tokio = { version = "^1", features = ["full"], optional = true } tokio-util = { version = "^0", features = ["compat"], optional = true} diff --git a/veilid-cli/src/main.rs b/veilid-cli/src/main.rs index e7da7048..2531dc1f 100644 --- a/veilid-cli/src/main.rs +++ b/veilid-cli/src/main.rs @@ -104,6 +104,7 @@ fn main() -> Result<(), String> { specbuilder.module("cursive", LevelFilter::Off); specbuilder.module("cursive_core", LevelFilter::Off); specbuilder.module("cursive_buffered_backend", LevelFilter::Off); + specbuilder.module("tokio_util", LevelFilter::Off); specbuilder.module("mio", LevelFilter::Off); specbuilder.module("async_std", LevelFilter::Off); specbuilder.module("async_io", LevelFilter::Off); diff --git a/veilid-cli/src/settings.rs b/veilid-cli/src/settings.rs index d75a64da..a5382ea0 100644 --- a/veilid-cli/src/settings.rs +++ b/veilid-cli/src/settings.rs @@ -16,7 +16,7 @@ logging: enabled: false file: enabled: true - directory: "%LOGGING_FILE_DIRECTORY%" + directory: '%LOGGING_FILE_DIRECTORY%' append: true interface: node_log: diff --git a/veilid-cli/src/ui.rs b/veilid-cli/src/ui.rs index 62365927..686e3eaf 100644 --- a/veilid-cli/src/ui.rs +++ b/veilid-cli/src/ui.rs @@ -649,31 +649,13 @@ impl UI { cursive_flexi_logger_view::resize(node_log_scrollback); // Instantiate the cursive runnable - let runnable; - cfg_if::cfg_if! { - if #[cfg(unix)] { - runnable = CursiveRunnable::new( - || -> Result, Box> { - let ncurses_backend = cursive::backends::curses::n::Backend::init().unwrap(); - let buffered_backend = - cursive_buffered_backend::BufferedBackend::new(ncurses_backend); - - Ok(Box::new(buffered_backend)) - }, - ); - } else { - runnable = CursiveRunnable::new( - || -> Result, Box> { - let crossterm_backend = cursive::backends::crossterm::Backend::init().unwrap(); - let buffered_backend = - cursive_buffered_backend::BufferedBackend::new(crossterm_backend); - - Ok(Box::new(buffered_backend)) - }, - ); - } - } - //let runnable = cursive::default(); + let runnable = CursiveRunnable::new( + || -> Result, Box> { + let backend = cursive::backends::crossterm::Backend::init().unwrap(); + let buffered_backend = cursive_buffered_backend::BufferedBackend::new(backend); + Ok(Box::new(buffered_backend)) + }, + ); // Make the callback mechanism easily reachable let cb_sink = runnable.cb_sink().clone(); diff --git a/veilid-core/src/intf/native/utils/network_interfaces/mod.rs b/veilid-core/src/intf/native/utils/network_interfaces/mod.rs index 9219fec4..8dee7aae 100644 --- a/veilid-core/src/intf/native/utils/network_interfaces/mod.rs +++ b/veilid-core/src/intf/native/utils/network_interfaces/mod.rs @@ -1,5 +1,4 @@ use crate::xx::*; -use crate::*; use core::fmt; mod tools; diff --git a/veilid-core/src/xx/tools.rs b/veilid-core/src/xx/tools.rs index 05f17335..8a267020 100644 --- a/veilid-core/src/xx/tools.rs +++ b/veilid-core/src/xx/tools.rs @@ -205,8 +205,8 @@ cfg_if::cfg_if! { Ok(()) } } else if #[cfg(windows)] { - use std::os::windows::fs::MetadataExt; - use windows_permissions::*; + //use std::os::windows::fs::MetadataExt; + //use windows_permissions::*; pub fn ensure_file_private_owner>(path: P) -> Result<(),String> { @@ -217,11 +217,11 @@ cfg_if::cfg_if! { // let uid = Uid::effective(); // let gid = Gid::effective(); - let meta = std::fs::metadata(path).map_err(|e| format!("unable to get metadata for path '{:?}': {}",path, e))?; + //let meta = std::fs::metadata(path).map_err(|e| format!("unable to get metadata for path '{:?}': {}",path, e))?; - if meta.mode() != 0o600 { - std::fs::set_permissions(path,std::fs::Permissions::from_mode(0o600)).map_err(|e| format!("unable to set correct permissions on path '{:?}': {}", path, e))?; - } + //if meta.mode() != 0o600 { + // std::fs::set_permissions(path,std::fs::Permissions::from_mode(0o600)).map_err(|e| format!("unable to set correct permissions on path '{:?}': {}", path, e))?; + //} //if meta.uid() != uid.as_raw() || meta.gid() != gid.as_raw() { // chown(path, Some(uid), Some(gid)).map_err(|e| format!("unable to set correct owner on path '{:?}': {}", path, e))?; diff --git a/veilid-server/src/windows.rs b/veilid-server/src/windows.rs index 19e28ea2..e0000e6a 100644 --- a/veilid-server/src/windows.rs +++ b/veilid-server/src/windows.rs @@ -1,9 +1,8 @@ use crate::settings::*; -use crate::tools::*; use clap::ArgMatches; -use log::*; use std::ffi::OsString; use std::time::Duration; +use tracing::*; use windows_service::service::{ ServiceControl, ServiceControlAccept, ServiceExitCode, ServiceState, ServiceStatus, ServiceType, };