Add TLS Flag and make it optional

TLS server is now optional and deactivated by default.
This commit is contained in:
Malte Reddig 2020-10-05 13:34:48 +02:00 committed by George Shammas
parent fde02bd06b
commit bdc30bf2c7
1 changed files with 6 additions and 3 deletions

View File

@ -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)
}