From 7604432750ad30d900e1454899bb2adcb9dc2174 Mon Sep 17 00:00:00 2001 From: jstuczyn Date: Fri, 17 Apr 2020 18:15:26 +0100 Subject: [PATCH 1/5] log statement for forwarding traffic --- common/clients/multi-tcp-client/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/common/clients/multi-tcp-client/src/lib.rs b/common/clients/multi-tcp-client/src/lib.rs index fede4082bf2..30a4c6da907 100644 --- a/common/clients/multi-tcp-client/src/lib.rs +++ b/common/clients/multi-tcp-client/src/lib.rs @@ -91,6 +91,7 @@ impl Client { message: Vec, wait_for_response: bool, ) -> io::Result<()> { + trace!("Sending packet to {:?}", address); if !self.connections_managers.contains_key(&address) { debug!( "There is no existing connection to {:?} - it will be established now", From 7dcec726eaaaf6bfdecf6a6184d1c6a51168c727 Mon Sep 17 00:00:00 2001 From: jstuczyn Date: Fri, 17 Apr 2020 18:15:47 +0100 Subject: [PATCH 2/5] Mixnode logging intent to forward packet --- mixnode/src/node/packet_forwarding.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mixnode/src/node/packet_forwarding.rs b/mixnode/src/node/packet_forwarding.rs index 00cfb7d2842..f67e814f91b 100644 --- a/mixnode/src/node/packet_forwarding.rs +++ b/mixnode/src/node/packet_forwarding.rs @@ -14,6 +14,7 @@ use futures::channel::mpsc; use futures::StreamExt; +use log::*; use std::net::SocketAddr; use std::time::Duration; use tokio::runtime::Handle; @@ -50,6 +51,7 @@ impl PacketForwarder { let sender_channel = self.conn_tx.clone(); handle.spawn(async move { while let Some((address, packet)) = self.conn_rx.next().await { + trace!("Going to forward packet to {:?}", address); // as a mix node we don't care about responses, we just want to fire packets // as quickly as possible self.tcp_client.send(address, packet, false).await.unwrap(); // if we're not waiting for response, we MUST get an Ok From 1a9375cf396430773eea4025eed689a252299687 Mon Sep 17 00:00:00 2001 From: jstuczyn Date: Fri, 17 Apr 2020 18:16:08 +0100 Subject: [PATCH 3/5] Presence logging level decrease + making things less public --- mixnode/src/node/presence.rs | 12 ++++++------ sfw-provider/src/provider/presence.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mixnode/src/node/presence.rs b/mixnode/src/node/presence.rs index 183bd7af877..766e4e00792 100644 --- a/mixnode/src/node/presence.rs +++ b/mixnode/src/node/presence.rs @@ -16,12 +16,12 @@ use crate::built_info; use directory_client::presence::mixnodes::MixNodePresence; use directory_client::requests::presence_mixnodes_post::PresenceMixNodesPoster; use directory_client::DirectoryClient; -use log::{debug, error}; +use log::{error, trace}; use std::time::Duration; use tokio::runtime::Handle; use tokio::task::JoinHandle; -pub struct NotifierConfig { +pub(crate) struct NotifierConfig { location: String, directory_server: String, announce_host: String, @@ -31,7 +31,7 @@ pub struct NotifierConfig { } impl NotifierConfig { - pub fn new( + pub(crate) fn new( location: String, directory_server: String, announce_host: String, @@ -50,14 +50,14 @@ impl NotifierConfig { } } -pub struct Notifier { +pub(crate) struct Notifier { net_client: directory_client::Client, presence: MixNodePresence, sending_delay: Duration, } impl Notifier { - pub fn new(config: NotifierConfig) -> Notifier { + pub(crate) fn new(config: NotifierConfig) -> Notifier { let directory_client_cfg = directory_client::Config { base_url: config.directory_server, }; @@ -80,7 +80,7 @@ impl Notifier { fn notify(&self) { match self.net_client.presence_mix_nodes_post.post(&self.presence) { Err(err) => error!("failed to send presence - {:?}", err), - Ok(_) => debug!("sent presence information"), + Ok(_) => trace!("sent presence information"), } } diff --git a/sfw-provider/src/provider/presence.rs b/sfw-provider/src/provider/presence.rs index 78251b7efbc..f874606be48 100644 --- a/sfw-provider/src/provider/presence.rs +++ b/sfw-provider/src/provider/presence.rs @@ -17,12 +17,12 @@ use crate::provider::ClientLedger; use directory_client::presence::providers::MixProviderPresence; use directory_client::requests::presence_providers_post::PresenceMixProviderPoster; use directory_client::DirectoryClient; -use log::{debug, error}; +use log::{error, trace}; use std::time::Duration; use tokio::runtime::Handle; use tokio::task::JoinHandle; -pub struct NotifierConfig { +pub(crate) struct NotifierConfig { location: String, directory_server: String, mix_announce_host: String, @@ -32,7 +32,7 @@ pub struct NotifierConfig { } impl NotifierConfig { - pub fn new( + pub(crate) fn new( location: String, directory_server: String, mix_announce_host: String, @@ -51,7 +51,7 @@ impl NotifierConfig { } } -pub struct Notifier { +pub(crate) struct Notifier { location: String, net_client: directory_client::Client, client_ledger: ClientLedger, @@ -91,10 +91,10 @@ impl Notifier { } } - pub fn notify(&self, presence: MixProviderPresence) { + pub(crate) fn notify(&self, presence: MixProviderPresence) { match self.net_client.presence_providers_post.post(&presence) { Err(err) => error!("failed to send presence - {:?}", err), - Ok(_) => debug!("sent presence information"), + Ok(_) => trace!("sent presence information"), } } From 1bf5f5480e71ed5365aa6c3b803dc6467375a439 Mon Sep 17 00:00:00 2001 From: jstuczyn Date: Fri, 17 Apr 2020 18:16:33 +0100 Subject: [PATCH 4/5] Default adjustments + human readable equivalents in comments --- nym-client/src/config/mod.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nym-client/src/config/mod.rs b/nym-client/src/config/mod.rs index 5591410bdcf..7fc1cd08d05 100644 --- a/nym-client/src/config/mod.rs +++ b/nym-client/src/config/mod.rs @@ -26,12 +26,12 @@ const DEFAULT_LISTENING_PORT: u16 = 9001; // 'DEBUG' // where applicable, the below are defined in milliseconds -const DEFAULT_LOOP_COVER_STREAM_AVERAGE_DELAY: u64 = 1000; -const DEFAULT_MESSAGE_STREAM_AVERAGE_DELAY: u64 = 500; -const DEFAULT_AVERAGE_PACKET_DELAY: u64 = 200; -const DEFAULT_FETCH_MESSAGES_DELAY: u64 = 1000; -const DEFAULT_TOPOLOGY_REFRESH_RATE: u64 = 10_000; -const DEFAULT_TOPOLOGY_RESOLUTION_TIMEOUT: u64 = 5_000; +const DEFAULT_LOOP_COVER_STREAM_AVERAGE_DELAY: u64 = 1000; // 1s +const DEFAULT_MESSAGE_STREAM_AVERAGE_DELAY: u64 = 500; // 0.5s +const DEFAULT_AVERAGE_PACKET_DELAY: u64 = 200; // 0.2s +const DEFAULT_FETCH_MESSAGES_DELAY: u64 = 1000; // 1s +const DEFAULT_TOPOLOGY_REFRESH_RATE: u64 = 30_000; // 30s +const DEFAULT_TOPOLOGY_RESOLUTION_TIMEOUT: u64 = 5_000; // 5s const DEFAULT_PACKET_FORWARDING_INITIAL_BACKOFF: u64 = 10_000; // 10s const DEFAULT_PACKET_FORWARDING_MAXIMUM_BACKOFF: u64 = 300_000; // 5min const DEFAULT_INITIAL_CONNECTION_TIMEOUT: u64 = 1_500; // 1.5s From 8c6f01ec3b92b2fa23bceb6da80cd6ecab6ed2bd Mon Sep 17 00:00:00 2001 From: jstuczyn Date: Fri, 17 Apr 2020 18:16:55 +0100 Subject: [PATCH 5/5] Do not immediately refresh topology on start --- nym-client/src/client/topology_control.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nym-client/src/client/topology_control.rs b/nym-client/src/client/topology_control.rs index ec43b9892c9..7473dfd4164 100644 --- a/nym-client/src/client/topology_control.rs +++ b/nym-client/src/client/topology_control.rs @@ -232,8 +232,8 @@ impl TopologyRefresher { pub(crate) fn start(mut self, handle: &Handle) -> JoinHandle<()> { handle.spawn(async move { loop { - self.refresh().await; tokio::time::delay_for(self.refresh_rate).await; + self.refresh().await; } }) }