Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui fix, netmaker-desktop improvements #3347

Open
wants to merge 2 commits into
base: release-v0.30.0
Choose a base branch
from
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
1 change: 1 addition & 0 deletions controllers/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ func updateNode(w http.ResponseWriter, r *http.Request) {
logic.UpdateRelayed(&currentNode, newNode)
}

logic.GetNodeStatus(newNode, false)
apiNode := newNode.ConvertToAPINode()
logger.Log(
1,
Expand Down
2 changes: 2 additions & 0 deletions models/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ type UserRemoteGws struct {
Metadata string `json:"metadata"`
AllowedEndpoints []string `json:"allowed_endpoints"`
NetworkAddresses []string `json:"network_addresses"`
DnsAddress string `json:"dns_address"`
Addresses string `json:"addresses"`
}

// UserRAGs - struct for user access gws
Expand Down
7 changes: 7 additions & 0 deletions pro/controllers/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/gravitl/netmaker/pro/email"
proLogic "github.com/gravitl/netmaker/pro/logic"
"github.com/gravitl/netmaker/servercfg"
"github.com/gravitl/netmaker/utils"
"golang.org/x/exp/slog"
)

Expand Down Expand Up @@ -1034,6 +1035,8 @@ func getRemoteAccessGatewayConf(w http.ResponseWriter, r *http.Request) {
Metadata: node.Metadata,
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
DnsAddress: node.IngressDNS,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extclient config already has dns field

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. but in that case, we wont be able to show the users the dns field unless they have an extclient

Addresses: utils.NonemptyStringToCsv(node.Address.String(), node.Address6.String()),
}

slog.Debug("returned user gw config", "user", user.UserName, "gws", userGw)
Expand Down Expand Up @@ -1117,6 +1120,8 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
Metadata: node.Metadata,
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
DnsAddress: node.IngressDNS,
Addresses: utils.NonemptyStringToCsv(node.Address.String(), node.Address6.String()),
})
userGws[node.Network] = gws
delete(userGwNodes, node.ID.String())
Expand Down Expand Up @@ -1154,6 +1159,8 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
Metadata: node.Metadata,
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
DnsAddress: node.IngressDNS,
Addresses: utils.NonemptyStringToCsv(node.Address.String(), node.Address6.String()),
})
userGws[node.Network] = gws
}
Expand Down
20 changes: 19 additions & 1 deletion utils/utils.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package utils

import "time"
import (
"strings"
"time"
)

// RetryStrategy specifies a strategy to retry an operation after waiting a while,
// with hooks for successful and unsuccessful (>=max) tries.
Expand Down Expand Up @@ -39,3 +42,18 @@ func (rs RetryStrategy) DoStrategy() {
return
}
}

// NonemptyStringToCsv takes a bunch of strings, filters out empty ones and returns a csv version of the string
func NonemptyStringToCsv(strs ...string) string {
var sb strings.Builder
for _, str := range strs {
trimmedStr := strings.TrimSpace(str)
if trimmedStr != "" && trimmedStr != "<nil>" {
if sb.Len() > 0 {
sb.WriteString(", ")
}
sb.WriteString(str)
}
}
return sb.String()
}