Browse Source

fixed iptable check

0xdcarns 3 years ago
parent
commit
a2a6d75c25
1 changed files with 3 additions and 1 deletions
  1. 3 1
      serverctl/iptables.go

+ 3 - 1
serverctl/iptables.go

@@ -110,7 +110,7 @@ func iptablesPortForward(entry string, inport string, outport string, isIP bool)
 		return errors.New("could not locate ip for " + entry)
 		return errors.New("could not locate ip for " + entry)
 	}
 	}
 
 
-	if output, _ := ncutils.RunCmd("iptables -t nat -C PREROUTING -p tcp --dport "+inport+" -j DNAT --to-destination "+address+":"+outport, false); output == "" {
+	if output, err := ncutils.RunCmd("iptables -t nat -C PREROUTING -p tcp --dport "+inport+" -j DNAT --to-destination "+address+":"+outport, false); output != "" || err != nil {
 		_, err := ncutils.RunCmd("iptables -t nat -A PREROUTING -p tcp --dport "+inport+" -j DNAT --to-destination "+address+":"+outport, false)
 		_, err := ncutils.RunCmd("iptables -t nat -A PREROUTING -p tcp --dport "+inport+" -j DNAT --to-destination "+address+":"+outport, false)
 		if err != nil {
 		if err != nil {
 			return err
 			return err
@@ -121,6 +121,8 @@ func iptablesPortForward(entry string, inport string, outport string, isIP bool)
 		}
 		}
 		_, err = ncutils.RunCmd("iptables -t nat -A POSTROUTING -j MASQUERADE", false)
 		_, err = ncutils.RunCmd("iptables -t nat -A POSTROUTING -j MASQUERADE", false)
 		return err
 		return err
+	} else {
+		logger.Log(2, "mq forwarding could not be set reliably")
 	}
 	}
 	return nil
 	return nil
 }
 }