This commit is contained in:
Kai Renken
2023-10-01 23:28:16 +02:00
230 changed files with 16696 additions and 4996 deletions

View File

@@ -1,7 +1,7 @@
[package]
# --- Bumpversion match - do not reorder
name = "veilid-cli"
version = "0.2.1"
version = "0.2.3"
# ---
authors = ["Veilid Team <contact@veilid.com>"]
edition = "2021"
@@ -21,13 +21,13 @@ rt-async-std = [
rt-tokio = ["tokio", "tokio-util", "veilid-tools/rt-tokio", "cursive/rt-tokio"]
[dependencies]
async-std = { version = "^1.9", features = [
async-std = { version = "^1.12", features = [
"unstable",
"attributes",
], optional = true }
tokio = { version = "^1", features = ["full"], optional = true }
tokio-util = { version = "^0", features = ["compat"], optional = true }
async-tungstenite = { version = "^0.8" }
async-tungstenite = { version = "^0.23" }
cursive = { git = "https://gitlab.com/veilid/cursive.git", default-features = false, features = [
"crossterm",
"toml",
@@ -38,10 +38,10 @@ cursive_buffered_backend = { git = "https://gitlab.com/veilid/cursive-buffered-b
# cursive-multiplex = "0.6.0"
# cursive_tree_view = "0.6.0"
cursive_table_view = "0.14.0"
arboard = "3.2.0"
arboard = "3.2.1"
# cursive-tabs = "0.5.0"
clap = { version = "4", features = ["derive"] }
directories = "^4"
directories = "^5"
log = "^0"
futures = "^0"
serde = "^1"
@@ -54,7 +54,7 @@ flexi_logger = { version = "^0", features = ["use_chrono_for_offset"] }
thiserror = "^1"
crossbeam-channel = "^0"
hex = "^0"
veilid-tools = { version = "0.2.0", path = "../veilid-tools" }
veilid-tools = { version = "0.2.3", path = "../veilid-tools" }
json = "^0"
stop-token = { version = "^0", default-features = false }
@@ -65,4 +65,4 @@ indent = { version = "0.1.1" }
chrono = "0.4.26"
[dev-dependencies]
serial_test = "^0"
serial_test = "^2"

View File

@@ -76,7 +76,6 @@ impl ClientApiConnection {
};
if let Err(e) = reply_channel.send_async(response).await {
error!("failed to process reply: {}", e);
return;
}
}

View File

@@ -248,7 +248,6 @@ Server Debug Commands:
_ => {
ui.add_node_event(Level::Error, format!("unknown flag: {}", flag));
ui.send_callback(callback);
return;
}
}
});
@@ -271,7 +270,6 @@ Server Debug Commands:
_ => {
ui.add_node_event(Level::Error, format!("unknown flag: {}", flag));
ui.send_callback(callback);
return;
}
}
});
@@ -399,12 +397,12 @@ Server Debug Commands:
}
pub fn update_route(&self, route: &json::JsonValue) {
let mut out = String::new();
if route["dead_routes"].len() != 0 {
if !route["dead_routes"].is_empty() {
out.push_str(&format!("Dead routes: {:?}", route["dead_routes"]));
}
if route["dead_routes"].len() != 0 {
if !route["dead_routes"].is_empty() {
if !out.is_empty() {
out.push_str("\n");
out.push('\n');
}
out.push_str(&format!(
"Dead remote routes: {:?}",
@@ -460,7 +458,7 @@ Server Debug Commands:
};
let strmsg = if printable {
format!("\"{}\"", String::from_utf8_lossy(&message).to_string())
format!("\"{}\"", String::from_utf8_lossy(message))
} else {
hex::encode(message)
};
@@ -498,7 +496,7 @@ Server Debug Commands:
};
let strmsg = if printable {
format!("\"{}\"", String::from_utf8_lossy(&message).to_string())
format!("\"{}\"", String::from_utf8_lossy(message))
} else {
hex::encode(message)
};

View File

@@ -1,4 +1,5 @@
#![deny(clippy::all)]
#![allow(clippy::comparison_chain, clippy::upper_case_acronyms)]
#![deny(unused_must_use)]
#![recursion_limit = "256"]
@@ -58,7 +59,7 @@ fn main() -> Result<(), String> {
None
};
let mut settings = settings::Settings::new(settings_path.as_ref().map(|x| x.as_os_str()))
let mut settings = settings::Settings::new(settings_path.as_deref())
.map_err(|e| format!("configuration is invalid: {}", e))?;
// Set config from command line

View File

@@ -58,7 +58,7 @@ impl TableViewItem<PeerTableColumn> for json::JsonValue {
PeerTableColumn::NodeId => self["node_ids"][0].to_string(),
PeerTableColumn::Address => self["peer_address"].to_string(),
PeerTableColumn::LatencyAvg => {
format!("{}", format_ts(&self["peer_stats"]["latency"]["average"]))
format_ts(&self["peer_stats"]["latency"]["average"]).to_string()
}
PeerTableColumn::TransferDownAvg => {
format_bps(&self["peer_stats"]["transfer"]["down"]["average"])

View File

@@ -6,7 +6,7 @@ use std::net::{SocketAddr, ToSocketAddrs};
use std::path::{Path, PathBuf};
pub fn load_default_config() -> Result<config::Config, config::ConfigError> {
let default_config = r###"---
let default_config = r#"---
address: "localhost:5959"
autoconnect: true
autoreconnect: true
@@ -44,7 +44,7 @@ interface:
info : "white"
warn : "light yellow"
error : "light red"
"###
"#
.replace(
"%LOGGING_FILE_DIRECTORY%",
&Settings::get_default_log_directory().to_string_lossy(),

View File

@@ -477,7 +477,11 @@ impl UI {
let color = *Self::inner_mut(s).log_colors.get(&Level::Warn).unwrap();
cursive_flexi_logger_view::parse_lines_to_log(
color.into(),
<<<<<<< HEAD
format!(">> {} Could not copy to clipboard", UI::cli_ts(Self::get_start_time())),
=======
">> Could not copy to clipboard".to_string(),
>>>>>>> f59c4509ea7e0c0e8b1088138a6eb5297844b112
);
}
} else {
@@ -491,7 +495,9 @@ impl UI {
.as_bytes(),
)
.is_ok()
&& std::io::stdout().flush().is_ok()
{
<<<<<<< HEAD
if std::io::stdout().flush().is_ok() {
let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap();
cursive_flexi_logger_view::parse_lines_to_log(
@@ -499,6 +505,13 @@ impl UI {
format!(">> {} Copied: {}", UI::cli_ts(Self::get_start_time()), text.as_ref()),
);
}
=======
let color = *Self::inner_mut(s).log_colors.get(&Level::Info).unwrap();
cursive_flexi_logger_view::parse_lines_to_log(
color.into(),
format!(">> Copied: {}", text.as_ref()),
);
>>>>>>> f59c4509ea7e0c0e8b1088138a6eb5297844b112
}
}
}
@@ -531,7 +544,7 @@ impl UI {
let mut reset: bool = false;
match state {
ConnectionState::Disconnected => {
if inner.connection_dialog_state == None
if inner.connection_dialog_state.is_none()
|| inner
.connection_dialog_state
.as_ref()
@@ -549,7 +562,7 @@ impl UI {
}
}
ConnectionState::Connected(_, _) => {
if inner.connection_dialog_state != None
if inner.connection_dialog_state.is_some()
&& !inner
.connection_dialog_state
.as_ref()
@@ -560,7 +573,7 @@ impl UI {
}
}
ConnectionState::Retrying(_, _) => {
if inner.connection_dialog_state == None
if inner.connection_dialog_state.is_none()
|| inner
.connection_dialog_state
.as_ref()
@@ -987,10 +1000,12 @@ impl UI {
}
type CallbackSink = Box<dyn FnOnce(&mut Cursive) + 'static + Send>;
#[derive(Clone)]
pub struct UISender {
inner: Arc<Mutex<UIInner>>,
cb_sink: Sender<Box<dyn FnOnce(&mut Cursive) + 'static + Send>>,
cb_sink: Sender<CallbackSink>,
}
impl UISender {
@@ -1066,7 +1081,7 @@ impl UISender {
for l in 0..node_ids.len() {
let nid = &node_ids[l];
if !node_id_str.is_empty() {
node_id_str.push_str(" ");
node_id_str.push(' ');
}
node_id_str.push_str(nid.to_string().as_ref());
}