From 84be1b6d6749982917a223dc15d43236d47386c4 Mon Sep 17 00:00:00 2001 From: Chandler Swift Date: Mon, 30 Mar 2020 20:00:48 -0500 Subject: [PATCH] Add TLSHostname and DebugServerPort as config values, not hardcoded values --- factorio-site.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/factorio-site.go b/factorio-site.go index e5436ac..a92dddb 100644 --- a/factorio-site.go +++ b/factorio-site.go @@ -14,8 +14,10 @@ import ( ) type config struct { - UseTLS bool `json:"useTLS"` - Servers []server `json:"servers"` + UseTLS bool `json:"useTLS"` + Servers []server `json:"servers"` + TLSHostname string `json:"tlshostname"` + DebugServerPort int `json:"debugserverport"` } type server struct { @@ -116,7 +118,7 @@ func main() { certManager := autocert.Manager{ Prompt: autocert.AcceptTOS, - HostPolicy: autocert.HostWhitelist("factorio.blackolivepineapple.pizza"), // TODO: add config + HostPolicy: autocert.HostWhitelist(config.TLSHostname), Cache: autocert.DirCache("certs"), } @@ -134,7 +136,10 @@ func main() { } else { // Debug fmt.Println("Serving...") - http.ListenAndServe(":8080", nil) // TODO: pass as config value + if config.DebugServerPort == 0 { // Value not set in JSON + config.DebugServerPort = 8080 + } + http.ListenAndServe(fmt.Sprintf(":%v", config.DebugServerPort), nil) // TODO: pass as config value } }