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:
parent
b7656a46be
commit
959db57391
1 changed files with 2 additions and 2 deletions
|
@ -354,12 +354,12 @@ def run(config, provider, location, server_type):
|
||||||
ssh_execute_command(server_ip, command)
|
ssh_execute_command(server_ip, command)
|
||||||
|
|
||||||
# Check if private key and preshared key are provided
|
# 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"]
|
private_key = config["wireguard"]["private_key"]
|
||||||
else:
|
else:
|
||||||
private_key = generate_private_key()
|
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"]
|
preshared_key = config["wireguard"]["preshared_key"]
|
||||||
else:
|
else:
|
||||||
preshared_key = generate_preshared_key()
|
preshared_key = generate_preshared_key()
|
||||||
|
|
Loading…
Reference in a new issue