From 13589d2a86c639583c95859ea658fc8cd0de9a37 Mon Sep 17 00:00:00 2001 From: Mmx Date: Wed, 25 Sep 2024 20:49:11 +0800 Subject: [PATCH] feat: add interval for multi interface login #37 --- internal/config/models.go | 9 +++++---- internal/controllers/login.go | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/internal/config/models.go b/internal/config/models.go index b3d50b5..ce23acd 100644 --- a/internal/config/models.go +++ b/internal/config/models.go @@ -24,10 +24,11 @@ type ( } BasicConf struct { - Https bool `json:"https" yaml:"https"` - SkipCertVerify bool `json:"skip_cert_verify" yaml:"skip_cert_verify"` - Timeout uint `json:"timeout" yaml:"timeout"` - Interfaces string `json:"interfaces" yaml:"interfaces"` + Https bool `json:"https" yaml:"https"` + SkipCertVerify bool `json:"skip_cert_verify" yaml:"skip_cert_verify"` + Timeout uint `json:"timeout" yaml:"timeout"` + Interfaces string `json:"interfaces" yaml:"interfaces"` + InterfacesInterval uint `json:"interfaces_interval" yaml:"interfaces_interval"` } LogConf struct { diff --git a/internal/controllers/login.go b/internal/controllers/login.go index eea7c88..e697032 100644 --- a/internal/controllers/login.go +++ b/internal/controllers/login.go @@ -12,6 +12,7 @@ import ( "github.com/Mmx233/BitSrunLoginGo/tools" "net/http" "sync" + "time" ) var ipLast string @@ -53,13 +54,17 @@ func LoginInterfaces() error { if err != nil { return err } + var interval = time.Duration(config.Settings.Basic.InterfacesInterval) * time.Second var errCount int - for _, eth := range interfaces { + for i, eth := range interfaces { logger.Infoln("使用网卡: ", eth.Name) if err := LoginSingle(ð, false); err != nil { config.Logger.Errorf("网卡 %s 登录出错: %v", eth.Name, err) errCount++ } + if i != len(interfaces)-1 { + time.Sleep(interval) + } } if errCount > 0 { return errors.New("multi interface login not completely succeed")