more RESTful APIs
This commit is contained in:
@@ -130,6 +130,7 @@ class FirewallManager:
|
||||
def allow_dhcp(self):
|
||||
return self.db.get("allow_dhcp", "1") == "1"
|
||||
|
||||
@drop_invalid.setter
|
||||
def allow_dhcp_set(self, value):
|
||||
@allow_dhcp.setter
|
||||
def allow_dhcp(self, value):
|
||||
self.db.set("allow_dhcp", "1" if value else "0")
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ import traceback
|
||||
from utils import DEBUG
|
||||
from fastapi import HTTPException
|
||||
|
||||
#TODO copied file, review
|
||||
|
||||
nft = FiregexTables()
|
||||
|
||||
class RegexFilter:
|
||||
|
||||
@@ -4,6 +4,8 @@ from modules.nfregex.nftables import FiregexTables, FiregexFilter
|
||||
from modules.nfregex.models import Regex, Service
|
||||
from utils.sqlite import SQLite
|
||||
|
||||
#TODO copied file, review
|
||||
|
||||
class STATUS:
|
||||
STOP = "stop"
|
||||
ACTIVE = "active"
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import base64
|
||||
|
||||
class Service:
|
||||
def __init__(self, service_id: str, status: str, port: int, name: str, proto: str, ip_int: str, **other):
|
||||
self.id = service_id
|
||||
@@ -14,17 +12,14 @@ class Service:
|
||||
return cls(**var)
|
||||
|
||||
|
||||
class Regex:
|
||||
def __init__(self, regex_id: int, regex: bytes, mode: str, service_id: str, blocked_packets: int, is_case_sensitive: bool, active: bool, **other):
|
||||
self.regex = regex
|
||||
self.mode = mode
|
||||
self.service_id = service_id
|
||||
class PyFilter:
|
||||
def __init__(self, filter_id:int, name: str, blocked_packets: int, edited_packets: int, active: bool, **other):
|
||||
self.filter_id = filter_id
|
||||
self.name = name
|
||||
self.blocked_packets = blocked_packets
|
||||
self.id = regex_id
|
||||
self.is_case_sensitive = is_case_sensitive
|
||||
self.edited_packets = edited_packets
|
||||
self.active = active
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, var: dict):
|
||||
var['regex'] = base64.b64decode(var['regex'])
|
||||
return cls(**var)
|
||||
return cls(**var)
|
||||
|
||||
Reference in New Issue
Block a user