Added "State" status for webhook session

This commit is contained in:
Donald Zou
2025-09-14 15:38:19 +08:00
parent 628464d2e1
commit 2eb3a17775
8 changed files with 68 additions and 32 deletions

View File

@@ -149,12 +149,6 @@ class AmneziaWGPeer(Peer):
shell=True, stderr=subprocess.STDOUT)
if f"wg showconf {self.configuration.Name}" not in saveConfig.decode().strip('\n'):
return False, "Update peer failed when saving the configuration"
# sqlUpdate(
# '''UPDATE '%s' SET name = ?, private_key = ?, DNS = ?, endpoint_allowed_ip = ?, mtu = ?,
# keepalive = ?, preshared_key = ?, advanced_security = ? WHERE id = ?''' % self.configuration.Name,
# (name, private_key, dns_addresses, endpoint_allowed_ip, mtu,
# keepalive, preshared_key, advanced_security, self.id,)
# )
with self.configuration.engine.begin() as conn:
conn.execute(
@@ -171,7 +165,7 @@ class AmneziaWGPeer(Peer):
self.configuration.peersTable.c.id == self.id
)
)
self.configuration.getPeers()
return True, None
except subprocess.CalledProcessError as exc:
return False, exc.output.decode("UTF-8").strip()

View File

@@ -3,7 +3,7 @@ import threading
import time
import urllib.parse
import uuid
from datetime import datetime
from datetime import datetime, timedelta
import requests
from pydantic import BaseModel, field_serializer
@@ -77,6 +77,17 @@ class DashboardWebHooks:
self.metadata.create_all(self.engine)
self.WebHooks: list[WebHook] = []
with self.engine.begin() as conn:
conn.execute(
self.webHookSessionsTable.update().values({
"EndDate": datetime.now(),
"Status": 2
}).where(
self.webHookSessionsTable.c.Status == -1
)
)
self.__getWebHooks()
def __getWebHooks(self):

View File

@@ -68,13 +68,13 @@ class Peer:
if len(dns_addresses) > 0 and not ValidateDNSAddress(dns_addresses):
return False, f"DNS format is incorrect"
if type(mtu) is str:
if type(mtu) is str or mtu is None:
mtu = 0
if mtu < 0 or mtu > 1460:
return False, "MTU format is not correct"
if type(keepalive) is str:
if type(keepalive) is str or keepalive is None:
keepalive = 0
if keepalive < 0:

View File

@@ -398,6 +398,7 @@ class WireguardConfiguration:
def getPeers(self):
tmpList = []
current_app.logger.info(f"Refreshing {self.Name} peer list")
if self.configurationFileChanged():
with open(self.configPath, 'r') as configFile:
p = []