mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 08:47:35 +08:00
feat: send gateway dns and private address (#3378)
This commit is contained in:
@@ -44,6 +44,8 @@ type UserRemoteGws struct {
|
||||
AllowedEndpoints []string `json:"allowed_endpoints"`
|
||||
NetworkAddresses []string `json:"network_addresses"`
|
||||
Status NodeStatus `json:"status"`
|
||||
DnsAddress string `json:"dns_address"`
|
||||
Addresses string `json:"addresses"`
|
||||
}
|
||||
|
||||
// UserRAGs - struct for user access gws
|
||||
|
@@ -21,6 +21,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"
|
||||
)
|
||||
|
||||
@@ -1074,6 +1075,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,
|
||||
Addresses: utils.NoEmptyStringToCsv(node.Address.String(), node.Address6.String()),
|
||||
}
|
||||
|
||||
slog.Debug("returned user gw config", "user", user.UserName, "gws", userGw)
|
||||
@@ -1165,6 +1168,8 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
|
||||
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
|
||||
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
|
||||
Status: node.Status,
|
||||
DnsAddress: node.IngressDNS,
|
||||
Addresses: utils.NoEmptyStringToCsv(node.Address.String(), node.Address6.String()),
|
||||
})
|
||||
userGws[node.Network] = gws
|
||||
delete(userGwNodes, node.ID.String())
|
||||
@@ -1207,6 +1212,8 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
|
||||
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
|
||||
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
|
||||
Status: node.Status,
|
||||
DnsAddress: node.IngressDNS,
|
||||
Addresses: utils.NoEmptyStringToCsv(node.Address.String(), node.Address6.String()),
|
||||
})
|
||||
userGws[node.Network] = gws
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package utils
|
||||
import (
|
||||
"log/slog"
|
||||
"runtime"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -59,3 +60,18 @@ func TraceCaller() {
|
||||
slog.Debug("Called from function: %s\n", "func-name", funcName)
|
||||
slog.Debug("File: %s, Line: %d\n", "file", file, "line-no", line)
|
||||
}
|
||||
|
||||
// NoEmptyStringToCsv takes a bunch of strings, filters out empty ones and returns a csv version of the string
|
||||
func NoEmptyStringToCsv(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()
|
||||
}
|
||||
|
Reference in New Issue
Block a user