feat: add node status to rac response (#3327)

This commit is contained in:
Aceix 2025-02-24 05:23:45 +00:00 committed by GitHub
parent 2fcdd865c8
commit a805901a73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 11 deletions

View file

@ -32,17 +32,18 @@ type IngressGwUsers struct {
// UserRemoteGws - struct to hold user's remote gws
type UserRemoteGws struct {
GwID string `json:"remote_access_gw_id"`
GWName string `json:"gw_name"`
Network string `json:"network"`
Connected bool `json:"connected"`
IsInternetGateway bool `json:"is_internet_gateway"`
GwClient ExtClient `json:"gw_client"`
GwPeerPublicKey string `json:"gw_peer_public_key"`
GwListenPort int `json:"gw_listen_port"`
Metadata string `json:"metadata"`
AllowedEndpoints []string `json:"allowed_endpoints"`
NetworkAddresses []string `json:"network_addresses"`
GwID string `json:"remote_access_gw_id"`
GWName string `json:"gw_name"`
Network string `json:"network"`
Connected bool `json:"connected"`
IsInternetGateway bool `json:"is_internet_gateway"`
GwClient ExtClient `json:"gw_client"`
GwPeerPublicKey string `json:"gw_peer_public_key"`
GwListenPort int `json:"gw_listen_port"`
Metadata string `json:"metadata"`
AllowedEndpoints []string `json:"allowed_endpoints"`
NetworkAddresses []string `json:"network_addresses"`
Status NodeStatus `json:"status"`
}
// UserRAGs - struct for user access gws

View file

@ -1102,6 +1102,10 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
slog.Error("failed to get node network", "error", err)
continue
}
nodesWithStatus := logic.AddStatusToNodes([]models.Node{node})
if len(nodesWithStatus) > 0 {
node = nodesWithStatus[0]
}
gws := userGws[node.Network]
extClient.AllowedIPs = logic.GetExtclientAllowedIPs(extClient)
@ -1117,6 +1121,7 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
Metadata: node.Metadata,
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
Status: node.Status,
})
userGws[node.Network] = gws
delete(userGwNodes, node.ID.String())
@ -1138,6 +1143,10 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
if err != nil {
continue
}
nodesWithStatus := logic.AddStatusToNodes([]models.Node{node})
if len(nodesWithStatus) > 0 {
node = nodesWithStatus[0]
}
network, err := logic.GetNetwork(node.Network)
if err != nil {
slog.Error("failed to get node network", "error", err)
@ -1154,6 +1163,7 @@ func getUserRemoteAccessGwsV1(w http.ResponseWriter, r *http.Request) {
Metadata: node.Metadata,
AllowedEndpoints: getAllowedRagEndpoints(&node, host),
NetworkAddresses: []string{network.AddressRange, network.AddressRange6},
Status: node.Status,
})
userGws[node.Network] = gws
}