mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-22 07:10:09 +01:00
Merge pull request #395 from donaldzou/fix-#391
Fixed issue where Preshared Key is not added when unrestricted peers
This commit is contained in:
commit
a97a91b844
@ -693,8 +693,6 @@ class WireguardConfiguration:
|
|||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
def allowAccessPeers(self, listOfPublicKeys):
|
def allowAccessPeers(self, listOfPublicKeys):
|
||||||
# numOfAllowedPeers = 0
|
|
||||||
# numOfFailedToAllowPeers = 0
|
|
||||||
if not self.getStatus():
|
if not self.getStatus():
|
||||||
self.toggleConfiguration()
|
self.toggleConfiguration()
|
||||||
|
|
||||||
@ -705,7 +703,15 @@ class WireguardConfiguration:
|
|||||||
% (self.Name, self.Name,), (p['id'],))
|
% (self.Name, self.Name,), (p['id'],))
|
||||||
sqlUpdate("DELETE FROM '%s_restrict_access' WHERE id = ?"
|
sqlUpdate("DELETE FROM '%s_restrict_access' WHERE id = ?"
|
||||||
% self.Name, (p['id'],))
|
% self.Name, (p['id'],))
|
||||||
subprocess.check_output(f"wg set {self.Name} peer {p['id']} allowed-ips {p['allowed_ip']}",
|
|
||||||
|
presharedKeyExist = len(p['preshared_key']) > 0
|
||||||
|
rd = random.Random()
|
||||||
|
uid = uuid.UUID(int=rd.getrandbits(128), version=4)
|
||||||
|
if presharedKeyExist:
|
||||||
|
with open(f"{uid}", "w+") as f:
|
||||||
|
f.write(p['preshared_key'])
|
||||||
|
|
||||||
|
subprocess.check_output(f"wg set {self.Name} peer {p['id']} allowed-ips {p['allowed_ip']}{f' preshared-key {uid}' if presharedKeyExist else ''}",
|
||||||
shell=True, stderr=subprocess.STDOUT)
|
shell=True, stderr=subprocess.STDOUT)
|
||||||
else:
|
else:
|
||||||
return ResponseObject(False, "Failed to allow access of peer " + i)
|
return ResponseObject(False, "Failed to allow access of peer " + i)
|
||||||
|
Loading…
Reference in New Issue
Block a user