chore(snownet): extract constant for handshake timeout (#4091)

This commit is contained in:
Thomas Eizinger
2024-03-13 01:06:28 +11:00
committed by GitHub
parent 36848e31a9
commit 48dc15f215

View File

@@ -38,6 +38,9 @@ const HANDSHAKE_RATE_LIMIT: u64 = 100;
/// How long we will at most wait for a candidate from the remote.
const CANDIDATE_TIMEOUT: Duration = Duration::from_secs(10);
/// How long we will at most wait for an [`Answer`] from the remote.
const HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(20);
const MAX_UDP_SIZE: usize = (1 << 16) - 1;
/// Manages a set of wireguard connections for a server.
@@ -1213,7 +1216,7 @@ impl InitialConnection {
where
TId: fmt::Display,
{
if now.duration_since(self.created_at) >= Duration::from_secs(20) {
if now.duration_since(self.created_at) >= HANDSHAKE_TIMEOUT {
tracing::info!(%id, "Connection setup timed out (no answer received)");
self.is_failed = true;
}