diff --git a/config.dist.ini b/config.dist.ini index 3f15976..054149c 100644 --- a/config.dist.ini +++ b/config.dist.ini @@ -4,6 +4,12 @@ address = 10.123.123.2, fdfd:fdfd:1234::2 listen_port = 1234 +# You can provide a private key and a pre-shared key for the server +# If you don't provide them, they will be generated automatically + +# private_key = your_private_key +# preshared_key = your_preshared_key + # Peer configuration peer_public_key = public key of the peer diff --git a/worker.py b/worker.py index 500c9dd..ebc01ed 100644 --- a/worker.py +++ b/worker.py @@ -370,7 +370,19 @@ def main(provider, location, server_type): for command in commands: ssh_execute_command(server_ip, command) - private_key, public_key, preshared_key = generate_wireguard_keys() + # Check if private key and preshared key are provided + if config["wireguard"]["private_key"]: + private_key = config["wireguard"]["private_key"] + else: + private_key = generate_private_key() + + if config["wireguard"]["preshared_key"]: + preshared_key = config["wireguard"]["preshared_key"] + else: + preshared_key = generate_preshared_key() + + public_key = private_to_public_key(private_key) + configure_wireguard(server_ip, private_key, public_key, preshared_key) # Generate client configuration for Chimpman