fix(config): Ensure no exception when keys are missing

Added fallback parameters to config retrieval to prevent exceptions when WireGuard private and preshared keys are missing. This ensures that keys are generated when not provided, improving robustness and preventing potential runtime errors.
This commit is contained in:
Kumi 2024-07-18 18:02:09 +02:00
parent b7656a46be
commit 959db57391
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -354,12 +354,12 @@ def run(config, provider, location, server_type):
ssh_execute_command(server_ip, command)
# Check if private key and preshared key are provided
if config.get("wireguard", "private_key"):
if config.get("wireguard", "private_key", fallback=None):
private_key = config["wireguard"]["private_key"]
else:
private_key = generate_private_key()
if config.get("wireguard", "preshared_key"):
if config.get("wireguard", "preshared_key", fallback=None):
preshared_key = config["wireguard"]["preshared_key"]
else:
preshared_key = generate_preshared_key()