From e3657610bcc092978eb21a28cdde9921de3a49f0 Mon Sep 17 00:00:00 2001 From: szakharchenko Date: Wed, 24 Aug 2022 17:30:40 +0300 Subject: [PATCH] Avoid pulling in management code in client (#437) Avoid management code import for the legacy port value, hardcoding it instead (it's literally spelled out in a comment below as well). --- client/internal/connect.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/internal/connect.go b/client/internal/connect.go index fee57695d..6d35113ce 100644 --- a/client/internal/connect.go +++ b/client/internal/connect.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/netbirdio/netbird/client/ssh" nbStatus "github.com/netbirdio/netbird/client/status" - mgmtcmd "github.com/netbirdio/netbird/management/cmd" "strings" "time" @@ -241,6 +240,11 @@ func connectToManagement(ctx context.Context, managementAddr string, ourPrivateK return client, loginResp, nil } +// NB: hardcoded from github.com/netbirdio/netbird/management/cmd to avoid import +// ManagementLegacyPort is the port that was used before by the Management gRPC server. +// It is used for backward compatibility now. +const ManagementLegacyPort = 33073 + // UpdateOldManagementPort checks whether client can switch to the new Management port 443. // If it can switch, then it updates the config and returns a new one. Otherwise, it returns the provided config. // The check is performed only for the NetBird's managed version. @@ -261,7 +265,7 @@ func UpdateOldManagementPort(ctx context.Context, config *Config, configPath str return config, nil } - if mgmTlsEnabled && config.ManagementURL.Port() == fmt.Sprintf("%d", mgmtcmd.ManagementLegacyPort) { + if mgmTlsEnabled && config.ManagementURL.Port() == fmt.Sprintf("%d", ManagementLegacyPort) { newURL, err := ParseURL("Management URL", fmt.Sprintf("%s://%s:%d", config.ManagementURL.Scheme, config.ManagementURL.Hostname(), 443))