fix UI data for blocked connections

formac
Cole Deck 2 years ago
parent f64ff86d83
commit def22643f6

@ -34,6 +34,7 @@ def block_conn(config, datafile, res):
fprint("Searching block data") fprint("Searching block data")
mydata = list() mydata = list()
badapps = list() badapps = list()
badips = list()
with open(find_data_file(datafile), newline='') as csvfile: with open(find_data_file(datafile), newline='') as csvfile:
csvreader = csv.reader(csvfile, delimiter=',', quotechar='|') csvreader = csv.reader(csvfile, delimiter=',', quotechar='|')
@ -66,7 +67,8 @@ def block_conn(config, datafile, res):
if srcip == badsrcip or destip == baddestip and not pid in badapps: if srcip == badsrcip or destip == baddestip and not pid in badapps:
fprint("FLAG " + srcip + " " + destip + " " + str(pid)) fprint("FLAG " + srcip + " " + destip + " " + str(pid))
badapps.append(pid) badapps.append(pid)
badips.append(baddestip)
#fprint(badapps) #fprint(badapps)
#fprint("FLAG " + srcip + " " + destip + " " + str(pid)) #fprint("FLAG " + srcip + " " + destip + " " + str(pid))
#kill(pid) #kill(pid)
return badapps return badapps, badips

@ -82,16 +82,28 @@ def login_done(res):
def blockdata_done(res): def blockdata_done(res):
global settings global settings
fprint("FINISHED downloading block data") fprint("FINISHED downloading block data")
tmpkill = settings["kill"]
settings["kill"] = False
#block_res = pool.apply_async(block.block_conn, (config, datafile, res, settings)) #block_res = pool.apply_async(block.block_conn, (config, datafile, res, settings))
block_res = block.block_conn(config, datafile, res) block_pids, block_ips = block.block_conn(config, datafile, res)
tmplist = settings["badapps"] tmplist = settings["badapps"]
for x in block_res:
for x in block_pids:
fprint(x) fprint(x)
if not x in tmplist: if not x in tmplist:
tmplist.append(x) tmplist.append(x)
settings["badapps"] = tmplist settings["badapps"] = tmplist
fprint(settings["badapps"]) fprint(settings["badapps"])
tmplist = settings["badips"]
for x in block_ips:
fprint(x)
if not x in tmplist:
tmplist.append(x)
settings["badips"] = tmplist
fprint(settings["badips"])
settings["kill"] = tmpkill
def killall(): def killall():
kids = active_children() kids = active_children()
@ -152,10 +164,12 @@ def mainloop(pool):
settings["block"] = False settings["block"] = False
if settings["kill"] == True: if settings["kill"] == True:
for x in settings["badapps"]: tmplist = settings["badapps"]
kill(x)
settings["badapps"] = list() settings["badapps"] = list()
for x in tmplist:
kill(x)
sleep(interval / (interval * config["core"]["clockspeed"])) sleep(interval / (interval * config["core"]["clockspeed"]))
counter += 1 counter += 1
if counter == interval * config["core"]["clockspeed"]: if counter == interval * config["core"]["clockspeed"]:
@ -202,6 +216,7 @@ if __name__ == '__main__':
settings["continueui"] = False settings["continueui"] = False
settings["killbox"] = list() settings["killbox"] = list()
settings["badapps"] = list() settings["badapps"] = list()
settings["badips"] = list()
settings["block"] = False settings["block"] = False
settings["kill"] = False settings["kill"] = False
killme = manager.Value('d', 0) killme = manager.Value('d', 0)

@ -187,11 +187,12 @@ class ServerPanel(wx.Panel):
else: else:
fprint("Unable to delete") fprint("Unable to delete")
for i in range(len(TEST_FILE)): for i in range(len(TEST_FILE)):
idx = 0 idx = 0
for pid in settings["badapps"]: for ip in settings["badips"]:
#fprint(pid) #fprint(pid)
idx = i idx = i
if str(TEST_FILE.iloc[i, 5]) == str(pid): # "bad" pid, highlight in red at the top if str(TEST_FILE.iloc[i, 3]).find(ip) >= 0 and str(TEST_FILE.iloc[i, 4]).find("TIME_WAIT") < 0: # "bad" pid, highlight in red at the top
idx = self.list_ctrl.InsertItem(0, TEST_FILE.iloc[i, 0]) idx = self.list_ctrl.InsertItem(0, TEST_FILE.iloc[i, 0])
self.list_ctrl.SetItemBackgroundColour(idx, wx.Colour(200, 51, 51)) self.list_ctrl.SetItemBackgroundColour(idx, wx.Colour(200, 51, 51))
break break
@ -202,8 +203,8 @@ class ServerPanel(wx.Panel):
#fprint("Got " + TEST_FILE.iloc[i, 5]) #fprint("Got " + TEST_FILE.iloc[i, 5])
for j in range(1, 6): for j in range(1, 6):
fprint(str(idx) + " " + str(TEST_FILE.iloc[i, 0])) #fprint(str(idx) + " " + str(TEST_FILE.iloc[i, 0]))
self.list_ctrl.SetItem(idx, j, str(TEST_FILE.iloc[idx, j])) self.list_ctrl.SetItem(idx, j, str(TEST_FILE.iloc[i, j]))
#fprint(i, j, TEST_FILE.iloc[i, j]) #fprint(i, j, TEST_FILE.iloc[i, j])
#self.SetSizer(self.main_sizer) #self.SetSizer(self.main_sizer)

@ -42,9 +42,10 @@ def time():
def kill(pid): def kill(pid):
setup_child() setup_child()
fprint("Killing PID " + str(pid)) if pid > 0:
os.kill(int(pid), 9) fprint("Killing PID " + str(pid))
fprint("Signal 9 sent to PID " + str(pid)) os.kill(int(pid), 9)
fprint("Signal 9 sent to PID " + str(pid))
def fprint(msg): def fprint(msg):
#if not getattr(sys, "frozen", False): #if not getattr(sys, "frozen", False):

Loading…
Cancel
Save