From 0047b54e9459280df7d3d09b6b38eb11b0aa7d56 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 12 Aug 2025 20:44:34 -0700 Subject: [PATCH] Dont override ENV Fixes #101 --- main.go | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index dbb141f..1d3d7bc 100644 --- a/main.go +++ b/main.go @@ -112,15 +112,20 @@ func main() { updownScript = os.Getenv("UPDOWN_SCRIPT") interfaceName = os.Getenv("INTERFACE") generateAndSaveKeyTo = os.Getenv("GENERATE_AND_SAVE_KEY_TO") - keepInterface = os.Getenv("KEEP_INTERFACE") == "true" - acceptClients = os.Getenv("ACCEPT_CLIENTS") == "true" + keepInterfaceEnv := os.Getenv("KEEP_INTERFACE") + acceptClientsEnv := os.Getenv("ACCEPT_CLIENTS") + useNativeInterfaceEnv := os.Getenv("USE_NATIVE_INTERFACE") + + keepInterface = keepInterfaceEnv == "true" + acceptClients = acceptClientsEnv == "true" + useNativeInterface = useNativeInterfaceEnv == "true" + tlsPrivateKey = os.Getenv("TLS_CLIENT_CERT") dockerSocket = os.Getenv("DOCKER_SOCKET") pingIntervalStr := os.Getenv("PING_INTERVAL") pingTimeoutStr := os.Getenv("PING_TIMEOUT") dockerEnforceNetworkValidation = os.Getenv("DOCKER_ENFORCE_NETWORK_VALIDATION") healthFile = os.Getenv("HEALTH_FILE") - useNativeInterface = os.Getenv("USE_NATIVE_INTERFACE") == "true" // authorizedKeysFile = os.Getenv("AUTHORIZED_KEYS_FILE") authorizedKeysFile = "" @@ -151,9 +156,15 @@ func main() { if generateAndSaveKeyTo == "" { flag.StringVar(&generateAndSaveKeyTo, "generateAndSaveKeyTo", "", "Path to save generated private key") } - flag.BoolVar(&keepInterface, "keep-interface", false, "Keep the WireGuard interface") - flag.BoolVar(&useNativeInterface, "native", false, "Use native WireGuard interface (requires WireGuard kernel module) and linux") - flag.BoolVar(&acceptClients, "accept-clients", false, "Accept clients on the WireGuard interface") + if keepInterfaceEnv == "" { + flag.BoolVar(&keepInterface, "keep-interface", false, "Keep the WireGuard interface") + } + if useNativeInterfaceEnv == "" { + flag.BoolVar(&useNativeInterface, "native", false, "Use native WireGuard interface (requires WireGuard kernel module) and linux") + } + if acceptClientsEnv == "" { + flag.BoolVar(&acceptClients, "accept-clients", false, "Accept clients on the WireGuard interface") + } if tlsPrivateKey == "" { flag.StringVar(&tlsPrivateKey, "tls-client-cert", "", "Path to client certificate used for mTLS") } @@ -166,9 +177,6 @@ func main() { if pingTimeoutStr == "" { flag.StringVar(&pingTimeoutStr, "ping-timeout", "5s", " Timeout for each ping (default 5s)") } - if pingTimeoutStr == "" { - flag.StringVar(&pingTimeoutStr, "ping-timeout", "5s", " Timeout for each ping (default 5s)") - } // if authorizedKeysFile == "" { // flag.StringVar(&authorizedKeysFile, "authorized-keys-file", "~/.ssh/authorized_keys", "Path to authorized keys file (if unset, no keys will be authorized)") // }