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

@@ -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