mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-06 21:24:16 +08:00
feat: add node status to rac response (#3327)
This commit is contained in:
parent
2fcdd865c8
commit
a805901a73
2 changed files with 22 additions and 11 deletions
|
@ -32,17 +32,18 @@ type IngressGwUsers struct {
|
||||||
|
|
||||||
// UserRemoteGws - struct to hold user's remote gws
|
// UserRemoteGws - struct to hold user's remote gws
|
||||||
type UserRemoteGws struct {
|
type UserRemoteGws struct {
|
||||||
GwID string `json:"remote_access_gw_id"`
|
GwID string `json:"remote_access_gw_id"`
|
||||||
GWName string `json:"gw_name"`
|
GWName string `json:"gw_name"`
|
||||||
Network string `json:"network"`
|
Network string `json:"network"`
|
||||||
Connected bool `json:"connected"`
|
Connected bool `json:"connected"`
|
||||||
IsInternetGateway bool `json:"is_internet_gateway"`
|
IsInternetGateway bool `json:"is_internet_gateway"`
|
||||||
GwClient ExtClient `json:"gw_client"`
|
GwClient ExtClient `json:"gw_client"`
|
||||||
GwPeerPublicKey string `json:"gw_peer_public_key"`
|
GwPeerPublicKey string `json:"gw_peer_public_key"`
|
||||||
GwListenPort int `json:"gw_listen_port"`
|
GwListenPort int `json:"gw_listen_port"`
|
||||||
Metadata string `json:"metadata"`
|
Metadata string `json:"metadata"`
|
||||||
AllowedEndpoints []string `json:"allowed_endpoints"`
|
AllowedEndpoints []string `json:"allowed_endpoints"`
|
||||||
NetworkAddresses []string `json:"network_addresses"`
|
NetworkAddresses []string `json:"network_addresses"`
|
||||||
|
Status NodeStatus `json:"status"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserRAGs - struct for user access gws
|
// UserRAGs - struct for user access gws
|
||||||
|
|
|
@ -1102,6 +1102,10 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
|
||||||
slog.Error("failed to get node network", "error", err)
|
slog.Error("failed to get node network", "error", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
nodesWithStatus := logic.AddStatusToNodes([]models.Node{node})
|
||||||
|
if len(nodesWithStatus) > 0 {
|
||||||
|
node = nodesWithStatus[0]
|
||||||
|
}
|
||||||
|
|
||||||
gws := userGws[node.Network]
|
gws := userGws[node.Network]
|
||||||
extClient.AllowedIPs = logic.GetExtclientAllowedIPs(extClient)
|
extClient.AllowedIPs = logic.GetExtclientAllowedIPs(extClient)
|
||||||
|
@ -1117,6 +1121,7 @@ func getUserRemoteAccessGwsV1(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},
|
||||||
|
Status: node.Status,
|
||||||
})
|
})
|
||||||
userGws[node.Network] = gws
|
userGws[node.Network] = gws
|
||||||
delete(userGwNodes, node.ID.String())
|
delete(userGwNodes, node.ID.String())
|
||||||
|
@ -1138,6 +1143,10 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
nodesWithStatus := logic.AddStatusToNodes([]models.Node{node})
|
||||||
|
if len(nodesWithStatus) > 0 {
|
||||||
|
node = nodesWithStatus[0]
|
||||||
|
}
|
||||||
network, err := logic.GetNetwork(node.Network)
|
network, err := logic.GetNetwork(node.Network)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error("failed to get node network", "error", err)
|
slog.Error("failed to get node network", "error", err)
|
||||||
|
@ -1154,6 +1163,7 @@ func getUserRemoteAccessGwsV1(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},
|
||||||
|
Status: node.Status,
|
||||||
})
|
})
|
||||||
userGws[node.Network] = gws
|
userGws[node.Network] = gws
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue