improve: login entry logic

This commit is contained in:
Mmx
2024-09-25 20:47:30 +08:00
parent a8b3d168cf
commit 0cb58ec841
3 changed files with 59 additions and 52 deletions

View File

@@ -2,7 +2,6 @@ package controllers
import (
"github.com/Mmx233/BitSrunLoginGo/internal/config"
"github.com/Mmx233/BitSrunLoginGo/tools"
"time"
)
@@ -10,28 +9,12 @@ import (
func Guardian() {
logger := config.Logger
logger.Infoln("[守护模式启动]")
logger.Infoln("[守护模式]")
GuardianDuration := time.Duration(config.Settings.Guardian.Duration) * time.Second
for {
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)
}
}
}
}
_ = Login()
time.Sleep(GuardianDuration)
}
}