Skip to content

Conversation

@mlsmaycon
Copy link
Collaborator

@mlsmaycon mlsmaycon commented Jun 22, 2025

Describe your changes

This PR enhances the version checker to send a custom User-Agent header when polling for updates, and configures both the management CLI and client UI to use distinct agents.

  • NewUpdate now takes an httpAgent string to set the User-Agent header.
  • fetchVersion builds a custom HTTP request (instead of http.Get) and sets the User-Agent.
  • Management CLI and client UI now pass "nb/management" and "nb/client-ui" respectively to NewUpdate.
  • Tests updated to supply an httpAgent constant.
  • Logs if there is a new version available for management

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

run the check every 30 minutes and logs on new NetBird version
Copilot AI review requested due to automatic review settings June 22, 2025 14:01
@sonarqubecloud
Copy link

Copy link
Contributor

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 enhances the version checker to send a custom User-Agent header when polling for updates, and configures both the management CLI and client UI to use distinct agents.

  • NewUpdate now takes an httpAgent string to set the User-Agent header.
  • fetchVersion builds a custom HTTP request (instead of http.Get) and sets the User-Agent.
  • Management CLI and client UI now pass "nb/management" and "nb/client-ui" respectively to NewUpdate.
  • Tests updated to supply an httpAgent constant.

Reviewed Changes

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

File Description
version/update.go Added httpAgent field, updated NewUpdate signature, set header in fetchVersion.
version/update_test.go Introduced httpAgent constant and passed it to NewUpdate in tests.
management/cmd/management.go Passed "nb/management" agent and set update listener.
client/ui/client_ui.go Passed "nb/client-ui" agent when creating the update checker.
Comments suppressed due to low confidence (2)

version/update.go:37

  • Update the comment to describe the new httpAgent parameter, e.g., // NewUpdate instantiates Update with a custom User-Agent and starts the fetcher.
// NewUpdate instantiate Update and start to fetch the new version information

version/update_test.go:16

  • Add an assertion in the test handler to verify r.Header.Get("User-Agent") == httpAgent so the custom header behavior is covered by tests.
	svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

@braginini braginini assigned braginini and unassigned braginini Jun 22, 2025
@braginini braginini self-requested a review June 22, 2025 14:41
@mlsmaycon mlsmaycon merged commit 5343bee into main Jun 22, 2025
39 of 40 checks passed
@mlsmaycon mlsmaycon deleted the log-on-management-version branch June 22, 2025 14:44
hurricanehrndz added a commit to hurricanehrndz/netbird that referenced this pull request Jun 25, 2025
…false_enginerestarts

* upstream/main: (228 commits)
  [management] add breakdown of network map calculation metrics (netbirdio#4020)
  [client] Don't open cmd.exe during MSI actions (netbirdio#4041)
  [misc] Specify netbird binary location in Dockerfiles (netbirdio#4024)
  [management] check and log on new management version (netbirdio#4029)
  [misc] add additional metrics (netbirdio#4028)
  [client] close windows when process needs to exit (netbirdio#4027)
  [client] Refactor showLoginURL to improve error handling and connection status checks (netbirdio#4026)
  [client] Handle lazy routing peers that are part of HA groups (netbirdio#3943)
  [management] add transaction for integrated validator groups update and primary account update (netbirdio#4014)
  [management] export ephemeral peer flag on api (netbirdio#4004)
  [management] Add backward compatibility for older clients without firewall rules port range support (netbirdio#4003)
  [client] Fix port range squashing (netbirdio#4007)
  [client] Add more Android advanced settings (netbirdio#4001)
  Fix route notification
  [management] Refactor routes to use store methods  (netbirdio#2928)
  [client] fix connection state handling (netbirdio#3995)
  [client] Fix logic in updateStatus to correctly handle connection state (netbirdio#3994)
  [management] Avoid recalculating next peer expiration (netbirdio#3991)
  [client] Fix DNS Interceptor Build Error (netbirdio#3993)
  [client] Tighten allowed domains for dns forwarder (netbirdio#3978)
  ...
volkermauel pushed a commit to volkermauel/netbird that referenced this pull request Jun 30, 2025
This PR enhances the version checker to send a custom User-Agent header when polling for updates, and configures both the management CLI and client UI to use distinct agents. 

- NewUpdate now takes an `httpAgent` string to set the User-Agent header.
- `fetchVersion` builds a custom HTTP request (instead of `http.Get`) and sets the User-Agent.
- Management CLI and client UI now pass `"nb/management"` and `"nb/client-ui"` respectively to NewUpdate.
- Tests updated to supply an `httpAgent` constant.
- Logs if there is a new version available for management
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.

3 participants