Skip to content

Commit

Permalink
Merge pull request #973 from NordSecurity/LLT-5607-reduce_amount_of_l…
Browse files Browse the repository at this point in the history
…ogs_on_failing_derp_connection

[LLT-5607] Reduce derp connection failure warning logs
  • Loading branch information
stalowyjez authored Jan 23, 2025
2 parents 1f1face + cac810f commit dcfd87c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Empty file.
9 changes: 8 additions & 1 deletion crates/telio-relay/src/derp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,14 @@ impl State {
break (server, conn);
}
Err(err) => {
telio_log_warn!("({}) Failed to connect: {}", Self::NAME, err);
if config.servers.current_server_num == config.servers.servers.len() {
telio_log_warn!(
"({}) Failed to connect to any of {} servers: {}",
Self::NAME,
config.servers.servers.len(),
err
);
}
last_disconnection_reason = err.into();
continue;
}
Expand Down
21 changes: 18 additions & 3 deletions crates/telio-sockets/src/protector/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io::{self, Result};
use std::net::Ipv4Addr;
use std::os::windows::io::RawSocket;
use std::sync::Arc;
use telio_utils::{telio_log_debug, telio_log_error, telio_log_warn};
use telio_utils::{telio_log_debug, telio_log_error, telio_log_trace, telio_log_warn};
use tokio::sync::mpsc::{self, Sender};
use tokio::sync::Notify;
use tokio::task::JoinHandle;
Expand Down Expand Up @@ -78,6 +78,7 @@ struct Sockets {
tunnel_interface: Option<u64>,
default_interface: Option<Interface>,
notify: Arc<Notify>,
last_default_interface_error: Option<io::Error>,
}

impl Sockets {
Expand All @@ -87,6 +88,7 @@ impl Sockets {
tunnel_interface: None,
default_interface: None,
notify: Arc::new(Notify::new()),
last_default_interface_error: None,
}
}

Expand All @@ -99,9 +101,22 @@ impl Sockets {
return;
}
let new_default_interface = match get_default_interface(tunnel_interface) {
Ok(def) => Some(def),
Ok(def) => {
self.last_default_interface_error = None;
Some(def)
}
Err(e) => {
telio_log_warn!("Failed to get default interface {}", e);
if self
.last_default_interface_error
.as_ref()
.map(|old_err| old_err.kind() != e.kind())
.unwrap_or(true)
{
telio_log_warn!("Failed to get default interface: {}", e);
self.last_default_interface_error = Some(e);
} else {
telio_log_trace!("Failed to get default interface");
}
return;
}
};
Expand Down

0 comments on commit dcfd87c

Please sign in to comment.