Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
bc59749
Feature: Auto-update client
mohamed-essam Jul 30, 2025
c632878
Resolve comments
mohamed-essam Aug 19, 2025
762b9b7
Restructure version.Update to use channel
mohamed-essam Aug 20, 2025
84501a3
Fix deadlock issues
mohamed-essam Aug 25, 2025
58d4812
Define constants for version semantics
mohamed-essam Aug 26, 2025
d2e198b
Fix lint
mohamed-essam Aug 26, 2025
59ae92c
Refactor handleAutoUpdateVersion to outside handleSync
mohamed-essam Aug 26, 2025
6025eb1
Add unit tests
mohamed-essam Sep 2, 2025
ecf1e90
Merge branch 'main' into feat/auto-upgrade
mohamed-essam Sep 7, 2025
ec47a84
Remove testing.T.Context() as it's added in go1.24
mohamed-essam Sep 8, 2025
d19f829
Move autoUpdateVersion inside NetworkMap
mohamed-essam Sep 15, 2025
02afd4e
Move to networkMap.PeerConfig
mohamed-essam Sep 16, 2025
5042339
Update management/server/account.go
mlsmaycon Sep 20, 2025
ad3985a
Merge pull request #4504 from netbirdio/sub-feat/auto-upgrade/move-ve…
mohamed-essam Sep 21, 2025
b070304
Modify client-side behavior
mohamed-essam Oct 1, 2025
e04b989
Change ProgressBarInfinite to Updating... label
mohamed-essam Oct 1, 2025
723c418
Merge branch 'main' into feat/auto-upgrade
mohamed-essam Oct 6, 2025
0d2ce56
Merge branch 'feat/auto-upgrade' into auto-upgrade-mod
mohamed-essam Oct 6, 2025
b37ba44
Resolve issues
mohamed-essam Oct 8, 2025
436d740
Merge branch 'feat/auto-upgrade' into auto-upgrade-mod
mohamed-essam Oct 8, 2025
d5ea408
Resolve issues
mohamed-essam Oct 8, 2025
5556ff3
Merge pull request #4563 from netbirdio/auto-upgrade-mod
mohamed-essam Oct 12, 2025
582ff1f
Fix auto-update message handling
pappz Oct 13, 2025
9ae48a0
Remove unused codes and remove unnecessary variables
pappz Oct 13, 2025
7fa926d
Fix deadlock
pappz Oct 13, 2025
6200aaf
Fix state handling
pappz Oct 13, 2025
7d846bf
Fix nil pointer exception in expectedSemVer
pappz Oct 13, 2025
bab5cd4
Clean up temp dir
pappz Oct 13, 2025
cd19f4d
Code cleaning in updateState
pappz Oct 13, 2025
1354096
Fix windows build
pappz Oct 13, 2025
18f884f
- fix nil pointer for context
pappz Oct 13, 2025
9313b49
Fix Windows installer
pappz Oct 14, 2025
6eee52b
Fix auto update success message check
pappz Oct 15, 2025
030ddae
Merge branch 'main' into feat/auto-upgrade
pappz Oct 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion client/internal/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/netbirdio/netbird/client/internal/peer"
"github.com/netbirdio/netbird/client/internal/profilemanager"
"github.com/netbirdio/netbird/client/internal/stdnet"
nbnet "github.com/netbirdio/netbird/client/net"
cProto "github.com/netbirdio/netbird/client/proto"
"github.com/netbirdio/netbird/client/ssh"
"github.com/netbirdio/netbird/client/system"
Expand All @@ -34,7 +35,6 @@ import (
relayClient "github.com/netbirdio/netbird/shared/relay/client"
signal "github.com/netbirdio/netbird/shared/signal/client"
"github.com/netbirdio/netbird/util"
nbnet "github.com/netbirdio/netbird/client/net"
"github.com/netbirdio/netbird/version"
)

Expand Down Expand Up @@ -280,6 +280,10 @@ func (c *ConnectClient) run(mobileDependency MobileDependency, runningChan chan
return wrapErr(err)
}

if loginResp.PeerConfig != nil && loginResp.PeerConfig.AutoUpdate != nil {
c.engine.InitialUpdateHandling(loginResp.PeerConfig.AutoUpdate)
}

log.Infof("Netbird engine started, the IP is: %s", peerConfig.GetAddress())
state.Set(StatusConnected)

Expand Down
56 changes: 56 additions & 0 deletions client/internal/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
"github.com/netbirdio/netbird/client/internal/routemanager"
"github.com/netbirdio/netbird/client/internal/routemanager/systemops"
"github.com/netbirdio/netbird/client/internal/statemanager"
"github.com/netbirdio/netbird/client/internal/updatemanager"
cProto "github.com/netbirdio/netbird/client/proto"
"github.com/netbirdio/netbird/shared/management/domain"
semaphoregroup "github.com/netbirdio/netbird/util/semaphore-group"
Expand All @@ -75,6 +76,7 @@ const (
PeerConnectionTimeoutMax = 45000 // ms
PeerConnectionTimeoutMin = 30000 // ms
connInitLimit = 200
disableAutoUpdate = "disabled"
)

var ErrResetConnection = fmt.Errorf("reset connection")
Expand Down Expand Up @@ -199,6 +201,9 @@ type Engine struct {
connSemaphore *semaphoregroup.SemaphoreGroup
flowManager nftypes.FlowManager

// auto-update
updateManager *updatemanager.UpdateManager

// WireGuard interface monitor
wgIfaceMonitor *WGIfaceMonitor
wgIfaceMonitorWg sync.WaitGroup
Expand Down Expand Up @@ -314,6 +319,10 @@ func (e *Engine) Stop() error {
e.srWatcher.Close()
}

if e.updateManager != nil {
e.updateManager.Stop()
}

e.statusRecorder.ReplaceOfflinePeers([]peer.State{})
e.statusRecorder.UpdateDNSStates([]peer.NSGroupState{})
e.statusRecorder.UpdateRelayStates([]relay.ProbeResult{})
Expand Down Expand Up @@ -500,6 +509,19 @@ func (e *Engine) Start(netbirdConfig *mgmProto.NetbirdConfig, mgmtURL *url.URL)
return nil
}

func (e *Engine) InitialUpdateHandling(autoUpdateSettings *mgmProto.AutoUpdateSettings) {
e.syncMsgMux.Lock()
defer e.syncMsgMux.Unlock()

if e.updateManager == nil {
e.updateManager = updatemanager.NewUpdateManager(e.statusRecorder, e.stateManager)
}

e.updateManager.CheckUpdateSuccess(e.ctx)

e.handleAutoUpdateVersion(autoUpdateSettings, true)
}

func (e *Engine) createFirewall() error {
if e.config.DisableFirewall {
log.Infof("firewall is disabled")
Expand Down Expand Up @@ -712,10 +734,44 @@ func (e *Engine) PopulateNetbirdConfig(netbirdConfig *mgmProto.NetbirdConfig, mg
return nil
}

func (e *Engine) handleAutoUpdateVersion(autoUpdateSettings *mgmProto.AutoUpdateSettings, initialCheck bool) {
if autoUpdateSettings == nil {
return
}

disabled := autoUpdateSettings.Version == disableAutoUpdate

// Stop and cleanup if disabled
if e.updateManager != nil && disabled {
log.Infof("auto-update is disabled, stopping update manager")
e.updateManager.Stop()
e.updateManager = nil
return
}

// Skip check unless AlwaysUpdate is enabled or this is the initial check at startup
if !autoUpdateSettings.AlwaysUpdate && !initialCheck {
log.Debugf("skipping auto-update check, AlwaysUpdate is false and this is not the initial check")
return
}

// Start manager if needed
if e.updateManager == nil {
log.Infof("starting auto-update manager")
e.updateManager = updatemanager.NewUpdateManager(e.statusRecorder, e.stateManager)
}
e.updateManager.Start(e.ctx)
log.Infof("handling auto-update version: %s", autoUpdateSettings.Version)
e.updateManager.SetVersion(autoUpdateSettings.Version)
}

func (e *Engine) handleSync(update *mgmProto.SyncResponse) error {
e.syncMsgMux.Lock()
defer e.syncMsgMux.Unlock()

if update.NetworkMap != nil && update.NetworkMap.PeerConfig != nil {
e.handleAutoUpdateVersion(update.NetworkMap.PeerConfig.AutoUpdate, false)
}
if update.GetNetbirdConfig() != nil {
wCfg := update.GetNetbirdConfig()
err := e.updateTURNs(wCfg.GetTurns())
Expand Down
Loading
Loading