feat: add interval for multi interface login

#37
This commit is contained in:
Mmx
2024-09-25 20:49:11 +08:00
parent 0cb58ec841
commit 13589d2a86
2 changed files with 11 additions and 5 deletions

View File

@@ -24,10 +24,11 @@ type (
} }
BasicConf struct { BasicConf struct {
Https bool `json:"https" yaml:"https"` Https bool `json:"https" yaml:"https"`
SkipCertVerify bool `json:"skip_cert_verify" yaml:"skip_cert_verify"` SkipCertVerify bool `json:"skip_cert_verify" yaml:"skip_cert_verify"`
Timeout uint `json:"timeout" yaml:"timeout"` Timeout uint `json:"timeout" yaml:"timeout"`
Interfaces string `json:"interfaces" yaml:"interfaces"` Interfaces string `json:"interfaces" yaml:"interfaces"`
InterfacesInterval uint `json:"interfaces_interval" yaml:"interfaces_interval"`
} }
LogConf struct { LogConf struct {

View File

@@ -12,6 +12,7 @@ import (
"github.com/Mmx233/BitSrunLoginGo/tools" "github.com/Mmx233/BitSrunLoginGo/tools"
"net/http" "net/http"
"sync" "sync"
"time"
) )
var ipLast string var ipLast string
@@ -53,13 +54,17 @@ func LoginInterfaces() error {
if err != nil { if err != nil {
return err return err
} }
var interval = time.Duration(config.Settings.Basic.InterfacesInterval) * time.Second
var errCount int var errCount int
for _, eth := range interfaces { for i, eth := range interfaces {
logger.Infoln("使用网卡: ", eth.Name) logger.Infoln("使用网卡: ", eth.Name)
if err := LoginSingle(&eth, false); err != nil { if err := LoginSingle(&eth, false); err != nil {
config.Logger.Errorf("网卡 %s 登录出错: %v", eth.Name, err) config.Logger.Errorf("网卡 %s 登录出错: %v", eth.Name, err)
errCount++ errCount++
} }
if i != len(interfaces)-1 {
time.Sleep(interval)
}
} }
if errCount > 0 { if errCount > 0 {
return errors.New("multi interface login not completely succeed") return errors.New("multi interface login not completely succeed")