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

@@ -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());
}