Bug fixes and better regex checks

This commit is contained in:
DomySh
2022-06-15 08:47:13 +02:00
parent d2d2b2c408
commit 3ec0879608
5 changed files with 31 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
from asyncore import file_dispatcher
from proxy import Filter, Proxy
import random, string, os, threading, sqlite3, time
import random, string, os, threading, sqlite3, time, atexit
from kthread import KThread
from base64 import b64decode
@@ -68,12 +68,13 @@ class STATUS:
STOP = "stop"
PAUSE = "pause"
ACTIVE = "active"
class ProxyManager:
def __init__(self, db:SQLite):
self.db = db
self.proxy_table = {}
self.lock = threading.Lock()
atexit.register(self.clear)
def __clear_proxy_table(self):
with self.lock:
@@ -81,6 +82,13 @@ class ProxyManager:
if not self.proxy_table[key]["thread"].is_alive():
del self.proxy_table[key]
def clear(self):
with self.lock:
for key in list(self.proxy_table.keys()):
if self.proxy_table[key]["thread"].is_alive():
self.proxy_table[key]["thread"].kill()
del self.proxy_table[key]
def reload(self):
self.__clear_proxy_table()
with self.lock: