Merge pull request #138 from WindSpiritSR/patch-proxy-config

fix: Move proxy address config to app.conf
This commit is contained in:
Yang Luo 2021-07-04 16:00:39 +08:00 committed by GitHub
commit 00b00a20de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

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

View File

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