mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-10 11:12:25 +08:00
ignore setting up rules when default poliy is enabled
This commit is contained in:
@@ -403,8 +403,17 @@ func ToggleExtClientConnectivity(client *models.ExtClient, enable bool) (models.
|
||||
}
|
||||
|
||||
func GetStaticNodeIps(node models.Node) (ips []net.IP) {
|
||||
defaultUserPolicy, _ := GetDefaultPolicy(models.NetworkID(node.Network), models.UserPolicy)
|
||||
defaultDevicePolicy, _ := GetDefaultPolicy(models.NetworkID(node.Network), models.DevicePolicy)
|
||||
|
||||
extclients := GetStaticNodesByNetwork(models.NetworkID(node.Network), false)
|
||||
for _, extclient := range extclients {
|
||||
if extclient.IsUserNode && defaultUserPolicy.Enabled {
|
||||
continue
|
||||
}
|
||||
if !extclient.IsUserNode && defaultDevicePolicy.Enabled {
|
||||
continue
|
||||
}
|
||||
if extclient.StaticNode.Address != "" {
|
||||
ips = append(ips, extclient.StaticNode.AddressIPNet4().IP)
|
||||
}
|
||||
@@ -417,9 +426,11 @@ func GetStaticNodeIps(node models.Node) (ips []net.IP) {
|
||||
|
||||
func GetFwRulesOnIngressGateway(node models.Node) (rules []models.FwRule) {
|
||||
// fetch user access to static clients via policies
|
||||
|
||||
defaultUserPolicy, _ := GetDefaultPolicy(models.NetworkID(node.Network), models.UserPolicy)
|
||||
defaultDevicePolicy, _ := GetDefaultPolicy(models.NetworkID(node.Network), models.DevicePolicy)
|
||||
nodes, _ := GetNetworkNodes(node.Network)
|
||||
nodes = append(nodes, GetStaticNodesByNetwork(models.NetworkID(node.Network), true)...)
|
||||
if !defaultUserPolicy.Enabled {
|
||||
userNodes := GetStaticUserNodesByNetwork(models.NetworkID(node.Network))
|
||||
for _, userNodeI := range userNodes {
|
||||
for _, peer := range nodes {
|
||||
@@ -472,7 +483,10 @@ func GetFwRulesOnIngressGateway(node models.Node) (rules []models.FwRule) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if defaultDevicePolicy.Enabled {
|
||||
return
|
||||
}
|
||||
for _, nodeI := range nodes {
|
||||
if !nodeI.IsStatic || nodeI.IsUserNode {
|
||||
continue
|
||||
|
Reference in New Issue
Block a user