fix(config): handle missing wireguard keys gracefully
Switch to `config.get` for retrieving Wireguard keys to safely handle cases where keys might not be present in the configuration. This change prevents potential crashes due to missing keys and ensures that defaults are generated as needed.
This commit is contained in:
parent
eb575e8f49
commit
b7656a46be
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)
|
||||
|
||||
# Check if private key and preshared key are provided
|
||||
if config["wireguard"]["private_key"]:
|
||||
if config.get("wireguard", "private_key"):
|
||||
private_key = config["wireguard"]["private_key"]
|
||||
else:
|
||||
private_key = generate_private_key()
|
||||
|
||||
if config["wireguard"]["preshared_key"]:
|
||||
if config.get("wireguard", "preshared_key"):
|
||||
preshared_key = config["wireguard"]["preshared_key"]
|
||||
else:
|
||||
preshared_key = generate_preshared_key()
|
||||
|
|
Loading…
Reference in a new issue