Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 13 additions & 15 deletions client/internal/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ const (
PeerConnectionTimeoutMax = 45000 // ms
PeerConnectionTimeoutMin = 30000 // ms
connInitLimit = 200
// skipAutoUpdateVersion used as a placeholder for autoUpdateVersion in proto responses to indicate response contains no new updates
skipAutoUpdateVersion = "skip"
disableAutoUpdate = "disabled"
disableAutoUpdate = "disabled"
)

var ErrResetConnection = fmt.Errorf("reset connection")
Expand Down Expand Up @@ -704,25 +702,25 @@ func (e *Engine) PopulateNetbirdConfig(netbirdConfig *mgmProto.NetbirdConfig, mg
}

func (e *Engine) handleAutoUpdateVersion(autoUpdateVersion string) {
if autoUpdateVersion != skipAutoUpdateVersion {
if e.updateManager == nil && autoUpdateVersion != disableAutoUpdate {
e.updateManager = updatemanager.NewUpdateManager(e.statusRecorder)
e.updateManager.Start(e.ctx)
} else if e.updateManager != nil && autoUpdateVersion == disableAutoUpdate {
e.updateManager.Stop()
e.updateManager = nil
}
if e.updateManager != nil {
e.updateManager.SetVersion(autoUpdateVersion)
}
if e.updateManager == nil && autoUpdateVersion != disableAutoUpdate {
e.updateManager = updatemanager.NewUpdateManager(e.statusRecorder)
e.updateManager.Start(e.ctx)
} else if e.updateManager != nil && autoUpdateVersion == disableAutoUpdate {
e.updateManager.Stop()
e.updateManager = nil
}
if e.updateManager != nil {
e.updateManager.SetVersion(autoUpdateVersion)
}
}

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

e.handleAutoUpdateVersion(update.AutoUpdateVersion)
if update.NetworkMap != nil && update.NetworkMap.PeerConfig != nil {
e.handleAutoUpdateVersion(update.NetworkMap.PeerConfig.AutoUpdateVersion)
}
if update.GetNetbirdConfig() != nil {
wCfg := update.GetNetbirdConfig()
err := e.updateTURNs(wCfg.GetTurns())
Expand Down
2 changes: 0 additions & 2 deletions management/server/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ const (
peerSchedulerRetryInterval = 3 * time.Second
emptyUserID = "empty user ID in claims"
errorGettingDomainAccIDFmt = "error getting account ID by private domain: %v"
// skipAutoUpdateVersion used as a placeholder for autoUpdateVersion in proto responses to indicate response contains no new updates
skipAutoUpdateVersion = "skip"
)

type userLoggedInOnce bool
Expand Down
11 changes: 6 additions & 5 deletions management/server/grpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,19 +710,20 @@ func toPeerConfig(peer *nbpeer.Peer, network *types.Network, dnsName string, set
Fqdn: fqdn,
RoutingPeerDnsResolutionEnabled: settings.RoutingPeerDNSResolutionEnabled,
LazyConnectionEnabled: settings.LazyConnectionEnabled,
AutoUpdateVersion: settings.AutoUpdateVersion,
}
}

func toSyncResponse(ctx context.Context, config *nbconfig.Config, peer *nbpeer.Peer, turnCredentials *Token, relayCredentials *Token, networkMap *types.NetworkMap, dnsName string, checks []*posture.Checks, dnsCache *DNSConfigCache, settings *types.Settings, extraSettings *types.ExtraSettings, peerGroups []string) *proto.SyncResponse {
response := &proto.SyncResponse{
PeerConfig: toPeerConfig(peer, networkMap.Network, dnsName, settings),
NetworkMap: &proto.NetworkMap{
Serial: networkMap.Network.CurrentSerial(),
Routes: toProtocolRoutes(networkMap.Routes),
DNSConfig: toProtocolDNSConfig(networkMap.DNSConfig, dnsCache),
Serial: networkMap.Network.CurrentSerial(),
Routes: toProtocolRoutes(networkMap.Routes),
DNSConfig: toProtocolDNSConfig(networkMap.DNSConfig, dnsCache),
PeerConfig: toPeerConfig(peer, networkMap.Network, dnsName, settings),
},
Checks: toProtocolChecks(ctx, checks),
AutoUpdateVersion: settings.AutoUpdateVersion,
Checks: toProtocolChecks(ctx, checks),
}

nbConfig := toNetbirdConfig(config, turnCredentials, relayCredentials, extraSettings)
Expand Down
2 changes: 1 addition & 1 deletion management/server/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1554,8 +1554,8 @@ func deletePeers(ctx context.Context, am *DefaultAccountManager, transaction sto
RemotePeersIsEmpty: true,
FirewallRules: []*proto.FirewallRule{},
FirewallRulesIsEmpty: true,
PeerConfig: toPeerConfig(peer, network, dnsDomain, settings),
},
AutoUpdateVersion: settings.AutoUpdateVersion,
},
NetworkMap: &types.NetworkMap{},
})
Expand Down
2 changes: 0 additions & 2 deletions management/server/token_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ func (m *TimeBasedAuthSecretsManager) pushNewTURNAndRelayTokens(ctx context.Cont
NetbirdConfig: &proto.NetbirdConfig{
Turns: turns,
},
AutoUpdateVersion: skipAutoUpdateVersion,
}

// workaround for the case when client is unable to handle turn and relay updates at different time
Expand Down Expand Up @@ -247,7 +246,6 @@ func (m *TimeBasedAuthSecretsManager) pushNewRelayTokens(ctx context.Context, ac
},
// omit Turns to avoid updates there
},
AutoUpdateVersion: skipAutoUpdateVersion,
}

m.extendNetbirdConfig(ctx, peerID, accountID, update)
Expand Down
Loading
Loading