Skip to content

Commit

Permalink
feat(snownet): always force a handshake when we change the socket (#3985
Browse files Browse the repository at this point in the history
)

Some local testing identified that we might lose the first packet if we
switch the sockets too quickly, i.e. upgrade from a relayed one to a
direct one initially. To mitigate having to wait for the wireguard
timeout here, let's force a handshake every time we switch to a new
socket.
  • Loading branch information
thomaseizinger committed Mar 6, 2024
1 parent ae6c326 commit 2f74edd
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions rust/connlib/snownet/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,11 @@ where

conn.invalidate_candiates();

if is_first_connection {
tracing::info!(%id, "Starting wireguard handshake");

self.buffered_transmits.extend(
conn.force_handshake(&mut self.allocations, self.last_now),
);
tracing::info!(%id, "Sending wireguard handshake");
self.buffered_transmits
.extend(conn.force_handshake(&mut self.allocations, self.last_now));

if is_first_connection {
return Some(Event::ConnectionEstablished(id));
}
}
Expand Down

0 comments on commit 2f74edd

Please sign in to comment.