mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-07 09:41:37 +08:00
resolve merge conflicts
This commit is contained in:
@@ -326,6 +326,7 @@ func getNetworkNodes(w http.ResponseWriter, r *http.Request) {
|
|||||||
if len(filteredNodes) > 0 {
|
if len(filteredNodes) > 0 {
|
||||||
nodes = filteredNodes
|
nodes = filteredNodes
|
||||||
}
|
}
|
||||||
|
nodes = logic.AddStaticNodestoList(nodes)
|
||||||
|
|
||||||
// returns all the nodes in JSON/API format
|
// returns all the nodes in JSON/API format
|
||||||
apiNodes := logic.GetAllNodesAPI(nodes[:])
|
apiNodes := logic.GetAllNodesAPI(nodes[:])
|
||||||
@@ -363,7 +364,9 @@ func getAllNodes(w http.ResponseWriter, r *http.Request) {
|
|||||||
if !userPlatformRole.FullAccess {
|
if !userPlatformRole.FullAccess {
|
||||||
nodes = logic.GetFilteredNodesByUserAccess(*user, nodes)
|
nodes = logic.GetFilteredNodesByUserAccess(*user, nodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
nodes = logic.AddStaticNodestoList(nodes)
|
||||||
// return all the nodes in JSON/API format
|
// return all the nodes in JSON/API format
|
||||||
apiNodes := logic.GetAllNodesAPI(nodes[:])
|
apiNodes := logic.GetAllNodesAPI(nodes[:])
|
||||||
logger.Log(3, r.Header.Get("user"), "fetched all nodes they have access to")
|
logger.Log(3, r.Header.Get("user"), "fetched all nodes they have access to")
|
||||||
|
@@ -528,3 +528,40 @@ func GetExtclientAllowedIPs(client models.ExtClient) (allowedIPs []string) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetStaticNodesByNetwork(network models.NetworkID) (staticNode []models.Node) {
|
||||||
|
extClients, err := GetAllExtClients()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, extI := range extClients {
|
||||||
|
if extI.Network == network.String() {
|
||||||
|
n := models.Node{
|
||||||
|
IsStatic: true,
|
||||||
|
StaticNode: extI,
|
||||||
|
IsUserNode: extI.RemoteAccessClientID != "",
|
||||||
|
}
|
||||||
|
staticNode = append(staticNode, n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStaticNodesByGw(gwNode models.Node) (staticNode []models.Node) {
|
||||||
|
extClients, err := GetAllExtClients()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, extI := range extClients {
|
||||||
|
if extI.IngressGatewayID == gwNode.ID.String() {
|
||||||
|
n := models.Node{
|
||||||
|
IsStatic: true,
|
||||||
|
StaticNode: extI,
|
||||||
|
IsUserNode: extI.RemoteAccessClientID != "",
|
||||||
|
}
|
||||||
|
staticNode = append(staticNode, n)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@@ -378,6 +378,20 @@ func GetAllNodes() ([]models.Node, error) {
|
|||||||
return nodes, nil
|
return nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AddStaticNodestoList(nodes []models.Node) []models.Node {
|
||||||
|
netMap := make(map[string]struct{})
|
||||||
|
for _, node := range nodes {
|
||||||
|
if _, ok := netMap[node.Network]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if node.IsIngressGateway {
|
||||||
|
nodes = append(nodes, GetStaticNodesByNetwork(models.NetworkID(node.Network))...)
|
||||||
|
netMap[node.Network] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodes
|
||||||
|
}
|
||||||
|
|
||||||
// GetNetworkByNode - gets the network model from a node
|
// GetNetworkByNode - gets the network model from a node
|
||||||
func GetNetworkByNode(node *models.Node) (models.Network, error) {
|
func GetNetworkByNode(node *models.Node) (models.Network, error) {
|
||||||
|
|
||||||
|
@@ -49,6 +49,9 @@ type ApiNode struct {
|
|||||||
InternetGwID string `json:"internetgw_node_id" yaml:"internetgw_node_id"`
|
InternetGwID string `json:"internetgw_node_id" yaml:"internetgw_node_id"`
|
||||||
AdditionalRagIps []string `json:"additional_rag_ips" yaml:"additional_rag_ips"`
|
AdditionalRagIps []string `json:"additional_rag_ips" yaml:"additional_rag_ips"`
|
||||||
Tags map[TagID]struct{} `json:"tags" yaml:"tags"`
|
Tags map[TagID]struct{} `json:"tags" yaml:"tags"`
|
||||||
|
IsStatic bool `json:"is_static"`
|
||||||
|
IsUserNode bool `json:"is_user_node"`
|
||||||
|
StaticNode ExtClient `json:"static_node"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApiNode.ConvertToServerNode - converts an api node to a server node
|
// ApiNode.ConvertToServerNode - converts an api node to a server node
|
||||||
@@ -186,6 +189,9 @@ func (nm *Node) ConvertToAPINode() *ApiNode {
|
|||||||
for _, ip := range nm.AdditionalRagIps {
|
for _, ip := range nm.AdditionalRagIps {
|
||||||
apiNode.AdditionalRagIps = append(apiNode.AdditionalRagIps, ip.String())
|
apiNode.AdditionalRagIps = append(apiNode.AdditionalRagIps, ip.String())
|
||||||
}
|
}
|
||||||
|
apiNode.IsStatic = nm.IsStatic
|
||||||
|
apiNode.IsUserNode = nm.IsUserNode
|
||||||
|
apiNode.StaticNode = nm.StaticNode
|
||||||
return &apiNode
|
return &apiNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -100,6 +100,9 @@ type Node struct {
|
|||||||
InternetGwID string `json:"internetgw_node_id" yaml:"internetgw_node_id"`
|
InternetGwID string `json:"internetgw_node_id" yaml:"internetgw_node_id"`
|
||||||
AdditionalRagIps []net.IP `json:"additional_rag_ips" yaml:"additional_rag_ips" swaggertype:"array,number"`
|
AdditionalRagIps []net.IP `json:"additional_rag_ips" yaml:"additional_rag_ips" swaggertype:"array,number"`
|
||||||
Tags map[TagID]struct{} `json:"tags" yaml:"tags"`
|
Tags map[TagID]struct{} `json:"tags" yaml:"tags"`
|
||||||
|
IsStatic bool `json:"is_static"`
|
||||||
|
IsUserNode bool `json:"is_user_node"`
|
||||||
|
StaticNode ExtClient `json:"static_node"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// LegacyNode - legacy struct for node model
|
// LegacyNode - legacy struct for node model
|
||||||
|
@@ -687,7 +687,9 @@ func GetFilteredNodesByUserAccess(user models.User, nodes []models.Node) (filter
|
|||||||
|
|
||||||
nodesMap := make(map[string]struct{})
|
nodesMap := make(map[string]struct{})
|
||||||
allNetworkRoles := make(map[models.UserRoleID]struct{})
|
allNetworkRoles := make(map[models.UserRoleID]struct{})
|
||||||
|
defer func() {
|
||||||
|
filteredNodes = logic.AddStaticNodestoList(filteredNodes)
|
||||||
|
}()
|
||||||
if len(user.NetworkRoles) > 0 {
|
if len(user.NetworkRoles) > 0 {
|
||||||
for _, netRoles := range user.NetworkRoles {
|
for _, netRoles := range user.NetworkRoles {
|
||||||
for netRoleI := range netRoles {
|
for netRoleI := range netRoles {
|
||||||
@@ -696,7 +698,8 @@ func GetFilteredNodesByUserAccess(user models.User, nodes []models.Node) (filter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, ok := user.NetworkRoles[models.AllNetworks]; ok {
|
if _, ok := user.NetworkRoles[models.AllNetworks]; ok {
|
||||||
return nodes
|
filteredNodes = nodes
|
||||||
|
return
|
||||||
}
|
}
|
||||||
if len(user.UserGroups) > 0 {
|
if len(user.UserGroups) > 0 {
|
||||||
for userGID := range user.UserGroups {
|
for userGID := range user.UserGroups {
|
||||||
@@ -704,7 +707,8 @@ func GetFilteredNodesByUserAccess(user models.User, nodes []models.Node) (filter
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
if len(userG.NetworkRoles) > 0 {
|
if len(userG.NetworkRoles) > 0 {
|
||||||
if _, ok := userG.NetworkRoles[models.AllNetworks]; ok {
|
if _, ok := userG.NetworkRoles[models.AllNetworks]; ok {
|
||||||
return nodes
|
filteredNodes = nodes
|
||||||
|
return
|
||||||
}
|
}
|
||||||
for _, netRoles := range userG.NetworkRoles {
|
for _, netRoles := range userG.NetworkRoles {
|
||||||
for netRoleI := range netRoles {
|
for netRoleI := range netRoles {
|
||||||
|
Reference in New Issue
Block a user