mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-12-16 08:26:17 +00:00
Compare commits
1 Commits
v4.3.2-dev
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6284bde4e |
@@ -18,18 +18,10 @@ def GetRemoteEndpoint() -> str:
|
|||||||
@return:
|
@return:
|
||||||
"""
|
"""
|
||||||
import socket
|
import socket
|
||||||
try:
|
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
||||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
s.connect(("1.1.1.1", 80)) # Connecting to a public IP
|
||||||
s.connect(("1.1.1.1", 80)) # Connecting to a public IP
|
|
||||||
wgd_remote_endpoint = s.getsockname()[0]
|
wgd_remote_endpoint = s.getsockname()[0]
|
||||||
return str(wgd_remote_endpoint)
|
return str(wgd_remote_endpoint)
|
||||||
except (socket.error, OSError):
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
return socket.gethostbyname(socket.gethostname())
|
|
||||||
except (socket.error, OSError):
|
|
||||||
pass
|
|
||||||
return "127.0.0.1"
|
|
||||||
|
|
||||||
|
|
||||||
def StringToBoolean(value: str):
|
def StringToBoolean(value: str):
|
||||||
|
|||||||
@@ -404,7 +404,6 @@ class WireguardConfiguration:
|
|||||||
try:
|
try:
|
||||||
if "[Peer]" not in content:
|
if "[Peer]" not in content:
|
||||||
current_app.logger.info(f"{self.Name} config has no [Peer] section")
|
current_app.logger.info(f"{self.Name} config has no [Peer] section")
|
||||||
self.Peers = []
|
|
||||||
return
|
return
|
||||||
|
|
||||||
peerStarts = content.index("[Peer]")
|
peerStarts = content.index("[Peer]")
|
||||||
@@ -666,8 +665,9 @@ class WireguardConfiguration:
|
|||||||
|
|
||||||
if not self.__wgSave():
|
if not self.__wgSave():
|
||||||
return False, "Failed to save configuration through WireGuard"
|
return False, "Failed to save configuration through WireGuard"
|
||||||
self.getRestrictedPeers()
|
|
||||||
self.getPeers()
|
self.getPeers()
|
||||||
|
|
||||||
if numOfRestrictedPeers == len(listOfPublicKeys):
|
if numOfRestrictedPeers == len(listOfPublicKeys):
|
||||||
return True, f"Restricted {numOfRestrictedPeers} peer(s)"
|
return True, f"Restricted {numOfRestrictedPeers} peer(s)"
|
||||||
return False, f"Restricted {numOfRestrictedPeers} peer(s) successfully. Failed to restrict {numOfFailedToRestrictPeers} peer(s)"
|
return False, f"Restricted {numOfRestrictedPeers} peer(s) successfully. Failed to restrict {numOfFailedToRestrictPeers} peer(s)"
|
||||||
@@ -783,7 +783,9 @@ class WireguardConfiguration:
|
|||||||
)
|
)
|
||||||
).mappings().fetchone()
|
).mappings().fetchone()
|
||||||
if cur_i is not None:
|
if cur_i is not None:
|
||||||
|
# print(cur_i is None)
|
||||||
total_sent = cur_i['total_sent']
|
total_sent = cur_i['total_sent']
|
||||||
|
# print(cur_i is None)
|
||||||
total_receive = cur_i['total_receive']
|
total_receive = cur_i['total_receive']
|
||||||
cur_total_sent = float(data_usage[i][2]) / (1024 ** 3)
|
cur_total_sent = float(data_usage[i][2]) / (1024 ** 3)
|
||||||
cur_total_receive = float(data_usage[i][1]) / (1024 ** 3)
|
cur_total_receive = float(data_usage[i][1]) / (1024 ** 3)
|
||||||
@@ -1224,6 +1226,7 @@ class WireguardConfiguration:
|
|||||||
def __validateOverridePeerSettings(self, key: str, value: str | int) -> tuple[bool, None] | tuple[bool, str]:
|
def __validateOverridePeerSettings(self, key: str, value: str | int) -> tuple[bool, None] | tuple[bool, str]:
|
||||||
status = True
|
status = True
|
||||||
msg = None
|
msg = None
|
||||||
|
print(value)
|
||||||
if key == "DNS" and value:
|
if key == "DNS" and value:
|
||||||
status, msg = ValidateDNSAddress(value)
|
status, msg = ValidateDNSAddress(value)
|
||||||
elif key == "EndpointAllowedIPs" and value:
|
elif key == "EndpointAllowedIPs" and value:
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ gunicorn==23.0.0
|
|||||||
requests==2.32.5
|
requests==2.32.5
|
||||||
tcconfig==0.30.1
|
tcconfig==0.30.1
|
||||||
sqlalchemy==2.0.44
|
sqlalchemy==2.0.44
|
||||||
sqlalchemy_utils==0.42.0
|
sqlalchemy_utils==0.42.1
|
||||||
psycopg[binary]==3.3.2
|
psycopg[binary]==3.3.2
|
||||||
PyMySQL==1.1.2
|
PyMySQL==1.1.2
|
||||||
tzlocal==5.3.1
|
tzlocal==5.3.1
|
||||||
|
|||||||
Reference in New Issue
Block a user