[PR #4083] [client, relay-server] Feature/relay notification #4081

Open
opened 2025-11-20 08:07:41 -05:00 by saavagebueno · 0 comments
Owner

Original Pull Request: https://github.com/netbirdio/netbird/pull/4083

State: closed
Merged: Yes


Describe your changes

Previously, the agent had no information about the state of the remote Relay connection. When the remote peer disconnected, we relied solely on the WireGuard handshake to detect the disconnection.

This update improves that by enabling the Relay server to propagate the remote peer's connection state — both when peers connect and when they disconnect.

Benefits:

  1. Faster disconnection detection: When a remote peer disconnects from the Relay server, the server immediately notifies the other peers.
  2. Connection validation: A peer will only attempt to open a relayed net.Conn connection once the server confirms that the remote peer is available, preventing dropped packets.

Key changes:

  • Clients now subscribe to peer status changes.

  • The server manages and maintains these subscriptions.

  • Replaced raw string peer IDs with a custom peer ID type for better type safety and clarity.

Stack

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

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

**Original Pull Request:** https://github.com/netbirdio/netbird/pull/4083 **State:** closed **Merged:** Yes --- ## Describe your changes Previously, the agent had no information about the state of the remote Relay connection. When the remote peer disconnected, we relied solely on the WireGuard handshake to detect the disconnection. This update improves that by enabling the Relay server to propagate the remote peer's connection state — both when peers connect and when they disconnect. ### Benefits: 1. Faster disconnection detection: When a remote peer disconnects from the Relay server, the server immediately notifies the other peers. 2. Connection validation: A peer will only attempt to open a relayed net.Conn connection once the server confirms that the remote peer is available, preventing dropped packets. ### Key changes: - Clients now subscribe to peer status changes. - The server manages and maintains these subscriptions. - Replaced raw string peer IDs with a custom peer ID type for better type safety and clarity. ## Issue ticket number and link ## Stack <!-- branch-stack --> ### Checklist - [ ] Is it a bug fix - [ ] Is a typo/documentation fix - [x] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md).
saavagebueno added the pull-request label 2025-11-20 08:07:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#4081