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:
Kumi 2024-07-18 18:00:20 +02:00
parent eb575e8f49
commit b7656a46be
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["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()