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

Closed
opened 2026-08-05 05:06:02 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/4083
Author: @pappz
Created: 7/1/2025
Status: Merged
Merged: 7/15/2025
Merged by: @pappz

Base: mainHead: feature/relay-notification


📝 Commits (10+)

  • 822dd7a Refactor server initialization to use a configuration struct for improved clarity and maintainability
  • 51630cb Use custom PeerID type
  • 5e19c82 Add subscription logic to the server
  • d714e8f Add subscription logic to the server
  • 54e5bbb Distinguish online and offline listener
  • db1b230 Merge remote-tracking branch 'origin/feature/relay-notification' into feature/relay-notification
  • 96347d8 Initial client implementation
  • 483d745 Add context to the OpenConn function
  • 6dea6a9 Filter offline peers response
  • 1c8172c Add on disconnect callback for proxies

📊 Changes

39 files changed (+1462 additions, -493 deletions)

View changed files

📝 client/iface/wgproxy/bind/proxy.go (+20 -0)
📝 client/iface/wgproxy/ebpf/wrapper.go (+18 -0)
📝 client/iface/wgproxy/factory_kernel.go (+2 -3)
📝 client/iface/wgproxy/factory_usp.go (+1 -3)
client/iface/wgproxy/listener/listener.go (+19 -0)
📝 client/iface/wgproxy/proxy.go (+1 -0)
📝 client/iface/wgproxy/proxy_test.go (+1 -3)
📝 client/iface/wgproxy/udp/proxy.go (+11 -0)
📝 client/internal/peer/conn.go (+3 -1)
📝 client/internal/peer/worker_relay.go (+4 -2)
📝 relay/auth/validator.go (+0 -7)
📝 relay/client/client.go (+113 -42)
📝 relay/client/client_test.go (+93 -66)
📝 relay/client/conn.go (+6 -7)
📝 relay/client/guard.go (+1 -1)
📝 relay/client/manager.go (+10 -10)
📝 relay/client/manager_test.go (+63 -39)
relay/client/peer_subscription.go (+168 -0)
relay/client/peer_subscription_test.go (+99 -0)
📝 relay/client/picker.go (+2 -2)

...and 19 more files

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/4083 **Author:** [@pappz](https://github.com/pappz) **Created:** 7/1/2025 **Status:** ✅ Merged **Merged:** 7/15/2025 **Merged by:** [@pappz](https://github.com/pappz) **Base:** `main` ← **Head:** `feature/relay-notification` --- ### 📝 Commits (10+) - [`822dd7a`](https://github.com/netbirdio/netbird/commit/822dd7a5b8128d56957d3b96a1cd74d1e080cd28) Refactor server initialization to use a configuration struct for improved clarity and maintainability - [`51630cb`](https://github.com/netbirdio/netbird/commit/51630cb4ec8db9aae34a9c42bda8386b655840ec) Use custom PeerID type - [`5e19c82`](https://github.com/netbirdio/netbird/commit/5e19c82310465b20728c0a15c192611d7ea58f89) Add subscription logic to the server - [`d714e8f`](https://github.com/netbirdio/netbird/commit/d714e8f69736f319b16b81ffd05e18e1a9606d01) Add subscription logic to the server - [`54e5bbb`](https://github.com/netbirdio/netbird/commit/54e5bbbaada916b47808baa402d37bc889c529cc) Distinguish online and offline listener - [`db1b230`](https://github.com/netbirdio/netbird/commit/db1b230f5baefac49b160adb2a2753717a41e5bb) Merge remote-tracking branch 'origin/feature/relay-notification' into feature/relay-notification - [`96347d8`](https://github.com/netbirdio/netbird/commit/96347d835b73a49c5e1ba0b07c137ad1bca87161) Initial client implementation - [`483d745`](https://github.com/netbirdio/netbird/commit/483d7457c2d745047da65ea09ea877877e8ee88c) Add context to the OpenConn function - [`6dea6a9`](https://github.com/netbirdio/netbird/commit/6dea6a96658973c3986cb11f772bbe848a8abbf9) Filter offline peers response - [`1c8172c`](https://github.com/netbirdio/netbird/commit/1c8172c18a90e79c8d200bcd45596fb564bdc224) Add on disconnect callback for proxies ### 📊 Changes **39 files changed** (+1462 additions, -493 deletions) <details> <summary>View changed files</summary> 📝 `client/iface/wgproxy/bind/proxy.go` (+20 -0) 📝 `client/iface/wgproxy/ebpf/wrapper.go` (+18 -0) 📝 `client/iface/wgproxy/factory_kernel.go` (+2 -3) 📝 `client/iface/wgproxy/factory_usp.go` (+1 -3) ➕ `client/iface/wgproxy/listener/listener.go` (+19 -0) 📝 `client/iface/wgproxy/proxy.go` (+1 -0) 📝 `client/iface/wgproxy/proxy_test.go` (+1 -3) 📝 `client/iface/wgproxy/udp/proxy.go` (+11 -0) 📝 `client/internal/peer/conn.go` (+3 -1) 📝 `client/internal/peer/worker_relay.go` (+4 -2) 📝 `relay/auth/validator.go` (+0 -7) 📝 `relay/client/client.go` (+113 -42) 📝 `relay/client/client_test.go` (+93 -66) 📝 `relay/client/conn.go` (+6 -7) 📝 `relay/client/guard.go` (+1 -1) 📝 `relay/client/manager.go` (+10 -10) 📝 `relay/client/manager_test.go` (+63 -39) ➕ `relay/client/peer_subscription.go` (+168 -0) ➕ `relay/client/peer_subscription_test.go` (+99 -0) 📝 `relay/client/picker.go` (+2 -2) _...and 19 more files_ </details> ### 📄 Description ## 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 05:06:02 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#19461