Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/logic/gateway.go b/logic/gateway.go
- index 3bac3f92..018ff394 100644
- --- a/logic/gateway.go
- +++ b/logic/gateway.go
- @@ -17,7 +17,7 @@ func CreateEgressGateway(gateway models.EgressGatewayRequest) (models.Node, erro
- if err != nil {
- return models.Node{}, err
- }
- - if node.OS != "linux" { // add in darwin later
- + if node.OS != "linux" && node.OS != "freebsd" { // add in darwin later
- return models.Node{}, errors.New(node.OS + " is unsupported for egress gateways")
- }
- err = ValidateEgressGateway(gateway)
- @@ -26,8 +26,14 @@ func CreateEgressGateway(gateway models.EgressGatewayRequest) (models.Node, erro
- }
- node.IsEgressGateway = "yes"
- node.EgressGatewayRanges = gateway.Ranges
- - postUpCmd := "iptables -A FORWARD -i " + node.Interface + " -j ACCEPT; iptables -A FORWARD -o " + node.Interface + " -j ACCEPT; iptables -t nat -A POSTROUTING -o " + gateway.Interface + " -j MASQUERADE"
- - postDownCmd := "iptables -D FORWARD -i " + node.Interface + " -j ACCEPT; iptables -D FORWARD -o " + node.Interface + " -j ACCEPT; iptables -t nat -D POSTROUTING -o " + gateway.Interface + " -j MASQUERADE"
- + if node.OS == "linux" {
- + postUpCmd := "iptables -A FORWARD -i " + node.Interface + " -j ACCEPT; iptables -A FORWARD -o " + node.Interface + " -j ACCEPT; iptables -t nat -A POSTROUTING -o " + gateway.Interface + " -j MASQUERADE"
- + postDownCmd := "iptables -D FORWARD -i " + node.Interface + " -j ACCEPT; iptables -D FORWARD -o " + node.Interface + " -j ACCEPT; iptables -t nat -D POSTROUTING -o " + gateway.Interface + " -j MASQUERADE"
- + }
- + if node.OS == "freebsd" {
- + node.PostUp = "kldload ipfw ; ipfw add 65000 nat ip from any to any in recv " + gateway.Interface + " ; ipfw add 65000 allow ip from any to any via " + gateway.Interface + " ; ipfw add 65000 allow ip from any to any"
- + node.PostDown = "ipfw delete 65000 ; kldunload ipfw"
- + }
- if gateway.PostUp != "" {
- postUpCmd = gateway.PostUp
- }
- @@ -89,8 +95,14 @@ func DeleteEgressGateway(network, nodeid string) (models.Node, error) {
- 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 -A FORWARD -o " + 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 -D FORWARD -o " + node.Interface + " -j ACCEPT; iptables -t nat -D POSTROUTING -o " + node.Interface + " -j MASQUERADE"
- + if node.OS == "linux" {
- + node.PostUp = "iptables -A FORWARD -i " + node.Interface + " -j ACCEPT; iptables -A FORWARD -o " + 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 -D FORWARD -o " + node.Interface + " -j ACCEPT; iptables -t nat -D POSTROUTING -o " + node.Interface + " -j MASQUERADE"
- + }
- + if node.OS == "freebsd" {
- + node.PostUp = "kldload ipfw ; ipfw add 65000 nat ip from any to any in recv " + gateway.Interface + " ; ipfw add 65000 allow ip from any to any via " + gateway.Interface + " ; ipfw add 65000 allow ip from any to any"
- + node.PostDown = "ipfw delete 65000 ; kldunload ipfw"
- + }
- }
- node.SetLastModified()
- @@ -111,7 +123,7 @@ func DeleteEgressGateway(network, nodeid string) (models.Node, error) {
- func CreateIngressGateway(netid string, nodeid string) (models.Node, error) {
- node, err := GetNodeByID(nodeid)
- - if node.OS != "linux" { // add in darwin later
- + if node.OS != "linux" && node.OS != "freebsd" { // add in darwin later
- return models.Node{}, errors.New(node.OS + " is unsupported for ingress gateways")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement