mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-08 07:41:41 +08:00
ignore setting up rules when default poliy is enabled
This commit is contained in:
parent
514e785f7b
commit
502a15ea14
1 changed files with 63 additions and 49 deletions
|
|
@ -403,8 +403,17 @@ func ToggleExtClientConnectivity(client *models.ExtClient, enable bool) (models.
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetStaticNodeIps(node models.Node) (ips []net.IP) {
|
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)
|
extclients := GetStaticNodesByNetwork(models.NetworkID(node.Network), false)
|
||||||
for _, extclient := range extclients {
|
for _, extclient := range extclients {
|
||||||
|
if extclient.IsUserNode && defaultUserPolicy.Enabled {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !extclient.IsUserNode && defaultDevicePolicy.Enabled {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if extclient.StaticNode.Address != "" {
|
if extclient.StaticNode.Address != "" {
|
||||||
ips = append(ips, extclient.StaticNode.AddressIPNet4().IP)
|
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) {
|
func GetFwRulesOnIngressGateway(node models.Node) (rules []models.FwRule) {
|
||||||
// fetch user access to static clients via policies
|
// 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, _ := GetNetworkNodes(node.Network)
|
||||||
nodes = append(nodes, GetStaticNodesByNetwork(models.NetworkID(node.Network), true)...)
|
nodes = append(nodes, GetStaticNodesByNetwork(models.NetworkID(node.Network), true)...)
|
||||||
|
if !defaultUserPolicy.Enabled {
|
||||||
userNodes := GetStaticUserNodesByNetwork(models.NetworkID(node.Network))
|
userNodes := GetStaticUserNodesByNetwork(models.NetworkID(node.Network))
|
||||||
for _, userNodeI := range userNodes {
|
for _, userNodeI := range userNodes {
|
||||||
for _, peer := range nodes {
|
for _, peer := range nodes {
|
||||||
|
|
@ -472,7 +483,10 @@ func GetFwRulesOnIngressGateway(node models.Node) (rules []models.FwRule) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if defaultDevicePolicy.Enabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
for _, nodeI := range nodes {
|
for _, nodeI := range nodes {
|
||||||
if !nodeI.IsStatic || nodeI.IsUserNode {
|
if !nodeI.IsStatic || nodeI.IsUserNode {
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue