mirror of
https://github.com/gwoo/goforever.git
synced 2025-09-27 03:45:51 +08:00
Add IP to Config struct
This commit is contained in:
@@ -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
|
||||||
|
@@ -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 {
|
||||||
|
4
http.go
4
http.go
@@ -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 {
|
||||||
|
Reference in New Issue
Block a user