mirror of
https://github.com/gwoo/goforever.git
synced 2025-09-26 19:41:10 +08:00
Add IP to Config struct
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
IP string
|
||||
Port string
|
||||
Username string
|
||||
Password string
|
||||
|
@@ -133,6 +133,9 @@ func setConfig() {
|
||||
if config.Port == "" {
|
||||
config.Port = "2224"
|
||||
}
|
||||
if config.IP == "" {
|
||||
config.IP = "127.0.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
func host() string {
|
||||
|
4
http.go
4
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 {
|
||||
|
Reference in New Issue
Block a user