Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[client, relay] Fix/wg watch #3261

Merged
merged 14 commits into from
Feb 10, 2025
Merged

[client, relay] Fix/wg watch #3261

merged 14 commits into from
Feb 10, 2025

Conversation

pappz
Copy link
Contributor

@pappz pappz commented Jan 31, 2025

Describe your changes

Fix WireGuard watcher related issues

  • Fix race handling between TURN and Relayed reconnection
  • Move the WgWatcher logic to separated struct
  • Handle timeouts more defensive way
  • Fix initial Relay client reconnection to the home server

The Relayed connection setup is optimistic. It does not have any confirmation of an established end-to-end connection. Peers start sending WireGuard handshake packets immediately after the successful offer-answer handshake.
Meanwhile, for successful P2P connection negotiation, we change the WireGuard endpoint address, but this change does not trigger new handshake initiation. Because the peer switched from Relayed connection to P2P, the packets from the Relay server are dropped and must wait for the next WireGuard handshake via P2P.

To avoid this scenario, the relayed WireGuard proxy no longer drops the packets. Instead, it rewrites the source address to the new P2P endpoint and continues forwarding the packets.

We still have one corner case: if the Relayed server negotiation chooses a server that has not been used before. In this case, one side of the peer connection will be slower to reach the Relay server, and the Relay server will drop the handshake packet.

If everything goes well we should see exactly 5 seconds improvements between the WireGuard configuration time and the handshake time.

Issue ticket number and link

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

@pappz pappz changed the title Fix/wg watch [client] Fix/wg watch Jan 31, 2025
@pappz pappz marked this pull request as ready for review February 7, 2025 21:24
lixmal
lixmal previously approved these changes Feb 7, 2025
@pappz pappz linked an issue Feb 8, 2025 that may be closed by this pull request
@pappz pappz changed the title [client] Fix/wg watch [client, relay] Fix/wg watch Feb 8, 2025
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 New issue
1 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@pappz pappz merged commit 5953b43 into main Feb 10, 2025
40 of 41 checks passed
@pappz pappz deleted the fix/wg-watch branch February 10, 2025 09:32
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pings disappear from some peers to others after one week
2 participants