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