Skip to content

Conversation

hakansa
Copy link
Member

@hakansa hakansa commented Oct 9, 2025

Describe your changes

[client] fix dns forwarder port update

Issue ticket number and link

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)
    .

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

@Copilot Copilot AI review requested due to automatic review settings October 9, 2025 14:27
Copy link

sonarqubecloud bot commented Oct 9, 2025

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue with DNS forwarder port updates by changing how the port is configured. Instead of passing the port through the constructor and setting it during Start(), the port is now set directly via a new SetListenPort() function before creating the manager.

  • Removed port parameter from NewManager constructor
  • Added SetListenPort() function to set the port globally before manager creation
  • Updated port setting to occur before manager instantiation rather than during Start()

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
client/internal/engine.go Updated to call SetListenPort() before creating DNS manager and removed port parameter from NewManager calls
client/internal/dnsfwd/manager.go Removed port field from Manager struct, added SetListenPort() function, and removed port setting logic from Start() method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +51 to +55
func SetListenPort(port uint16) {
listenPortMu.Lock()
listenPort = port
listenPortMu.Unlock()
}
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SetListenPort function modifies global state without considering if a DNS forwarder is already running. This could cause race conditions if called while the forwarder is active, potentially leading to the forwarder listening on one port while the global listenPort variable indicates another.

Copilot uses AI. Check for mistakes.

@hakansa hakansa merged commit 4e03f70 into main Oct 9, 2025
32 of 33 checks passed
@hakansa hakansa deleted the fix/fwd-port-update branch October 9, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants