From 37ce40ede647164d0ce60112b9375d7ec27bf8cb Mon Sep 17 00:00:00 2001 From: bcmmbaga Date: Fri, 5 Jun 2026 23:53:48 +0300 Subject: [PATCH] build client config in sync response --- .../internals/shared/grpc/conversion.go | 7 +----- management/internals/shared/grpc/token_mgr.go | 24 ------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/management/internals/shared/grpc/conversion.go b/management/internals/shared/grpc/conversion.go index b4a0d8b28..ee7a4a1d3 100644 --- a/management/internals/shared/grpc/conversion.go +++ b/management/internals/shared/grpc/conversion.go @@ -12,8 +12,6 @@ import ( goproto "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/timestamppb" - integrationsConfig "github.com/netbirdio/management-integrations/integrations/config" - "github.com/netbirdio/netbird/client/ssh/auth" nbdns "github.com/netbirdio/netbird/dns" @@ -147,9 +145,7 @@ func ToSyncResponse(ctx context.Context, config *nbconfig.Config, httpConfig *nb Checks: toProtocolChecks(ctx, checks), } - nbConfig := toNetbirdConfig(config, turnCredentials, relayCredentials, extraSettings) - extendedConfig := integrationsConfig.ExtendNetBirdConfig(peer.ID, peerGroups, nbConfig, extraSettings) - response.NetbirdConfig = extendedConfig + response.NetbirdConfig = toNetbirdConfig(config, turnCredentials, relayCredentials, extraSettings) response.NetworkMap.PeerConfig = response.PeerConfig @@ -363,7 +359,6 @@ func toProtocolFirewallRules(rules []*types.FirewallRule, includeIPv6, useSource return result } - // populateSourcePrefixes sets SourcePrefixes on fwRule and returns any // additional rules needed (e.g. a v6 wildcard clone when the peer IP is unspecified). func populateSourcePrefixes(fwRule *proto.FirewallRule, rule *types.FirewallRule, includeIPv6 bool) []*proto.FirewallRule { diff --git a/management/internals/shared/grpc/token_mgr.go b/management/internals/shared/grpc/token_mgr.go index 65e58ad41..110b87461 100644 --- a/management/internals/shared/grpc/token_mgr.go +++ b/management/internals/shared/grpc/token_mgr.go @@ -12,7 +12,6 @@ import ( log "github.com/sirupsen/logrus" "golang.zx2c4.com/wireguard/wgctrl/wgtypes" - integrationsConfig "github.com/netbirdio/management-integrations/integrations/config" "github.com/netbirdio/netbird/management/internals/controllers/network_map" nbconfig "github.com/netbirdio/netbird/management/internals/server/config" "github.com/netbirdio/netbird/management/server/groups" @@ -41,8 +40,6 @@ type TimeBasedAuthSecretsManager struct { turnHmacToken *auth.TimedHMAC relayHmacToken *authv2.Generator updateManager network_map.PeersUpdateManager - settingsManager settings.Manager - groupsManager groups.Manager turnCancelMap map[string]chan struct{} relayCancelMap map[string]chan struct{} wgKey wgtypes.Key @@ -62,8 +59,6 @@ func NewTimeBasedAuthSecretsManager(updateManager network_map.PeersUpdateManager relayCfg: relayCfg, turnCancelMap: make(map[string]chan struct{}), relayCancelMap: make(map[string]chan struct{}), - settingsManager: settingsManager, - groupsManager: groupsManager, wgKey: key, } @@ -239,8 +234,6 @@ func (m *TimeBasedAuthSecretsManager) pushNewTURNAndRelayTokens(ctx context.Cont } } - m.extendNetbirdConfig(ctx, peerID, accountID, update) - log.WithContext(ctx).Debugf("sending new TURN credentials to peer %s", peerID) m.updateManager.SendUpdate(ctx, peerID, &network_map.UpdateMessage{ Update: update, @@ -266,26 +259,9 @@ func (m *TimeBasedAuthSecretsManager) pushNewRelayTokens(ctx context.Context, ac }, } - m.extendNetbirdConfig(ctx, peerID, accountID, update) - log.WithContext(ctx).Debugf("sending new relay credentials to peer %s", peerID) m.updateManager.SendUpdate(ctx, peerID, &network_map.UpdateMessage{ Update: update, MessageType: network_map.MessageTypeControlConfig, }) } - -func (m *TimeBasedAuthSecretsManager) extendNetbirdConfig(ctx context.Context, peerID, accountID string, update *proto.SyncResponse) { - extraSettings, err := m.settingsManager.GetExtraSettings(ctx, accountID) - if err != nil { - log.WithContext(ctx).Errorf("failed to get extra settings: %v", err) - } - - peerGroups, err := m.groupsManager.GetPeerGroupIDs(ctx, accountID, peerID) - if err != nil { - log.WithContext(ctx).Errorf("failed to get peer groups: %v", err) - } - - extendedConfig := integrationsConfig.ExtendNetBirdConfig(peerID, peerGroups, update.NetbirdConfig, extraSettings) - update.NetbirdConfig = extendedConfig -}