fix: Move proxy address config to app.conf

Signed-off-by: WindSpiritSR <simon343riley@gmail.com>
This commit is contained in:
WindSpiritSR 2021-07-02 11:11:28 +08:00
parent 98e0c1aa85
commit 1bca883f4f
2 changed files with 4 additions and 8 deletions

View File

@ -7,5 +7,5 @@ driverName = mysql
dataSourceName = root:123@tcp(localhost:3306)/
dbName = casdoor
authState = "casdoor"
useProxy = false
httpProxy = "127.0.0.1:10808"
verificationCodeTimeout = 10

View File

@ -24,18 +24,14 @@ import (
var httpClient *http.Client
func InitHttpClient() {
useProxy, err := beego.AppConfig.Bool("useProxy")
if err != nil {
panic(err)
}
if !useProxy {
httpProxy := beego.AppConfig.String("httpProxy")
if httpProxy == "" {
httpClient = &http.Client{}
return
}
// https://stackoverflow.com/questions/33585587/creating-a-go-socks5-client
proxyAddress := "127.0.0.1:10808"
dialer, err := proxy.SOCKS5("tcp", proxyAddress, nil, proxy.Direct)
dialer, err := proxy.SOCKS5("tcp", httpProxy, nil, proxy.Direct)
if err != nil {
panic(err)
}