add(todo): additional setting to implement
This commit is contained in:
@@ -21,7 +21,38 @@ class FirewallManager:
|
||||
async def reload(self):
|
||||
async with self.lock:
|
||||
if self.db.get("ENABLED", "0") == "1":
|
||||
nft.set(map(Rule.from_dict, self.db.query('SELECT * FROM rules WHERE active = 1 ORDER BY rule_id;')), policy=self.db.get('POLICY', 'accept'))
|
||||
additional_rules = []
|
||||
if self.allow_loopback:
|
||||
pass #TODO complete rule
|
||||
if self.allow_established:
|
||||
pass #TODO complete rule
|
||||
rules = list(map(Rule.from_dict, self.db.query('SELECT * FROM rules WHERE active = 1 ORDER BY rule_id;')), policy=self.db.get('POLICY', 'accept'))
|
||||
nft.set(additional_rules + rules)
|
||||
else:
|
||||
nft.reset()
|
||||
|
||||
@property
|
||||
def keep_rules(self):
|
||||
return self.db.get("keep_rules", "0") == "1"
|
||||
|
||||
@keep_rules.setter
|
||||
def keep_rules(self, value):
|
||||
self.db.set("keep_rules", "1" if value else "0")
|
||||
|
||||
@property
|
||||
def allow_loopback(self):
|
||||
return self.db.get("allow_loopback", "1") == "1"
|
||||
|
||||
@allow_loopback.setter
|
||||
def allow_loopback(self, value):
|
||||
self.db.set("allow_loopback", "1" if value else "0")
|
||||
|
||||
@property
|
||||
def allow_established(self):
|
||||
return self.db.get("allow_established", "1") == "1"
|
||||
|
||||
@allow_established.setter
|
||||
def allow_established(self, value):
|
||||
self.db.set("allow_established", "1" if value else "0")
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from modules.regexproxy.proxy import Filter, Proxy
|
||||
import random, socket, asyncio
|
||||
from base64 import b64decode
|
||||
from utils.sqlite import SQLite
|
||||
from utils import refresh_frontend
|
||||
from utils import socketio_emit
|
||||
|
||||
class STATUS:
|
||||
WAIT = "wait"
|
||||
@@ -130,10 +130,10 @@ class ServiceManager:
|
||||
while True:
|
||||
if check_port_is_open(self.proxy.public_port):
|
||||
self._set_status(to)
|
||||
await refresh_frontend()
|
||||
await socketio_emit(["regexproxy"])
|
||||
await self.proxy.start(in_pause=(to==STATUS.PAUSE))
|
||||
self._set_status(STATUS.STOP)
|
||||
await refresh_frontend()
|
||||
await socketio_emit(["regexproxy"])
|
||||
return
|
||||
else:
|
||||
await asyncio.sleep(.5)
|
||||
|
||||
Reference in New Issue
Block a user