This commit is contained in:
fatedier
2018-08-08 11:18:38 +08:00
parent 6e305db4be
commit ca88b07ecf
5 changed files with 38 additions and 27 deletions

View File

@ -51,8 +51,11 @@ type ServerCommonConf struct {
VhostHttpPort int `json:"vhost_http_port"`
// if VhostHttpsPort equals 0, don't listen a public port for https protocol
VhostHttpsPort int `json:"vhost_http_port"`
DashboardAddr string `json:"dashboard_addr"`
VhostHttpsPort int `json:"vhost_http_port"`
VhostHttpTimeout int64 `json:"vhost_http_timeout"`
DashboardAddr string `json:"dashboard_addr"`
// if DashboardPort equals 0, dashboard is not available
DashboardPort int `json:"dashboard_port"`
@ -73,7 +76,6 @@ type ServerCommonConf struct {
MaxPortsPerClient int64 `json:"max_ports_per_client"`
HeartBeatTimeout int64 `json:"heart_beat_timeout"`
UserConnTimeout int64 `json:"user_conn_timeout"`
VhostHttpTimeout int64 `json:"vhost_http_timeout "`
}
func GetDefaultServerConf() *ServerCommonConf {
@ -85,6 +87,7 @@ func GetDefaultServerConf() *ServerCommonConf {
ProxyBindAddr: "0.0.0.0",
VhostHttpPort: 0,
VhostHttpsPort: 0,
VhostHttpTimeout: 60,
DashboardAddr: "0.0.0.0",
DashboardPort: 0,
DashboardUser: "admin",
@ -103,7 +106,6 @@ func GetDefaultServerConf() *ServerCommonConf {
MaxPortsPerClient: 0,
HeartBeatTimeout: 90,
UserConnTimeout: 10,
VhostHttpTimeout: 30,
}
}
@ -183,6 +185,16 @@ func UnmarshalServerConfFromIni(defaultCfg *ServerCommonConf, content string) (c
cfg.VhostHttpsPort = 0
}
if tmpStr, ok = conf.Get("common", "vhost_http_timeout"); ok {
v, errRet := strconv.ParseInt(tmpStr, 10, 64)
if errRet != nil || v < 0 {
err = fmt.Errorf("Parse conf error: invalid vhost_http_timeout")
return
} else {
cfg.VhostHttpTimeout = v
}
}
if tmpStr, ok = conf.Get("common", "dashboard_addr"); ok {
cfg.DashboardAddr = tmpStr
} else {
@ -302,15 +314,6 @@ func UnmarshalServerConfFromIni(defaultCfg *ServerCommonConf, content string) (c
cfg.HeartBeatTimeout = v
}
}
if tmpStr, ok = conf.Get("common", "vhost_http_timeout"); ok {
v, errRet := strconv.ParseInt(tmpStr, 10, 64)
if errRet != nil {
err = fmt.Errorf("Parse conf error: vhost_http_timeout is incorrect")
return
} else {
cfg.VhostHttpTimeout = v
}
}
return
}