improve: 使用标准项目结构

This commit is contained in:
Mmx233
2023-03-01 18:58:11 +08:00
parent cb11426bd6
commit 3c63e9ddc3
29 changed files with 178 additions and 183 deletions

40
cmd/bitsrun/bitsrun.go Normal file
View File

@@ -0,0 +1,40 @@
package main
import (
"fmt"
controllers2 "github.com/Mmx233/BitSrunLoginGo/internal/controllers"
global2 "github.com/Mmx233/BitSrunLoginGo/internal/global"
"github.com/Mmx233/BitSrunLoginGo/tools"
log "github.com/sirupsen/logrus"
)
func main() {
if global2.Flags.RunningDaemon {
//后台挂起模式中
controllers2.Guardian()
} else if global2.Config.Settings.Guardian.Enable {
//进入守护模式流程
controllers2.EnterGuardian()
} else {
//登录流程
var err error
if global2.Config.Settings.Basic.Interfaces == "" { //单网卡
if err = controllers2.Login(nil, false); err != nil {
log.Errorln("登录出错: ", err)
if !global2.Config.Settings.Log.DebugLevel {
fmt.Printf("开启调试日志debug_level获取详细信息")
}
return
}
} else { //多网卡
log.Infoln("多网卡模式")
interfaces, _ := tools.GetInterfaceAddr()
for _, eth := range interfaces {
log.Infoln("使用网卡: ", eth.Name)
if err = controllers2.Login(eth.Addr, false); err != nil {
log.Errorf("网卡 %s 登录出错: %v", eth.Name, err)
}
}
}
}
}