Browse Source

add checks for firewall

Matthew R. Kasun 3 years ago
parent
commit
157a8f02cd
2 changed files with 19 additions and 0 deletions
  1. 3 0
      netclient/main.go
  2. 16 0
      netclient/ncutils/netclientutils.go

+ 3 - 0
netclient/main.go

@@ -35,6 +35,9 @@ func main() {
 	} else {
 	} else {
 		ncutils.CheckUID()
 		ncutils.CheckUID()
 		ncutils.CheckWG()
 		ncutils.CheckWG()
+		if ncutils.IsLinux() {
+			ncutils.CheckFirewall()
+		}
 	}
 	}
 
 
 	if len(os.Args) <= 1 && config.GuiActive {
 	if len(os.Args) <= 1 && config.GuiActive {

+ 16 - 0
netclient/ncutils/netclientutils.go

@@ -515,6 +515,22 @@ func CheckUID() {
 	}
 	}
 }
 }
 
 
+// CheckFirewall - checks if iptables of nft install, if not exit
+func CheckFirewall() {
+	found := false
+	_, err := exec.LookPath("iptables")
+	if err == nil {
+		found = true
+	}
+	_, err = exec.LookPath("nft")
+	if err == nil {
+		found = true
+	}
+	if !found {
+		log.Fatal("neither iptables nor nft is installed - please install one or the other and try again")
+	}
+}
+
 // CheckWG - Checks if WireGuard is installed. If not, exit
 // CheckWG - Checks if WireGuard is installed. If not, exit
 func CheckWG() {
 func CheckWG() {
 	uspace := GetWireGuard()
 	uspace := GetWireGuard()