Fixes (need fixes on docker)
This commit is contained in:
@@ -165,7 +165,6 @@ class ServiceModel(BaseModel):
|
||||
service_id: str
|
||||
port: int
|
||||
name: str
|
||||
ipv6: bool
|
||||
proto: str
|
||||
ip_int: str
|
||||
n_regex: int
|
||||
@@ -180,7 +179,6 @@ async def get_service_list(auth: bool = Depends(is_loggined)):
|
||||
s.status status,
|
||||
s.port port,
|
||||
s.name name,
|
||||
s.ipv6 ipv6,
|
||||
s.proto proto,
|
||||
s.ip_int ip_int,
|
||||
COUNT(r.regex_id) n_regex,
|
||||
@@ -198,7 +196,6 @@ async def get_service_by_id(service_id: str, auth: bool = Depends(is_loggined)):
|
||||
s.status status,
|
||||
s.port port,
|
||||
s.name name,
|
||||
s.ipv6 ipv6,
|
||||
s.proto proto,
|
||||
s.ip_int ip_int,
|
||||
COUNT(r.regex_id) n_regex,
|
||||
@@ -360,8 +357,8 @@ async def add_new_service(form: ServiceAddForm, auth: bool = Depends(is_loggined
|
||||
srv_id = None
|
||||
try:
|
||||
srv_id = gen_service_id(db)
|
||||
db.query("INSERT INTO services (service_id ,name, port, ipv6, status, proto, ip_int) VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
srv_id, refactor_name(form.name), form.port, True, STATUS.STOP, form.proto, form.ip_int)
|
||||
db.query("INSERT INTO services (service_id ,name, port, status, proto, ip_int) VALUES (?, ?, ?, ?, ?, ?)",
|
||||
srv_id, refactor_name(form.name), form.port, STATUS.STOP, form.proto, form.ip_int)
|
||||
except sqlite3.IntegrityError:
|
||||
return {'status': 'This type of service already exists'}
|
||||
await firewall.reload()
|
||||
|
||||
@@ -133,7 +133,6 @@ class FiregexTables:
|
||||
def delete_by_srv(self, srv:Service):
|
||||
for filter in self.get():
|
||||
if filter.port == srv.port and filter.proto == srv.proto and ip_parse(filter.ip_int) == ip_parse(srv.ip_int):
|
||||
print("DELETE CMD", {"delete":{"rule": {"handle": filter.id, "table": self.table_name, "chain": filter.target, "family": "inet"}}})
|
||||
self.cmd({"delete":{"rule": {"handle": filter.id, "table": self.table_name, "chain": filter.target, "family": "inet"}}})
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ class SQLite():
|
||||
'status': 'VARCHAR(100) NOT NULL',
|
||||
'port': 'INT NOT NULL CHECK(port > 0 and port < 65536)',
|
||||
'name': 'VARCHAR(100) NOT NULL UNIQUE',
|
||||
'ipv6': 'BOOLEAN NOT NULL CHECK (ipv6 IN (0, 1)) DEFAULT 0',
|
||||
'proto': 'VARCHAR(3) NOT NULL CHECK (proto IN ("tcp", "udp"))',
|
||||
'ip_int': 'VARCHAR(100) NOT NULL',
|
||||
},
|
||||
@@ -31,7 +30,7 @@ class SQLite():
|
||||
'FOREIGN KEY (service_id)':'REFERENCES services (service_id)',
|
||||
},
|
||||
'QUERY':[
|
||||
"CREATE UNIQUE INDEX IF NOT EXISTS unique_services ON services (ipv6, port, ip_int, proto);",
|
||||
"CREATE UNIQUE INDEX IF NOT EXISTS unique_services ON services (port, ip_int, proto);",
|
||||
"CREATE UNIQUE INDEX IF NOT EXISTS unique_regex_service ON regexes (regex,service_id,is_blacklist,mode,is_case_sensitive);"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user