feat: 重构配置层,添加 json 支持

This commit is contained in:
Mmx233
2023-08-28 22:03:03 +08:00
parent 2a098e00dd
commit 6f283a93f5
19 changed files with 318 additions and 272 deletions

View File

@@ -1,7 +1,7 @@
package controllers
import (
"github.com/Mmx233/BitSrunLoginGo/internal/global"
"github.com/Mmx233/BitSrunLoginGo/internal/config"
"time"
"github.com/Mmx233/BitSrunLoginGo/tools"
@@ -12,7 +12,7 @@ import (
func Guardian() {
log.Infoln("[以守护模式启动]")
GuardianDuration := time.Duration(global.Config.Settings.Guardian.Duration) * time.Second
GuardianDuration := time.Duration(config.Settings.Guardian.Duration) * time.Second
var c = make(chan bool)
for {
@@ -20,13 +20,13 @@ func Guardian() {
defer func() {
_ = recover()
}()
if global.Config.Settings.Basic.Interfaces == "" { //单网卡
if config.Settings.Basic.Interfaces == "" { //单网卡
e := Login(nil, true)
if e != nil {
log.Errorln("登录出错: ", e)
}
} else { //多网卡
interfaces, e := tools.GetInterfaceAddr(global.Config.Settings.Basic.Interfaces)
interfaces, e := tools.GetInterfaceAddr(config.Settings.Basic.Interfaces)
if e == nil {
for _, eth := range interfaces {
log.Debugf("使用 %s 网口登录 ", eth.Name)