refactor socks5 proxy and cron config
This commit is contained in:
parent
89946ffd62
commit
9a919c5399
@ -56,14 +56,16 @@ func BotStart() {
|
|||||||
}
|
}
|
||||||
//set socks5
|
//set socks5
|
||||||
if config.Socks5 != "" {
|
if config.Socks5 != "" {
|
||||||
fmt.Println("Proxy:" + config.Socks5)
|
fmt.Println("Proxy: " + config.Socks5)
|
||||||
dialer, err := proxy.SOCKS5("tcp", config.Socks5, nil, proxy.Direct)
|
dialer, err := proxy.SOCKS5("tcp", config.Socks5, nil, proxy.Direct)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
zap.S().Errorw("failed to make dialer", "error", err, "socks5", config.Socks5)
|
zap.S().Errorw("failed to get dialer",
|
||||||
|
"error", err, "proxy", config.Socks5)
|
||||||
}
|
}
|
||||||
httpTransport := &http.Transport{}
|
httpTransport := &http.Transport{}
|
||||||
httpClient := &http.Client{Transport: httpTransport}
|
|
||||||
httpTransport.Dial = dialer.Dial
|
httpTransport.Dial = dialer.Dial
|
||||||
|
httpClient := &http.Client{Transport: httpTransport}
|
||||||
|
|
||||||
botSetting.Client = httpClient
|
botSetting.Client = httpClient
|
||||||
}
|
}
|
||||||
//create bot
|
//create bot
|
||||||
|
|||||||
@ -41,7 +41,11 @@ func InitConfig() {
|
|||||||
zap.S().Errorw("failed to read config", "error", err)
|
zap.S().Errorw("failed to read config", "error", err)
|
||||||
}
|
}
|
||||||
BotToken = viper.GetString("bot_token")
|
BotToken = viper.GetString("bot_token")
|
||||||
|
Cron = viper.GetString("cron")
|
||||||
Socks5 = viper.GetString("socks5")
|
Socks5 = viper.GetString("socks5")
|
||||||
|
//if Socks5[:5] != "socks5" {
|
||||||
|
// Socks5 = "socks5://" + Socks5
|
||||||
|
//}
|
||||||
|
|
||||||
viper.SetDefault("errlimit", 5)
|
viper.SetDefault("errlimit", 5)
|
||||||
viper.SetDefault("bindmax", 5)
|
viper.SetDefault("bindmax", 5)
|
||||||
@ -49,7 +53,7 @@ func InitConfig() {
|
|||||||
BindMaxNum = viper.GetInt("bindmax")
|
BindMaxNum = viper.GetInt("bindmax")
|
||||||
MaxErrTimes = viper.GetInt("errlimit")
|
MaxErrTimes = viper.GetInt("errlimit")
|
||||||
Notice = viper.GetString("notice")
|
Notice = viper.GetString("notice")
|
||||||
Cron = viper.GetString("cron")
|
|
||||||
MaxGoroutines = viper.GetInt("goroutine")
|
MaxGoroutines = viper.GetInt("goroutine")
|
||||||
Admins = getAdmins()
|
Admins = getAdmins()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user