From f759f8ed86276e86114efd322ce14ab8be03e6b8 Mon Sep 17 00:00:00 2001 From: Cole Deck Date: Tue, 29 Nov 2022 21:01:21 -0600 Subject: [PATCH] fix bugs that were discovered thanks to backend changes --- block.py | 5 ++++- config.yml | 2 +- ippigeon.py | 6 +++--- panel.py | 4 ++-- util.py | 11 +++++++---- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/block.py b/block.py index a4ae02e..c3ab10b 100644 --- a/block.py +++ b/block.py @@ -15,7 +15,10 @@ def get_blocklist(config, settings): appendbad = settings["appendbad"] whitelist = settings["whitelist"] fprint("Downloading deny list from server") - data = ssh.check_for_file(config, "BadIPs.csv", "receive") + try: + data = ssh.check_for_file(config, "BadIPs.csv", "receive") + except: + data = list() #fprint(data.stdout) csvreader = csv.reader(data.stdout.split("\n"), delimiter=',', quotechar='|') data2 = list() diff --git a/config.yml b/config.yml index a2ba196..14ca7d3 100644 --- a/config.yml +++ b/config.yml @@ -2,7 +2,7 @@ core: autostart: true clockspeed: 20 interval: 10 - level: 3 + level: 2 localadmin: true sftp: filepath: diff --git a/ippigeon.py b/ippigeon.py index 775a1ea..ac2aa83 100644 --- a/ippigeon.py +++ b/ippigeon.py @@ -218,7 +218,7 @@ def mainloop(pool): tmplist = settings["badapps"] settings["badapps"] = list() for x in tmplist: - if x > 0: + if x > 4: send_notification("Killing PID " + str(x)) kill(x) @@ -237,14 +237,14 @@ def mainloop(pool): if (badip, badport) not in history: fprint("Firewalling " + badip + ":" + str(badport), settings) send_notification("Firewalling " + badip + ":" + str(badport)) + history.append((badip, badport)) if win32: cmd = 'New-NetFirewallRule -DisplayName "IPPigeon Security Rule ' + badip + ':' + str(badport) + '" -Group "IPPigeon" -Direction Outbound -LocalPort Any -Protocol ' + badproto + ' -Action Block -RemoteAddress ' + badip + ' -RemotePort ' + str(badport) run_cmd(cmd) if linux: cmd = "nft add rule ip ippigeon output ip daddr " + badip + " " + badproto.lower() + " dport " + str(badport) + " drop" run_cmd(cmd) - else: - history.append((badip, badport)) + settings["badapps"] = list() diff --git a/panel.py b/panel.py index 58c5a83..531fc82 100644 --- a/panel.py +++ b/panel.py @@ -89,8 +89,8 @@ class LoginPanel(wx.Panel): vbox.Add(pwdText, 0, wx.ALIGN_CENTER | 100, 5) login_button = wx.Button(self, label='Login') login_button.Bind(wx.EVT_BUTTON, self.on_login) - help_button = wx.Button(self, label='Help') - help_button.Bind(wx.EVT_BUTTON, self.on_help) + #help_button = wx.Button(self, label='Help') + #help_button.Bind(wx.EVT_BUTTON, self.on_help) # signup_button = wx.Button(self, label='Sign Up') hbox.Add(login_button, 0, wx.ALL | 200, 20) # hbox.Add(signup_button, 0, wx.ALL | 200, 20) diff --git a/util.py b/util.py index 15d23af..7d91fdb 100644 --- a/util.py +++ b/util.py @@ -47,10 +47,13 @@ def time(): def kill(pid): setup_child() - if pid > 0: - fprint("Killing PID " + str(pid), settings) - os.kill(int(pid), 9) - fprint("Signal 9 sent to PID " + str(pid), settings) + try: + if pid > 4: + fprint("Killing PID " + str(pid), settings) + os.kill(int(pid), 9) + fprint("Signal 9 sent to PID " + str(pid), settings) + except: + fprint("Unable to kill " + str(pid), settings) def fprint(msg, settings = None): #if not getattr(sys, "frozen", False):