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", "")
|
host := getEnvWithDefault("HOST", "")
|
||||||
port := getEnvWithDefault("PORT", "8080")
|
port := getEnvWithDefault("PORT", "8080")
|
||||||
|
|
||||||
|
tlsenabled := getEnvWithDefault("TLS", "0")
|
||||||
tlsport := getEnvWithDefault("TLSPORT", "8443")
|
tlsport := getEnvWithDefault("TLSPORT", "8443")
|
||||||
tlscert := getEnvWithDefault("TLSCERT", "/opt/ifconfig/.cf/ifconfig.io.crt")
|
tlscert := getEnvWithDefault("TLSCERT", "/opt/ifconfig/.cf/ifconfig.io.crt")
|
||||||
tlskey := getEnvWithDefault("TLSKEY", "/opt/ifconfig/.cf/ifconfig.io.key")
|
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 <- r.Run(fmt.Sprintf("%s:%s", host, port))
|
||||||
}(errc)
|
}(errc)
|
||||||
|
|
||||||
go func(errc chan error) {
|
if tlsenabled == "1" {
|
||||||
errc <- r.RunTLS(
|
go func(errc chan error) {
|
||||||
|
errc <- r.RunTLS(
|
||||||
fmt.Sprintf("%s:%s", host, tlsport),
|
fmt.Sprintf("%s:%s", host, tlsport),
|
||||||
tlscert, tlskey)
|
tlscert, tlskey)
|
||||||
}(errc)
|
}(errc)
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println(<-errc)
|
fmt.Println(<-errc)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue