mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 01:07:41 +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"`
|
AllowedEndpoints []string `json:"allowed_endpoints"`
|
||||||
NetworkAddresses []string `json:"network_addresses"`
|
NetworkAddresses []string `json:"network_addresses"`
|
||||||
Status NodeStatus `json:"status"`
|
Status NodeStatus `json:"status"`
|
||||||
|
DnsAddress string `json:"dns_address"`
|
||||||
|
Addresses string `json:"addresses"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserRAGs - struct for user access gws
|
// UserRAGs - struct for user access gws
|
||||||
|
@@ -21,6 +21,7 @@ import (
|
|||||||
"github.com/gravitl/netmaker/pro/email"
|
"github.com/gravitl/netmaker/pro/email"
|
||||||
proLogic "github.com/gravitl/netmaker/pro/logic"
|
proLogic "github.com/gravitl/netmaker/pro/logic"
|
||||||
"github.com/gravitl/netmaker/servercfg"
|
"github.com/gravitl/netmaker/servercfg"
|
||||||
|
"github.com/gravitl/netmaker/utils"
|
||||||
"golang.org/x/exp/slog"
|
"golang.org/x/exp/slog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1074,6 +1075,8 @@ func getRemoteAccessGatewayConf(w http.ResponseWriter, r *http.Request) {
|
|||||||
Metadata: node.Metadata,
|
Metadata: node.Metadata,
|
||||||
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
|
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
|
||||||
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
|
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)
|
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),
|
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
|
||||||
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
|
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
|
||||||
Status: node.Status,
|
Status: node.Status,
|
||||||
|
DnsAddress: node.IngressDNS,
|
||||||
|
Addresses: utils.NoEmptyStringToCsv(node.Address.String(), node.Address6.String()),
|
||||||
})
|
})
|
||||||
userGws[node.Network] = gws
|
userGws[node.Network] = gws
|
||||||
delete(userGwNodes, node.ID.String())
|
delete(userGwNodes, node.ID.String())
|
||||||
@@ -1207,6 +1212,8 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
|
|||||||
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
|
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
|
||||||
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
|
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
|
||||||
Status: node.Status,
|
Status: node.Status,
|
||||||
|
DnsAddress: node.IngressDNS,
|
||||||
|
Addresses: utils.NoEmptyStringToCsv(node.Address.String(), node.Address6.String()),
|
||||||
})
|
})
|
||||||
userGws[node.Network] = gws
|
userGws[node.Network] = gws
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ package utils
|
|||||||
import (
|
import (
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -59,3 +60,18 @@ func TraceCaller() {
|
|||||||
slog.Debug("Called from function: %s\n", "func-name", funcName)
|
slog.Debug("Called from function: %s\n", "func-name", funcName)
|
||||||
slog.Debug("File: %s, Line: %d\n", "file", file, "line-no", line)
|
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