Code refactoring and adding port-hijacking backup commit
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from typing import Dict, List, Set
|
||||
from modules.nfregex.nftables import FiregexFilter, FiregexTables
|
||||
from modules.nfregex.nftables import FiregexTables
|
||||
from utils import ip_parse, run_func
|
||||
from modules.nfregex.models import Service, Regex
|
||||
import re, os, asyncio
|
||||
@@ -54,7 +54,7 @@ class RegexFilter:
|
||||
class FiregexInterceptor:
|
||||
|
||||
def __init__(self):
|
||||
self.filter:FiregexFilter
|
||||
self.srv:Service
|
||||
self.filter_map_lock:asyncio.Lock
|
||||
self.filter_map: Dict[str, RegexFilter]
|
||||
self.regex_filters: Set[RegexFilter]
|
||||
@@ -63,16 +63,14 @@ class FiregexInterceptor:
|
||||
self.update_task: asyncio.Task
|
||||
|
||||
@classmethod
|
||||
async def start(cls, filter: FiregexFilter):
|
||||
async def start(cls, srv: Service):
|
||||
self = cls()
|
||||
self.filter = filter
|
||||
self.srv = srv
|
||||
self.filter_map_lock = asyncio.Lock()
|
||||
self.update_config_lock = asyncio.Lock()
|
||||
input_range, output_range = await self._start_binary()
|
||||
self.update_task = asyncio.create_task(self.update_blocked())
|
||||
if not filter in nft.get():
|
||||
nft.add_input(queue_range=input_range, proto=self.filter.proto, port=self.filter.port, ip_int=self.filter.ip_int)
|
||||
nft.add_output(queue_range=output_range, proto=self.filter.proto, port=self.filter.port, ip_int=self.filter.ip_int)
|
||||
nft.add(self.srv, input_range, output_range)
|
||||
return self
|
||||
|
||||
async def _start_binary(self):
|
||||
|
||||
Reference in New Issue
Block a user