Merge a9398ada8f
into 2c39719cc0
This commit is contained in:
commit
b64958c8d5
@ -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,20 +74,43 @@ 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
|
||||||
tmpStr, ok = conf.Get("common", "auth_token")
|
tmpStr, ok = conf.Get("common", "auth_token")
|
||||||
|
if ok {
|
||||||
|
authToken = tmpStr
|
||||||
|
} else {
|
||||||
|
tmpStr, ok = conf.Get("common", "AUTH_TOKEN")
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
authToken = tmpStr
|
authToken = tmpStr
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("auth_token not found")
|
return fmt.Errorf("auth_token not found")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// proxies
|
// proxies
|
||||||
for name, section := range conf {
|
for name, section := range conf {
|
||||||
@ -89,13 +124,25 @@ func LoadConf(confFile string) (err error) {
|
|||||||
|
|
||||||
// local_ip
|
// local_ip
|
||||||
proxyClient.LocalIp, ok = section["local_ip"]
|
proxyClient.LocalIp, ok = section["local_ip"]
|
||||||
|
if !ok {
|
||||||
|
proxyClient.LocalIp, ok = section["LOCAL_IP"]
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
// use 127.0.0.1 as default
|
// use 127.0.0.1 as default
|
||||||
proxyClient.LocalIp = "127.0.0.1"
|
proxyClient.LocalIp = "127.0.0.1"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// local_port
|
// local_port
|
||||||
portStr, ok := section["local_port"]
|
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 {
|
||||||
|
portStr, ok := section["LOCAL_PORT"]
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
proxyClient.LocalPort, err = strconv.ParseInt(portStr, 10, 64)
|
proxyClient.LocalPort, err = strconv.ParseInt(portStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -104,14 +151,19 @@ func LoadConf(confFile string) (err error) {
|
|||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("Parse ini file error: proxy [%s] local_port not found", proxyClient.Name)
|
return fmt.Errorf("Parse ini file error: proxy [%s] local_port not found", proxyClient.Name)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// use_encryption
|
// use_encryption
|
||||||
proxyClient.UseEncryption = false
|
proxyClient.UseEncryption = false
|
||||||
useEncryptionStr, ok := section["use_encryption"]
|
useEncryptionStr, ok := section["use_encryption"]
|
||||||
|
if ok && useEncryptionStr == "true" {
|
||||||
|
proxyClient.UseEncryption = true
|
||||||
|
} else {
|
||||||
|
useEncryptionStr, ok := section["USE_ENCRYPTION"]
|
||||||
if ok && useEncryptionStr == "true" {
|
if ok && useEncryptionStr == "true" {
|
||||||
proxyClient.UseEncryption = 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
|
||||||
@ -76,16 +105,29 @@ func LoadConf(confFile string) (err error) {
|
|||||||
proxyServer.Name = name
|
proxyServer.Name = name
|
||||||
|
|
||||||
proxyServer.AuthToken, ok = section["auth_token"]
|
proxyServer.AuthToken, ok = section["auth_token"]
|
||||||
|
if !ok {
|
||||||
|
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)
|
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 {
|
||||||
|
proxyServer.BindAddr, ok = section["BIND_ADDR"]
|
||||||
if !ok {
|
if !ok {
|
||||||
proxyServer.BindAddr = "0.0.0.0"
|
proxyServer.BindAddr = "0.0.0.0"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
portStr, ok := section["listen_port"]
|
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 {
|
||||||
|
portStr, ok := section["LISTEN_PORT"]
|
||||||
if ok {
|
if ok {
|
||||||
proxyServer.ListenPort, err = strconv.ParseInt(portStr, 10, 64)
|
proxyServer.ListenPort, err = strconv.ParseInt(portStr, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -94,6 +136,7 @@ func LoadConf(confFile string) (err error) {
|
|||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("Parse ini file error: proxy [%s] listen_port not found", proxyServer.Name)
|
return fmt.Errorf("Parse ini file error: proxy [%s] listen_port not found", proxyServer.Name)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
proxyServer.Init()
|
proxyServer.Init()
|
||||||
ProxyServers[proxyServer.Name] = proxyServer
|
ProxyServers[proxyServer.Name] = proxyServer
|
||||||
|
Loading…
Reference in New Issue
Block a user