From bdc30bf2c7acaa73f24884371d925e7d06fa6549 Mon Sep 17 00:00:00 2001 From: Malte Reddig Date: Mon, 5 Oct 2020 13:34:48 +0200 Subject: [PATCH] Add TLS Flag and make it optional TLS server is now optional and deactivated by default. --- main.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index a259a81..60a5d54 100644 --- a/main.go +++ b/main.go @@ -155,6 +155,7 @@ func main() { host := getEnvWithDefault("HOST", "") port := getEnvWithDefault("PORT", "8080") + tlsenabled := getEnvWithDefault("TLS", "0") tlsport := getEnvWithDefault("TLSPORT", "8443") tlscert := getEnvWithDefault("TLSCERT", "/opt/ifconfig/.cf/ifconfig.io.crt") tlskey := getEnvWithDefault("TLSKEY", "/opt/ifconfig/.cf/ifconfig.io.key") @@ -163,11 +164,13 @@ func main() { errc <- r.Run(fmt.Sprintf("%s:%s", host, port)) }(errc) - go func(errc chan error) { - errc <- r.RunTLS( + if tlsenabled == "1" { + go func(errc chan error) { + errc <- r.RunTLS( fmt.Sprintf("%s:%s", host, tlsport), tlscert, tlskey) - }(errc) + }(errc) + } fmt.Println(<-errc) }