[client] Feat: Support Multiple Profiles (#3980)

[client] Feat: Support Multiple Profiles (#3980)
This commit is contained in:
hakansa
2025-07-25 16:54:46 +03:00
committed by GitHub
parent e0d9306b05
commit cb8b6ca59b
53 changed files with 4651 additions and 768 deletions

View File

@@ -98,9 +98,10 @@ type OutputOverview struct {
NSServerGroups []NsServerGroupStateOutput `json:"dnsServers" yaml:"dnsServers"`
Events []SystemEventOutput `json:"events" yaml:"events"`
LazyConnectionEnabled bool `json:"lazyConnectionEnabled" yaml:"lazyConnectionEnabled"`
ProfileName string `json:"profileName" yaml:"profileName"`
}
func ConvertToStatusOutputOverview(resp *proto.StatusResponse, anon bool, statusFilter string, prefixNamesFilter []string, prefixNamesFilterMap map[string]struct{}, ipsFilter map[string]struct{}, connectionTypeFilter string) OutputOverview {
func ConvertToStatusOutputOverview(resp *proto.StatusResponse, anon bool, statusFilter string, prefixNamesFilter []string, prefixNamesFilterMap map[string]struct{}, ipsFilter map[string]struct{}, connectionTypeFilter string, profName string) OutputOverview {
pbFullStatus := resp.GetFullStatus()
managementState := pbFullStatus.GetManagementState()
@@ -138,6 +139,7 @@ func ConvertToStatusOutputOverview(resp *proto.StatusResponse, anon bool, status
NSServerGroups: mapNSGroups(pbFullStatus.GetDnsServers()),
Events: mapEvents(pbFullStatus.GetEvents()),
LazyConnectionEnabled: pbFullStatus.GetLazyConnectionEnabled(),
ProfileName: profName,
}
if anon {
@@ -406,6 +408,7 @@ func ParseGeneralSummary(overview OutputOverview, showURL bool, showRelays bool,
"OS: %s\n"+
"Daemon version: %s\n"+
"CLI version: %s\n"+
"Profile: %s\n"+
"Management: %s\n"+
"Signal: %s\n"+
"Relays: %s\n"+
@@ -421,6 +424,7 @@ func ParseGeneralSummary(overview OutputOverview, showURL bool, showRelays bool,
fmt.Sprintf("%s/%s%s", goos, goarch, goarm),
overview.DaemonVersion,
version.NetbirdVersion(),
overview.ProfileName,
managementConnString,
signalConnString,
relaysString,

View File

@@ -234,7 +234,7 @@ var overview = OutputOverview{
}
func TestConversionFromFullStatusToOutputOverview(t *testing.T) {
convertedResult := ConvertToStatusOutputOverview(resp, false, "", nil, nil, nil, "")
convertedResult := ConvertToStatusOutputOverview(resp, false, "", nil, nil, nil, "", "")
assert.Equal(t, overview, convertedResult)
}
@@ -384,7 +384,8 @@ func TestParsingToJSON(t *testing.T) {
}
],
"events": [],
"lazyConnectionEnabled": false
"lazyConnectionEnabled": false,
"profileName":""
}`
// @formatter:on
@@ -486,6 +487,7 @@ dnsServers:
error: timeout
events: []
lazyConnectionEnabled: false
profileName: ""
`
assert.Equal(t, expectedYAML, yaml)
@@ -538,6 +540,7 @@ Events: No events recorded
OS: %s/%s
Daemon version: 0.14.1
CLI version: %s
Profile:
Management: Connected to my-awesome-management.com:443
Signal: Connected to my-awesome-signal.com:443
Relays:
@@ -565,6 +568,7 @@ func TestParsingToShortVersion(t *testing.T) {
expectedString := fmt.Sprintf("OS: %s/%s", runtime.GOOS, runtime.GOARCH) + `
Daemon version: 0.14.1
CLI version: development
Profile:
Management: Connected
Signal: Connected
Relays: 1/2 Available