fix: make keypair generation async to avoid blocking the event loop
generate_keypair() used synchronous subprocess.run() which blocked the NiceGUI event loop during wg genkey/pubkey calls. This caused WebSocket disconnects, page reloads, and the config dialog never appearing after device creation. Switched to asyncio.create_subprocess_exec so the event loop stays responsive while waiting for the wg CLI.
This commit is contained in:
parent
e51c53f247
commit
92554d4089
7 changed files with 31 additions and 22 deletions
|
|
@ -103,7 +103,7 @@ def test_build_client_config_no_psk():
|
|||
# --- Crypto (only if wg is installed) ---
|
||||
|
||||
|
||||
def test_generate_keypair():
|
||||
async def test_generate_keypair():
|
||||
"""Test keypair generation — requires `wg` CLI to be installed."""
|
||||
try:
|
||||
subprocess.run(["wg", "--version"], capture_output=True, check=True)
|
||||
|
|
@ -112,7 +112,7 @@ def test_generate_keypair():
|
|||
|
||||
from wiregui.utils.crypto import generate_keypair, generate_preshared_key
|
||||
|
||||
priv, pub = generate_keypair()
|
||||
priv, pub = await generate_keypair()
|
||||
assert len(priv) == 44 # base64-encoded 32 bytes
|
||||
assert len(pub) == 44
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue