Add TLS Flag and make it optional
TLS server is now optional and deactivated by default.
This commit is contained in:
parent
fde02bd06b
commit
bdc30bf2c7
9
main.go
9
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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue