diff --git a/config.go b/config.go index 9b9c8f5..6fcbbc2 100644 --- a/config.go +++ b/config.go @@ -11,6 +11,7 @@ import ( ) type Config struct { + IP string Port string Username string Password string diff --git a/goforever.go b/goforever.go index 192328e..5ac97b5 100644 --- a/goforever.go +++ b/goforever.go @@ -133,6 +133,9 @@ func setConfig() { if config.Port == "" { config.Port = "2224" } + if config.IP == "" { + config.IP = "127.0.0.1" + } } func host() string { diff --git a/http.go b/http.go index 78b169b..7fcffb1 100644 --- a/http.go +++ b/http.go @@ -18,11 +18,11 @@ func HttpServer() { http.HandleFunc("/", AuthHandler(Handler)) fmt.Printf("goforever serving port %s\n", config.Port) if isHttps() == false { - http.ListenAndServe(fmt.Sprintf(":%s", config.Port), nil) + http.ListenAndServe(fmt.Sprintf("%s:%s", config.IP, config.Port), nil) return } log.Printf("SSL enabled.\n") - http.ListenAndServeTLS(fmt.Sprintf(":%s", config.Port), "cert.pem", "key.pem", nil) + http.ListenAndServeTLS(fmt.Sprintf("%s:%s", config.IP, config.Port), "cert.pem", "key.pem", nil) } func isHttps() bool {