This commit is contained in:
Donald Zou
2025-12-01 10:15:59 +08:00
parent 1fe03e1664
commit 876a079be3
4 changed files with 20 additions and 13 deletions

View File

@@ -222,14 +222,7 @@ def auth_req():
if request.method.lower() == 'options':
return ResponseObject(True)
DashboardConfig.APIAccessed = False
# if "api" in request.path:
# if str(request.method) == "GET":
# DashboardLogger.log(str(request.url), str(request.remote_addr), Message=str(request.args))
# elif str(request.method) == "POST":
# DashboardLogger.log(str(request.url), str(request.remote_addr), Message=f"Request Args: {str(request.args)} Body:{str(request.get_json())}")
DashboardConfig.APIAccessed = False
authenticationRequired = DashboardConfig.GetConfig("Server", "auth_req")[1]
d = request.headers
if authenticationRequired:
@@ -1090,12 +1083,10 @@ def API_GetPeerTraffics():
interval = request.args.get('interval', 30)
startDate = request.args.get('startDate', None)
endDate = request.args.get('endDate', None)
if type(interval) is str:
if not interval.isdigit():
return ResponseObject(False, "Interval must be integers in minutes")
interval = int(interval)
if startDate is None:
endDate = None
else:

View File

@@ -1195,7 +1195,7 @@ class WireguardConfiguration:
except Exception as e:
return False
def updateConfigurationInfo(self, key: str, value: str | dict[str, str] | dict[str, dict]) -> tuple[bool, Any, str] | tuple[
def updateConfigurationInfo(self, key: str, value: str | dict[str, str] | dict[str, dict] | bool) -> tuple[bool, Any, str] | tuple[
bool, str, None] | tuple[bool, None, None]:
if key == "Description":
self.configurationInfo.Description = value
@@ -1214,9 +1214,12 @@ class WireguardConfiguration:
for name, data in value.items():
peerGroups[name] = PeerGroupsClass(**data)
self.configurationInfo.PeerGroups = peerGroups
elif key == "PeerTrafficTracking":
self.configurationInfo.PeerTrafficTracking = value
elif key == "PeerHistoricalTrafficTracking":
self.configurationInfo.PeerHistoricalEndpointTracking = value
else:
return False, "Key does not exist", None
self.storeConfigurationInfo()
return True, None, None

View File

@@ -18,4 +18,6 @@ class PeerGroupsClass(BaseModel):
class WireguardConfigurationInfo(BaseModel):
Description: str = ''
OverridePeerSettings: OverridePeerSettingsClass = OverridePeerSettingsClass(**{})
PeerGroups: dict[str, PeerGroupsClass] = {}
PeerGroups: dict[str, PeerGroupsClass] = {}
PeerTrafficTracking: bool = True
PeerHistoricalEndpointTracking: bool = True

View File

@@ -0,0 +1,11 @@
<script setup>
</script>
<template>
</template>
<style scoped>
</style>