[PR #6151] [client] Server RPC call resolves correct wireguard port #24960

Open
opened 2026-08-05 06:09:21 -04:00 by saavagebueno · 0 comments
Owner

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

State: closed
Merged: No


Describe your changes

When WgPort is configured as 0, the engine picks a random free port at startup (connect.go:598), but GetConfig was reading WgPort straight from the on-disk profile config. The UI therefore showed the default WG port instead of the port WG is actually listening on.

This change adds Engine.GetWgPort() exposing e.config.WgPort (the resolved port), and updates the daemon's GetConfig RPC to fall back to the engine's value when the configured port is 0 and the engine is running. The configured port is still returned when set explicitly or when the engine isn't up.

https://github.com/netbirdio/netbird/issues/4557

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)

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

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced WireGuard port reporting to correctly display the actual port being used, including properly handling cases where the port is dynamically assigned at runtime rather than statically configured.

Review Change Stack

**Original Pull Request:** https://github.com/netbirdio/netbird/pull/6151 **State:** closed **Merged:** No --- ## Describe your changes When WgPort is configured as 0, the engine picks a random free port at startup ([connect.go:598](https://github.com/netbirdio/netbird/blob/07e5450117dd0451aaeefc18729a822115587e69/client/internal/connect.go#L598)), but `GetConfig` was reading WgPort straight from the on-disk profile config. The UI therefore showed the default WG port instead of the port WG is actually listening on. This change adds `Engine.GetWgPort()` exposing `e.config.WgPort` (the resolved port), and updates the daemon's GetConfig RPC to fall back to the engine's value when the configured port is 0 and the engine is running. The configured port is still returned when set explicitly or when the engine isn't up. ## Issue ticket number and link https://github.com/netbirdio/netbird/issues/4557 ## Stack <!-- branch-stack --> ### Checklist - [x] 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) > 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). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Enhanced WireGuard port reporting to correctly display the actual port being used, including properly handling cases where the port is dynamically assigned at runtime rather than statically configured. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/netbirdio/netbird/pull/6151) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
saavagebueno added the pull-request label 2026-08-05 06:09:21 -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#24960