From b7656a46be08f367e937af6747efbf9f098e1547 Mon Sep 17 00:00:00 2001 From: Kumi Date: Thu, 18 Jul 2024 18:00:20 +0200 Subject: [PATCH] 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. --- worker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worker.py b/worker.py index f66c51d..5187513 100644 --- a/worker.py +++ b/worker.py @@ -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()