refactor for tracing and api logging
This commit is contained in:
parent
bfe0315af1
commit
38abe7874d
@ -64,7 +64,7 @@ impl ConnectionTable {
|
|||||||
// then drop the least recently used connection
|
// then drop the least recently used connection
|
||||||
if self.conn_by_descriptor[index].len() > self.max_connections[index] {
|
if self.conn_by_descriptor[index].len() > self.max_connections[index] {
|
||||||
if let Some((lruk, _)) = self.conn_by_descriptor[index].remove_lru() {
|
if let Some((lruk, _)) = self.conn_by_descriptor[index].remove_lru() {
|
||||||
warn!("XX: connection lru out: {:?}", lruk);
|
debug!("connection lru out: {:?}", lruk);
|
||||||
self.remove_connection_records(lruk);
|
self.remove_connection_records(lruk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,14 +75,12 @@ impl ConnectionTable {
|
|||||||
.entry(descriptor.remote())
|
.entry(descriptor.remote())
|
||||||
.or_default();
|
.or_default();
|
||||||
|
|
||||||
warn!("add_connection: {:?}", descriptor);
|
|
||||||
descriptors.push(descriptor);
|
descriptors.push(descriptor);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_connection(&mut self, descriptor: ConnectionDescriptor) -> Option<ConnectionHandle> {
|
pub fn get_connection(&mut self, descriptor: ConnectionDescriptor) -> Option<ConnectionHandle> {
|
||||||
warn!("get_connection: {:?}", descriptor);
|
|
||||||
let index = protocol_to_index(descriptor.protocol_type());
|
let index = protocol_to_index(descriptor.protocol_type());
|
||||||
let out = self.conn_by_descriptor[index].get(&descriptor);
|
let out = self.conn_by_descriptor[index].get(&descriptor);
|
||||||
out.map(|c| c.get_handle())
|
out.map(|c| c.get_handle())
|
||||||
@ -92,7 +90,6 @@ impl ConnectionTable {
|
|||||||
&mut self,
|
&mut self,
|
||||||
remote: PeerAddress,
|
remote: PeerAddress,
|
||||||
) -> Option<ConnectionHandle> {
|
) -> Option<ConnectionHandle> {
|
||||||
warn!("get_last_connection_by_remote: {:?}", remote);
|
|
||||||
let descriptor = self
|
let descriptor = self
|
||||||
.descriptors_by_remote
|
.descriptors_by_remote
|
||||||
.get(&remote)
|
.get(&remote)
|
||||||
@ -113,7 +110,6 @@ impl ConnectionTable {
|
|||||||
&mut self,
|
&mut self,
|
||||||
remote: PeerAddress,
|
remote: PeerAddress,
|
||||||
) -> Vec<ConnectionDescriptor> {
|
) -> Vec<ConnectionDescriptor> {
|
||||||
warn!("get_connection_descriptors_by_remote: {:?}", remote);
|
|
||||||
self.descriptors_by_remote
|
self.descriptors_by_remote
|
||||||
.get(&remote)
|
.get(&remote)
|
||||||
.cloned()
|
.cloned()
|
||||||
@ -154,7 +150,6 @@ impl ConnectionTable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_connection(&mut self, descriptor: ConnectionDescriptor) -> Result<(), String> {
|
pub fn remove_connection(&mut self, descriptor: ConnectionDescriptor) -> Result<(), String> {
|
||||||
warn!("remove_connection: {:?}", descriptor);
|
|
||||||
let index = protocol_to_index(descriptor.protocol_type());
|
let index = protocol_to_index(descriptor.protocol_type());
|
||||||
let _ = self.conn_by_descriptor[index]
|
let _ = self.conn_by_descriptor[index]
|
||||||
.remove(&descriptor)
|
.remove(&descriptor)
|
||||||
|
@ -32,7 +32,16 @@ fn do_clap_matches(default_config_path: &OsStr) -> Result<clap::ArgMatches, clap
|
|||||||
.default_value_os(default_config_path)
|
.default_value_os(default_config_path)
|
||||||
.allow_invalid_utf8(true)
|
.allow_invalid_utf8(true)
|
||||||
.help("Specify a configuration file to use"),
|
.help("Specify a configuration file to use"),
|
||||||
).arg(
|
)
|
||||||
|
.arg(
|
||||||
|
Arg::new("set-config")
|
||||||
|
.short('s')
|
||||||
|
.long("set-config")
|
||||||
|
.takes_value(true)
|
||||||
|
.multiple_occurrences(true)
|
||||||
|
.help("Specify configuration value to set (key in dot format, value in json format), eg: logging.api.enabled=true")
|
||||||
|
)
|
||||||
|
.arg(
|
||||||
Arg::new("attach")
|
Arg::new("attach")
|
||||||
.long("attach")
|
.long("attach")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
@ -270,9 +279,20 @@ pub fn process_command_line() -> Result<(Settings, ArgMatches), String> {
|
|||||||
};
|
};
|
||||||
settingsrw.core.network.bootstrap_nodes = bootstrap_list;
|
settingsrw.core.network.bootstrap_nodes = bootstrap_list;
|
||||||
}
|
}
|
||||||
|
drop(settingsrw);
|
||||||
|
|
||||||
|
// Set specific config settings
|
||||||
|
if let Some(set_configs) = matches.values_of("set-config") {
|
||||||
|
for set_config in set_configs {
|
||||||
|
if let Some((k, v)) = set_config.split_once('=') {
|
||||||
|
let k = k.trim();
|
||||||
|
let v = v.trim();
|
||||||
|
settings.set(k, v)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Apply subnode index if we're testing
|
// Apply subnode index if we're testing
|
||||||
drop(settingsrw);
|
|
||||||
settings
|
settings
|
||||||
.apply_subnode_index()
|
.apply_subnode_index()
|
||||||
.map_err(|_| "failed to apply subnode index".to_owned())?;
|
.map_err(|_| "failed to apply subnode index".to_owned())?;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::client_api;
|
use crate::client_api;
|
||||||
use crate::settings::*;
|
use crate::settings::*;
|
||||||
use flume::{bounded, Receiver, Sender};
|
use flume::{unbounded, Receiver, Sender};
|
||||||
use lazy_static::*;
|
use lazy_static::*;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@ -45,7 +45,7 @@ pub async fn run_veilid_server_internal(
|
|||||||
let (sender, receiver): (
|
let (sender, receiver): (
|
||||||
Sender<veilid_core::VeilidUpdate>,
|
Sender<veilid_core::VeilidUpdate>,
|
||||||
Receiver<veilid_core::VeilidUpdate>,
|
Receiver<veilid_core::VeilidUpdate>,
|
||||||
) = bounded(1);
|
) = unbounded();
|
||||||
|
|
||||||
// Create VeilidCore setup
|
// Create VeilidCore setup
|
||||||
let update_callback = Arc::new(move |change: veilid_core::VeilidUpdate| {
|
let update_callback = Arc::new(move |change: veilid_core::VeilidUpdate| {
|
||||||
|
@ -849,6 +849,142 @@ impl Settings {
|
|||||||
pk_path
|
pk_path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set(&self, key: &str, value: &str) -> Result<(), String> {
|
||||||
|
let mut inner = self.inner.write();
|
||||||
|
|
||||||
|
macro_rules! set_config_value {
|
||||||
|
($innerkey:expr, $value:expr) => {{
|
||||||
|
let innerkeyname = &stringify!($innerkey)[6..];
|
||||||
|
if innerkeyname == key {
|
||||||
|
match veilid_core::deserialize_json(value) {
|
||||||
|
Ok(v) => {
|
||||||
|
$innerkey = v;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
return Err(format!(
|
||||||
|
"invalid type for key {}, value: {}: {}",
|
||||||
|
key, value, e
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
set_config_value!(inner.daemon.enabled, value);
|
||||||
|
set_config_value!(inner.client_api.enabled, value);
|
||||||
|
set_config_value!(inner.client_api.listen_address, value);
|
||||||
|
set_config_value!(inner.auto_attach, value);
|
||||||
|
set_config_value!(inner.logging.system.enabled, value);
|
||||||
|
set_config_value!(inner.logging.system.level, value);
|
||||||
|
set_config_value!(inner.logging.terminal.enabled, value);
|
||||||
|
set_config_value!(inner.logging.terminal.level, value);
|
||||||
|
set_config_value!(inner.logging.file.enabled, value);
|
||||||
|
set_config_value!(inner.logging.file.path, value);
|
||||||
|
set_config_value!(inner.logging.file.append, value);
|
||||||
|
set_config_value!(inner.logging.file.level, value);
|
||||||
|
set_config_value!(inner.logging.api.enabled, value);
|
||||||
|
set_config_value!(inner.logging.api.level, value);
|
||||||
|
set_config_value!(inner.testing.subnode_index, value);
|
||||||
|
set_config_value!(inner.core.protected_store.allow_insecure_fallback, value);
|
||||||
|
set_config_value!(
|
||||||
|
inner.core.protected_store.always_use_insecure_storage,
|
||||||
|
value
|
||||||
|
);
|
||||||
|
set_config_value!(
|
||||||
|
inner.core.protected_store.insecure_fallback_directory,
|
||||||
|
value
|
||||||
|
);
|
||||||
|
set_config_value!(inner.core.protected_store.delete, value);
|
||||||
|
set_config_value!(inner.core.table_store.directory, value);
|
||||||
|
set_config_value!(inner.core.table_store.delete, value);
|
||||||
|
set_config_value!(inner.core.block_store.directory, value);
|
||||||
|
set_config_value!(inner.core.block_store.delete, value);
|
||||||
|
set_config_value!(inner.core.network.connection_initial_timeout_ms, value);
|
||||||
|
set_config_value!(inner.core.network.connection_inactivity_timeout_ms, value);
|
||||||
|
set_config_value!(inner.core.network.max_connections_per_ip4, value);
|
||||||
|
set_config_value!(inner.core.network.max_connections_per_ip6_prefix, value);
|
||||||
|
set_config_value!(
|
||||||
|
inner.core.network.max_connections_per_ip6_prefix_size,
|
||||||
|
value
|
||||||
|
);
|
||||||
|
set_config_value!(inner.core.network.max_connection_frequency_per_min, value);
|
||||||
|
set_config_value!(inner.core.network.client_whitelist_timeout_ms, value);
|
||||||
|
set_config_value!(inner.core.network.reverse_connection_receipt_time_ms, value);
|
||||||
|
set_config_value!(inner.core.network.hole_punch_receipt_time_ms, value);
|
||||||
|
set_config_value!(inner.core.network.node_id, value);
|
||||||
|
set_config_value!(inner.core.network.node_id_secret, value);
|
||||||
|
set_config_value!(inner.core.network.bootstrap, value);
|
||||||
|
set_config_value!(inner.core.network.bootstrap_nodes, value);
|
||||||
|
set_config_value!(inner.core.network.routing_table.limit_over_attached, value);
|
||||||
|
set_config_value!(inner.core.network.routing_table.limit_fully_attached, value);
|
||||||
|
set_config_value!(
|
||||||
|
inner.core.network.routing_table.limit_attached_strong,
|
||||||
|
value
|
||||||
|
);
|
||||||
|
set_config_value!(inner.core.network.routing_table.limit_attached_good, value);
|
||||||
|
set_config_value!(inner.core.network.routing_table.limit_attached_weak, value);
|
||||||
|
set_config_value!(inner.core.network.rpc.concurrency, value);
|
||||||
|
set_config_value!(inner.core.network.rpc.queue_size, value);
|
||||||
|
set_config_value!(inner.core.network.rpc.max_timestamp_behind_ms, value);
|
||||||
|
set_config_value!(inner.core.network.rpc.max_timestamp_ahead_ms, value);
|
||||||
|
set_config_value!(inner.core.network.rpc.timeout_ms, value);
|
||||||
|
set_config_value!(inner.core.network.rpc.max_route_hop_count, value);
|
||||||
|
set_config_value!(inner.core.network.dht.resolve_node_timeout_ms, value);
|
||||||
|
set_config_value!(inner.core.network.dht.resolve_node_count, value);
|
||||||
|
set_config_value!(inner.core.network.dht.resolve_node_fanout, value);
|
||||||
|
set_config_value!(inner.core.network.dht.max_find_node_count, value);
|
||||||
|
set_config_value!(inner.core.network.dht.get_value_timeout_ms, value);
|
||||||
|
set_config_value!(inner.core.network.dht.get_value_count, value);
|
||||||
|
set_config_value!(inner.core.network.dht.get_value_fanout, value);
|
||||||
|
set_config_value!(inner.core.network.dht.set_value_timeout_ms, value);
|
||||||
|
set_config_value!(inner.core.network.dht.set_value_count, value);
|
||||||
|
set_config_value!(inner.core.network.dht.set_value_fanout, value);
|
||||||
|
set_config_value!(inner.core.network.dht.min_peer_count, value);
|
||||||
|
set_config_value!(inner.core.network.dht.min_peer_refresh_time_ms, value);
|
||||||
|
set_config_value!(
|
||||||
|
inner.core.network.dht.validate_dial_info_receipt_time_ms,
|
||||||
|
value
|
||||||
|
);
|
||||||
|
set_config_value!(inner.core.network.upnp, value);
|
||||||
|
set_config_value!(inner.core.network.natpmp, value);
|
||||||
|
set_config_value!(inner.core.network.enable_local_peer_scope, value);
|
||||||
|
set_config_value!(inner.core.network.restricted_nat_retries, value);
|
||||||
|
set_config_value!(inner.core.network.tls.certificate_path, value);
|
||||||
|
set_config_value!(inner.core.network.tls.private_key_path, value);
|
||||||
|
set_config_value!(inner.core.network.tls.connection_initial_timeout_ms, value);
|
||||||
|
set_config_value!(inner.core.network.application.https.enabled, value);
|
||||||
|
set_config_value!(inner.core.network.application.https.listen_address, value);
|
||||||
|
set_config_value!(inner.core.network.application.https.path, value);
|
||||||
|
set_config_value!(inner.core.network.application.https.url, value);
|
||||||
|
set_config_value!(inner.core.network.application.http.enabled, value);
|
||||||
|
set_config_value!(inner.core.network.application.http.listen_address, value);
|
||||||
|
set_config_value!(inner.core.network.application.http.path, value);
|
||||||
|
set_config_value!(inner.core.network.application.http.url, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.udp.enabled, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.udp.socket_pool_size, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.udp.listen_address, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.udp.public_address, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.tcp.connect, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.tcp.listen, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.tcp.max_connections, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.tcp.listen_address, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.tcp.public_address, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.ws.connect, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.ws.listen, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.ws.max_connections, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.ws.listen_address, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.ws.path, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.ws.url, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.wss.connect, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.wss.listen, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.wss.max_connections, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.wss.listen_address, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.wss.path, value);
|
||||||
|
set_config_value!(inner.core.network.protocol.wss.url, value);
|
||||||
|
Err("settings key not found".to_owned())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_core_config_callback(&self) -> veilid_core::ConfigCallback {
|
pub fn get_core_config_callback(&self) -> veilid_core::ConfigCallback {
|
||||||
let inner = self.inner.clone();
|
let inner = self.inner.clone();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user