fix: remove unused goroutine for guardian

This commit is contained in:
Mmx
2024-09-24 23:54:51 +08:00
parent e68bd88e05
commit 1d753419bc

View File

@@ -2,9 +2,8 @@ package controllers
import ( import (
"github.com/Mmx233/BitSrunLoginGo/internal/config" "github.com/Mmx233/BitSrunLoginGo/internal/config"
"time"
"github.com/Mmx233/BitSrunLoginGo/tools" "github.com/Mmx233/BitSrunLoginGo/tools"
"time"
) )
// Guardian 守护模式逻辑 // Guardian 守护模式逻辑
@@ -15,30 +14,24 @@ func Guardian() {
GuardianDuration := time.Duration(config.Settings.Guardian.Duration) * time.Second GuardianDuration := time.Duration(config.Settings.Guardian.Duration) * time.Second
var c = make(chan bool)
for { for {
go func() { if config.Settings.Basic.Interfaces == "" { //单网卡
if config.Settings.Basic.Interfaces == "" { //单网卡 err := Login(nil, true)
err := Login(nil, true) if err != nil {
if err != nil { logger.Errorln("登录出错: ", err)
logger.Errorln("登录出错: ", err) }
} } else { //多网卡
} else { //多网卡 interfaces, err := tools.GetInterfaceAddr(logger, config.Settings.Basic.Interfaces)
interfaces, err := tools.GetInterfaceAddr(logger, config.Settings.Basic.Interfaces) if err == nil {
if err == nil { for _, eth := range interfaces {
for _, eth := range interfaces { logger.Debugf("使用 %s 网口登录 ", eth.Name)
logger.Debugf("使用 %s 网口登录 ", eth.Name) err = Login(&eth, true)
err = Login(&eth, true) if err != nil {
if err != nil { logger.Errorln("网口 ", eth.Name+" 登录出错: ", err)
logger.Errorln("网口 ", eth.Name+" 登录出错: ", err)
}
} }
} }
} }
}
c <- false
}()
<-c
time.Sleep(GuardianDuration) time.Sleep(GuardianDuration)
} }
} }