Skip to content

Commit

Permalink
refactor socks5 proxy and cron config
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Jun 19, 2021
1 parent 89946ff commit 9a919c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 5 additions & 3 deletions bots/bots.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ func BotStart() {
}
//set socks5
if config.Socks5 != "" {
fmt.Println("Proxy:" + config.Socks5)
fmt.Println("Proxy: " + config.Socks5)
dialer, err := proxy.SOCKS5("tcp", config.Socks5, nil, proxy.Direct)
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{}
httpClient := &http.Client{Transport: httpTransport}
httpTransport.Dial = dialer.Dial
httpClient := &http.Client{Transport: httpTransport}

botSetting.Client = httpClient
}
//create bot
Expand Down
6 changes: 5 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,19 @@ func InitConfig() {
zap.S().Errorw("failed to read config", "error", err)
}
BotToken = viper.GetString("bot_token")
Cron = viper.GetString("cron")
Socks5 = viper.GetString("socks5")
//if Socks5[:5] != "socks5" {
// Socks5 = "socks5://" + Socks5
//}

viper.SetDefault("errlimit", 5)
viper.SetDefault("bindmax", 5)

BindMaxNum = viper.GetInt("bindmax")
MaxErrTimes = viper.GetInt("errlimit")
Notice = viper.GetString("notice")
Cron = viper.GetString("cron")

MaxGoroutines = viper.GetInt("goroutine")
Admins = getAdmins()

Expand Down

0 comments on commit 9a919c5

Please sign in to comment.