mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-22 15:20:09 +01:00
Update dashboard_new.py
Typo in `updatePeer`
This commit is contained in:
parent
769ca4e26d
commit
5a34f16dcf
@ -505,7 +505,7 @@ class Peer:
|
|||||||
if keepalive < 0:
|
if keepalive < 0:
|
||||||
return ResponseObject(False, "Persistent Keepalive format is not correct.")
|
return ResponseObject(False, "Persistent Keepalive format is not correct.")
|
||||||
if len(private_key) > 0:
|
if len(private_key) > 0:
|
||||||
pubKey = _generatePrivateKey(private_key)
|
pubKey = _generatePublicKey(private_key)
|
||||||
if not pubKey[0] or pubKey[1] != self.id:
|
if not pubKey[0] or pubKey[1] != self.id:
|
||||||
return ResponseObject(False, "Private key does not match with the public key.")
|
return ResponseObject(False, "Private key does not match with the public key.")
|
||||||
try:
|
try:
|
||||||
@ -772,7 +772,7 @@ def _checkDNS(dns):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def _generatePublicKey(privateKey) -> [bool, str]:
|
def _generatePublicKey(privateKey) -> [bool, str] | [bool, None]:
|
||||||
try:
|
try:
|
||||||
publicKey = subprocess.check_output(f"wg pubkey", input=privateKey.encode(), shell=True,
|
publicKey = subprocess.check_output(f"wg pubkey", input=privateKey.encode(), shell=True,
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
@ -790,9 +790,6 @@ def _generatePrivateKey() -> [bool, str]:
|
|||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _getWireguardConfigurationAvailableIP(configName: str) -> tuple[bool, list[str]] | tuple[bool, None]:
|
def _getWireguardConfigurationAvailableIP(configName: str) -> tuple[bool, list[str]] | tuple[bool, None]:
|
||||||
if configName not in WireguardConfigurations.keys():
|
if configName not in WireguardConfigurations.keys():
|
||||||
return False, None
|
return False, None
|
||||||
@ -1035,7 +1032,7 @@ def API_addPeers(configName):
|
|||||||
keyPairs = []
|
keyPairs = []
|
||||||
for i in range(bulkAddAmount):
|
for i in range(bulkAddAmount):
|
||||||
key = _generatePrivateKey()[1]
|
key = _generatePrivateKey()[1]
|
||||||
keyPairs.append([key, _generatePublicKey(key), _generatePrivateKey()[1]])
|
keyPairs.append([key, _generatePublicKey(key)[1], _generatePrivateKey()[1]])
|
||||||
if len(keyPairs) == 0:
|
if len(keyPairs) == 0:
|
||||||
return ResponseObject(False, "Generating key pairs by bulk failed")
|
return ResponseObject(False, "Generating key pairs by bulk failed")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user