mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-12-15 16:06:17 +00:00
Compare commits
3 Commits
client_app
...
v4.3.2-dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7c9d62e80 | ||
|
|
f5ccbdf9d3 | ||
|
|
a09342ed2a |
@@ -18,10 +18,18 @@ def GetRemoteEndpoint() -> str:
|
||||
@return:
|
||||
"""
|
||||
import socket
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
||||
s.connect(("1.1.1.1", 80)) # Connecting to a public IP
|
||||
try:
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
||||
s.connect(("1.1.1.1", 80)) # Connecting to a public IP
|
||||
wgd_remote_endpoint = s.getsockname()[0]
|
||||
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):
|
||||
|
||||
@@ -404,6 +404,7 @@ class WireguardConfiguration:
|
||||
try:
|
||||
if "[Peer]" not in content:
|
||||
current_app.logger.info(f"{self.Name} config has no [Peer] section")
|
||||
self.Peers = []
|
||||
return
|
||||
|
||||
peerStarts = content.index("[Peer]")
|
||||
@@ -665,9 +666,8 @@ class WireguardConfiguration:
|
||||
|
||||
if not self.__wgSave():
|
||||
return False, "Failed to save configuration through WireGuard"
|
||||
|
||||
self.getRestrictedPeers()
|
||||
self.getPeers()
|
||||
|
||||
if numOfRestrictedPeers == len(listOfPublicKeys):
|
||||
return True, f"Restricted {numOfRestrictedPeers} peer(s)"
|
||||
return False, f"Restricted {numOfRestrictedPeers} peer(s) successfully. Failed to restrict {numOfFailedToRestrictPeers} peer(s)"
|
||||
@@ -783,9 +783,7 @@ class WireguardConfiguration:
|
||||
)
|
||||
).mappings().fetchone()
|
||||
if cur_i is not None:
|
||||
# print(cur_i is None)
|
||||
total_sent = cur_i['total_sent']
|
||||
# print(cur_i is None)
|
||||
total_receive = cur_i['total_receive']
|
||||
cur_total_sent = float(data_usage[i][2]) / (1024 ** 3)
|
||||
cur_total_receive = float(data_usage[i][1]) / (1024 ** 3)
|
||||
@@ -1226,7 +1224,6 @@ class WireguardConfiguration:
|
||||
def __validateOverridePeerSettings(self, key: str, value: str | int) -> tuple[bool, None] | tuple[bool, str]:
|
||||
status = True
|
||||
msg = None
|
||||
print(value)
|
||||
if key == "DNS" and value:
|
||||
status, msg = ValidateDNSAddress(value)
|
||||
elif key == "EndpointAllowedIPs" and value:
|
||||
|
||||
Reference in New Issue
Block a user