From 157a8f02cd9679b2feedfa0a5b8d8bf1ce4b43d6 Mon Sep 17 00:00:00 2001 From: "Matthew R. Kasun" Date: Fri, 19 Aug 2022 10:43:51 -0400 Subject: [PATCH] add checks for firewall --- netclient/main.go | 3 +++ netclient/ncutils/netclientutils.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/netclient/main.go b/netclient/main.go index 6293297a..34e1f2e0 100644 --- a/netclient/main.go +++ b/netclient/main.go @@ -35,6 +35,9 @@ func main() { } else { ncutils.CheckUID() ncutils.CheckWG() + if ncutils.IsLinux() { + ncutils.CheckFirewall() + } } if len(os.Args) <= 1 && config.GuiActive { diff --git a/netclient/ncutils/netclientutils.go b/netclient/ncutils/netclientutils.go index 7dc8a1ec..fa80711d 100644 --- a/netclient/ncutils/netclientutils.go +++ b/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 func CheckWG() { uspace := GetWireGuard()