egress + inress bug fixes #284 & #285

This commit is contained in:
0xdcarns
2021-10-01 10:33:32 -04:00
parent 1661f3dabf
commit da26802865
2 changed files with 5 additions and 1 deletions

View File

@@ -597,6 +597,10 @@ func DeleteEgressGateway(network, macaddress string) (models.Node, error) {
node.EgressGatewayRanges = []string{}
node.PostUp = ""
node.PostDown = ""
if node.IsIngressGateway == "yes" { // check if node is still an ingress gateway before completely deleting postdown/up rules
node.PostUp = "iptables -A FORWARD -i " + node.Interface + " -j ACCEPT; iptables -t nat -A POSTROUTING -o " + node.Interface + " -j MASQUERADE"
node.PostDown = "iptables -D FORWARD -i " + node.Interface + " -j ACCEPT; iptables -t nat -D POSTROUTING -o " + node.Interface + " -j MASQUERADE"
}
node.SetLastModified()
node.PullChanges = "yes"
key, err := functions.GetRecordKey(node.MacAddress, node.Network)