diff --git a/controllers/middleware.go b/controllers/middleware.go index 98cb8571..abc22611 100644 --- a/controllers/middleware.go +++ b/controllers/middleware.go @@ -50,8 +50,11 @@ func userMiddleWare(handler http.Handler) http.Handler { if strings.Contains(route, "createrelay") || strings.Contains(route, "deleterelay") { r.Header.Set("TARGET_RSRC", models.RelayRsrc.String()) } - if strings.Contains(route, "gateway") { + r.Header.Set("TARGET_RSRC", models.GatewayRsrc.String()) + } + + if strings.Contains(route, "egress") { r.Header.Set("TARGET_RSRC", models.EgressGwRsrc.String()) } if strings.Contains(route, "networks") { diff --git a/logic/extpeers.go b/logic/extpeers.go index 4b621672..ea571054 100644 --- a/logic/extpeers.go +++ b/logic/extpeers.go @@ -81,12 +81,19 @@ func GetEgressRangesOnNetwork(client *models.ExtClient) ([]string, error) { continue } GetNodeEgressInfo(¤tNode, eli) - if currentNode.EgressDetails.IsInternetGateway && client.IngressGatewayID != currentNode.ID.String() { - continue - } if currentNode.EgressDetails.IsEgressGateway { // add the egress gateway range(s) to the result if len(currentNode.EgressDetails.EgressGatewayRanges) > 0 { - result = append(result, currentNode.EgressDetails.EgressGatewayRanges...) + if currentNode.EgressDetails.IsInternetGateway && client.IngressGatewayID != currentNode.ID.String() { + for _, rangeI := range currentNode.EgressDetails.EgressGatewayRanges { + if rangeI == "0.0.0.0/0" || rangeI == "::/0" { + continue + } else { + result = append(result, rangeI) + } + } + } else { + result = append(result, currentNode.EgressDetails.EgressGatewayRanges...) + } } } } diff --git a/logic/peers.go b/logic/peers.go index db919ece..bc388184 100644 --- a/logic/peers.go +++ b/logic/peers.go @@ -186,12 +186,9 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N } defaultUserPolicy, _ := GetDefaultPolicy(models.NetworkID(node.Network), models.UserPolicy) defaultDevicePolicy, _ := GetDefaultPolicy(models.NetworkID(node.Network), models.DevicePolicy) - anyActiveEgressPolicy := CheckIfAnyActiveEgressPolicy(node) - nodeHasAccessToAllRsrcs := CheckIfNodeHasAccessToAllResources(&node) - anyUniDirectionPolicy := CheckIfAnyPolicyisUniDirectional(node) if (defaultDevicePolicy.Enabled && defaultUserPolicy.Enabled) || - (!anyUniDirectionPolicy && !anyActiveEgressPolicy) || - nodeHasAccessToAllRsrcs { + (!CheckIfAnyPolicyisUniDirectional(node) && !CheckIfAnyActiveEgressPolicy(node)) || + CheckIfNodeHasAccessToAllResources(&node) { aclRule := models.AclRule{ ID: fmt.Sprintf("%s-allowed-network-rules", node.ID.String()), AllowedProtocol: models.ALL, diff --git a/models/user_mgmt.go b/models/user_mgmt.go index 94fa9595..2a09b13a 100644 --- a/models/user_mgmt.go +++ b/models/user_mgmt.go @@ -65,6 +65,7 @@ const ( HostRsrc RsrcType = "hosts" RelayRsrc RsrcType = "relays" RemoteAccessGwRsrc RsrcType = "remote_access_gw" + GatewayRsrc RsrcType = "gateways" ExtClientsRsrc RsrcType = "extclients" InetGwRsrc RsrcType = "inet_gw" EgressGwRsrc RsrcType = "egress" diff --git a/pro/logic/user_mgmt.go b/pro/logic/user_mgmt.go index 119f9735..389b1bb8 100644 --- a/pro/logic/user_mgmt.go +++ b/pro/logic/user_mgmt.go @@ -761,7 +761,6 @@ func GetUserRAGNodes(user models.User) (gws map[string]models.Node) { } } } - } } return