fix_cfg_bug
This commit is contained in:
parent
2c39719cc0
commit
a9398ada8f
@ -47,11 +47,23 @@ func LoadConf(confFile string) (err error) {
|
|||||||
tmpStr, ok = conf.Get("common", "server_addr")
|
tmpStr, ok = conf.Get("common", "server_addr")
|
||||||
if ok {
|
if ok {
|
||||||
ServerAddr = tmpStr
|
ServerAddr = tmpStr
|
||||||
|
} else {
|
||||||
|
tmpStr, ok = conf.Get("common", "SERVER_ADDR")
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
ServerAddr = tmpStr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpStr, ok = conf.Get("common", "server_port")
|
tmpStr, ok = conf.Get("common", "server_port")
|
||||||
if ok {
|
if ok {
|
||||||
ServerPort, _ = strconv.ParseInt(tmpStr, 10, 64)
|
ServerPort, _ = strconv.ParseInt(tmpStr, 10, 64)
|
||||||
|
} else {
|
||||||
|
tmpStr, ok = conf.Get("common", "SERVER_PORT")
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
ServerPort, _ = strconv.ParseInt(tmpStr, 10, 64)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpStr, ok = conf.Get("common", "log_file")
|
tmpStr, ok = conf.Get("common", "log_file")
|
||||||
@ -62,11 +74,28 @@ func LoadConf(confFile string) (err error) {
|
|||||||
} else {
|
} else {
|
||||||
LogWay = "file"
|
LogWay = "file"
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tmpStr, ok = conf.Get("common", "LOG_FILE")
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
LogFile = tmpStr
|
||||||
|
if LogFile == "console" {
|
||||||
|
LogWay = "console"
|
||||||
|
} else {
|
||||||
|
LogWay = "file"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpStr, ok = conf.Get("common", "log_level")
|
tmpStr, ok = conf.Get("common", "log_level")
|
||||||
if ok {
|
if ok {
|
||||||
LogLevel = tmpStr
|
LogLevel = tmpStr
|
||||||
|
} else {
|
||||||
|
tmpStr, ok = conf.Get("common", "LOG_LEVEL")
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
LogLevel = tmpStr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var authToken string
|
var authToken string
|
||||||
@ -74,7 +103,13 @@ func LoadConf(confFile string) (err error) {
|
|||||||
if ok {
|
if ok {
|
||||||
authToken = tmpStr
|
authToken = tmpStr
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("auth_token not found")
|
tmpStr, ok = conf.Get("common", "AUTH_TOKEN")
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
authToken = tmpStr
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("auth_token not found")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// proxies
|
// proxies
|
||||||
@ -90,8 +125,12 @@ func LoadConf(confFile string) (err error) {
|
|||||||
// local_ip
|
// local_ip
|
||||||
proxyClient.LocalIp, ok = section["local_ip"]
|
proxyClient.LocalIp, ok = section["local_ip"]
|
||||||
if !ok {
|
if !ok {
|
||||||
// use 127.0.0.1 as default
|
proxyClient.LocalIp, ok = section["LOCAL_IP"]
|
||||||
proxyClient.LocalIp = "127.0.0.1"
|
|
||||||
|
if !ok {
|
||||||
|
// use 127.0.0.1 as default
|
||||||
|
proxyClient.LocalIp = "127.0.0.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// local_port
|
// local_port
|
||||||
@ -102,7 +141,16 @@ func LoadConf(confFile string) (err error) {
|
|||||||
return fmt.Errorf("Parse ini file error: proxy [%s] local_port error", proxyClient.Name)
|
return fmt.Errorf("Parse ini file error: proxy [%s] local_port error", proxyClient.Name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("Parse ini file error: proxy [%s] local_port not found", proxyClient.Name)
|
portStr, ok := section["LOCAL_PORT"]
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
proxyClient.LocalPort, err = strconv.ParseInt(portStr, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Parse ini file error: proxy [%s] local_port error", proxyClient.Name)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("Parse ini file error: proxy [%s] local_port not found", proxyClient.Name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// use_encryption
|
// use_encryption
|
||||||
@ -110,8 +158,12 @@ func LoadConf(confFile string) (err error) {
|
|||||||
useEncryptionStr, ok := section["use_encryption"]
|
useEncryptionStr, ok := section["use_encryption"]
|
||||||
if ok && useEncryptionStr == "true" {
|
if ok && useEncryptionStr == "true" {
|
||||||
proxyClient.UseEncryption = true
|
proxyClient.UseEncryption = true
|
||||||
|
} else {
|
||||||
|
useEncryptionStr, ok := section["USE_ENCRYPTION"]
|
||||||
|
if ok && useEncryptionStr == "true" {
|
||||||
|
proxyClient.UseEncryption = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxyClients[proxyClient.Name] = proxyClient
|
ProxyClients[proxyClient.Name] = proxyClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,11 +47,23 @@ func LoadConf(confFile string) (err error) {
|
|||||||
tmpStr, ok = conf.Get("common", "bind_addr")
|
tmpStr, ok = conf.Get("common", "bind_addr")
|
||||||
if ok {
|
if ok {
|
||||||
BindAddr = tmpStr
|
BindAddr = tmpStr
|
||||||
|
} else {
|
||||||
|
tmpStr, ok = conf.Get("common", "BIND_ADDR")
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
BindAddr = tmpStr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpStr, ok = conf.Get("common", "bind_port")
|
tmpStr, ok = conf.Get("common", "bind_port")
|
||||||
if ok {
|
if ok {
|
||||||
BindPort, _ = strconv.ParseInt(tmpStr, 10, 64)
|
BindPort, _ = strconv.ParseInt(tmpStr, 10, 64)
|
||||||
|
} else {
|
||||||
|
tmpStr, ok = conf.Get("common", "BIND_PORT")
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
BindPort, _ = strconv.ParseInt(tmpStr, 10, 64)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpStr, ok = conf.Get("common", "log_file")
|
tmpStr, ok = conf.Get("common", "log_file")
|
||||||
@ -62,11 +74,28 @@ func LoadConf(confFile string) (err error) {
|
|||||||
} else {
|
} else {
|
||||||
LogWay = "file"
|
LogWay = "file"
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tmpStr, ok = conf.Get("common", "LOG_FILE")
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
LogFile = tmpStr
|
||||||
|
if LogFile == "console" {
|
||||||
|
LogWay = "console"
|
||||||
|
} else {
|
||||||
|
LogWay = "file"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tmpStr, ok = conf.Get("common", "log_level")
|
tmpStr, ok = conf.Get("common", "log_level")
|
||||||
if ok {
|
if ok {
|
||||||
LogLevel = tmpStr
|
LogLevel = tmpStr
|
||||||
|
} else {
|
||||||
|
tmpStr, ok = conf.Get("common", "LOG_LEVEL")
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
LogLevel = tmpStr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// servers
|
// servers
|
||||||
@ -77,12 +106,18 @@ func LoadConf(confFile string) (err error) {
|
|||||||
|
|
||||||
proxyServer.AuthToken, ok = section["auth_token"]
|
proxyServer.AuthToken, ok = section["auth_token"]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("Parse ini file error: proxy [%s] no auth_token found", proxyServer.Name)
|
proxyServer.AuthToken, ok = section["AUTH_TOKEN"]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("Parse ini file error: proxy [%s] no auth_token found", proxyServer.Name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyServer.BindAddr, ok = section["bind_addr"]
|
proxyServer.BindAddr, ok = section["bind_addr"]
|
||||||
if !ok {
|
if !ok {
|
||||||
proxyServer.BindAddr = "0.0.0.0"
|
proxyServer.BindAddr, ok = section["BIND_ADDR"]
|
||||||
|
if !ok {
|
||||||
|
proxyServer.BindAddr = "0.0.0.0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
portStr, ok := section["listen_port"]
|
portStr, ok := section["listen_port"]
|
||||||
@ -92,7 +127,15 @@ func LoadConf(confFile string) (err error) {
|
|||||||
return fmt.Errorf("Parse ini file error: proxy [%s] listen_port error", proxyServer.Name)
|
return fmt.Errorf("Parse ini file error: proxy [%s] listen_port error", proxyServer.Name)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("Parse ini file error: proxy [%s] listen_port not found", proxyServer.Name)
|
portStr, ok := section["LISTEN_PORT"]
|
||||||
|
if ok {
|
||||||
|
proxyServer.ListenPort, err = strconv.ParseInt(portStr, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Parse ini file error: proxy [%s] listen_port error", proxyServer.Name)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return fmt.Errorf("Parse ini file error: proxy [%s] listen_port not found", proxyServer.Name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
proxyServer.Init()
|
proxyServer.Init()
|
||||||
|
Loading…
Reference in New Issue
Block a user