From 139fe391302da901b53f3a508ed01eac9a591401 Mon Sep 17 00:00:00 2001 From: DomySh Date: Mon, 18 Jul 2022 23:01:24 +0200 Subject: [PATCH] Fixes and small changes --- backend/modules/firegex.py | 2 +- backend/modules/firewall.py | 19 +------------------ backend/modules/sqlite.py | 2 +- backend/nfqueue/nfqueue.cpp | 3 ++- frontend/src/App.tsx | 5 +++++ 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/backend/modules/firegex.py b/backend/modules/firegex.py index ebff9f1..22d6162 100644 --- a/backend/modules/firegex.py +++ b/backend/modules/firegex.py @@ -192,7 +192,7 @@ class FiregexInterceptor: ) line_fut = self.process.stdout.readuntil() try: - line_fut = await asyncio.wait_for(line_fut, timeout=1) + line_fut = await asyncio.wait_for(line_fut, timeout=3) except asyncio.TimeoutError: self.process.kill() raise Exception("Invalid binary output") diff --git a/backend/modules/firewall.py b/backend/modules/firewall.py index 582b159..e12706b 100644 --- a/backend/modules/firewall.py +++ b/backend/modules/firewall.py @@ -1,4 +1,4 @@ -import traceback, asyncio +import asyncio from typing import Dict from modules.firegex import FiregexFilter, FiregexTables, RegexFilter from modules.sqlite import Regex, SQLite, Service @@ -14,7 +14,6 @@ class FirewallManager: self.lock = asyncio.Lock() async def close(self): - if self.updater_task: self.updater_task.cancel() for key in list(self.proxy_table.keys()): await self.remove(key) @@ -36,22 +35,6 @@ class FirewallManager: self.proxy_table[srv.id] = ServiceManager(srv, self.db) await self.proxy_table[srv.id].next(srv.status) - async def _stats_updater(self, callback): - try: - while True: - try: - for key in list(self.proxy_table.keys()): - self.proxy_table[key].update_stats() - except Exception: - traceback.print_exc() - if callback: - if asyncio.iscoroutinefunction(callback): await callback() - else: callback() - await asyncio.sleep(5) - except asyncio.CancelledError: - self.updater_task = None - return - def get(self,srv_id): if srv_id in self.proxy_table: return self.proxy_table[srv_id] diff --git a/backend/modules/sqlite.py b/backend/modules/sqlite.py index 73051b3..85e9e86 100644 --- a/backend/modules/sqlite.py +++ b/backend/modules/sqlite.py @@ -116,7 +116,7 @@ class Service: class Regex: - def __init__(self, id: int, regex: str, mode: str, service_id: str, is_blacklist: bool, blocked_packets: int, is_case_sensitive: bool, active: bool): + def __init__(self, id: int, regex: bytes, mode: str, service_id: str, is_blacklist: bool, blocked_packets: int, is_case_sensitive: bool, active: bool): self.regex = regex self.mode = mode self.service_id = service_id diff --git a/backend/nfqueue/nfqueue.cpp b/backend/nfqueue/nfqueue.cpp index 373ed4f..ab508d0 100644 --- a/backend/nfqueue/nfqueue.cpp +++ b/backend/nfqueue/nfqueue.cpp @@ -8,7 +8,7 @@ using namespace std; shared_ptr regex_config; void config_updater (){ - string line, data; + string line; while (true){ getline(cin, line); if (cin.eof()){ @@ -23,6 +23,7 @@ void config_updater (){ istringstream config_stream(line); regex_rules *regex_new_config = new regex_rules(); while(!config_stream.eof()){ + string data; config_stream >> data; if (data != "" && data != "\n"){ regex_new_config->add(data.c_str()); diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 697a393..d52cf33 100755 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -47,6 +47,11 @@ function App() { } },[]) + useEffect(()=>{ + const updater = setInterval(fireUpdateRequest,6000) + return () => clearInterval(updater) + },[]) + const form = useForm({ initialValues: { password:"",