Add IP to Config struct

This commit is contained in:
Arnaldo Mendonca
2015-11-09 22:56:49 -02:00
parent 57d791add9
commit 53e87ff642
3 changed files with 6 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import (
) )
type Config struct { type Config struct {
IP string
Port string Port string
Username string Username string
Password string Password string

View File

@@ -133,6 +133,9 @@ func setConfig() {
if config.Port == "" { if config.Port == "" {
config.Port = "2224" config.Port = "2224"
} }
if config.IP == "" {
config.IP = "127.0.0.1"
}
} }
func host() string { func host() string {

View File

@@ -18,11 +18,11 @@ func HttpServer() {
http.HandleFunc("/", AuthHandler(Handler)) http.HandleFunc("/", AuthHandler(Handler))
fmt.Printf("goforever serving port %s\n", config.Port) fmt.Printf("goforever serving port %s\n", config.Port)
if isHttps() == false { if isHttps() == false {
http.ListenAndServe(fmt.Sprintf(":%s", config.Port), nil) http.ListenAndServe(fmt.Sprintf("%s:%s", config.IP, config.Port), nil)
return return
} }
log.Printf("SSL enabled.\n") 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 { func isHttps() bool {