1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-22 07:10:09 +01:00

Update dashboard.py

This commit is contained in:
Donald Zou 2024-08-21 11:35:10 +08:00
parent 3c50e4768a
commit 9312e168cb

View File

@ -592,7 +592,8 @@ class WireguardConfiguration:
def __getPeers(self): def __getPeers(self):
mt = os.path.getmtime(os.path.join(WG_CONF_PATH, f'{self.Name}.conf')) mt = os.path.getmtime(os.path.join(WG_CONF_PATH, f'{self.Name}.conf'))
# if self.__configFileModifiedTime is None or self.__configFileModifiedTime != mt: if self.__configFileModifiedTime is None or self.__configFileModifiedTime != mt:
print(f"[WGDashboard] WireGuard configuration file modified. Reading {self.Name}.conf now")
self.Peers = [] self.Peers = []
with open(os.path.join(WG_CONF_PATH, f'{self.Name}.conf'), 'r') as configFile: with open(os.path.join(WG_CONF_PATH, f'{self.Name}.conf'), 'r') as configFile:
p = [] p = []
@ -1368,7 +1369,10 @@ def _getWireguardConfigurationAvailableIP(configName: str) -> tuple[bool, list[s
add = p.allowed_ip.split(',') add = p.allowed_ip.split(',')
for i in add: for i in add:
a, c = i.split('/') a, c = i.split('/')
try:
existedAddress.append(ipaddress.ip_address(a.replace(" ", ""))) existedAddress.append(ipaddress.ip_address(a.replace(" ", "")))
except ValueError as e:
print("[WGDashboard] Error: " + str(e))
for p in configuration.getRestrictedPeersList(): for p in configuration.getRestrictedPeersList():
if len(p.allowed_ip) > 0: if len(p.allowed_ip) > 0:
@ -2127,8 +2131,6 @@ def API_Welcome_Finish():
"repeatNewPassword": data["repeatNewPassword"], "repeatNewPassword": data["repeatNewPassword"],
"currentPassword": "admin" "currentPassword": "admin"
}) })
# updateEnableTotp, updateEnableTotpErr = DashboardConfig.SetConfig("Account", "enable_totp", data["enable_totp"])
if not updateUsername or not updatePassword: if not updateUsername or not updatePassword:
return ResponseObject(False, f"{updateUsernameErr},{updatePasswordErr}".strip(",")) return ResponseObject(False, f"{updateUsernameErr},{updatePasswordErr}".strip(","))