feat: acid 自动嗅探逻辑
This commit is contained in:
@@ -11,18 +11,18 @@ import (
|
||||
|
||||
// Login 登录逻辑
|
||||
func Login(eth *tools.Eth, debugOutput bool) error {
|
||||
// 登录状态检查
|
||||
|
||||
// 登录配置初始化
|
||||
httpClient := tools.HttpPackSelect(eth).Client
|
||||
conf := &srun.Conf{
|
||||
Https: global.Config.Settings.Basic.Https,
|
||||
LoginInfo: srun.LoginInfo{
|
||||
Form: &global.Config.Form,
|
||||
Meta: &global.Config.Meta,
|
||||
Form: global.Config.Form,
|
||||
Meta: global.Config.Meta,
|
||||
},
|
||||
Client: httpClient,
|
||||
}
|
||||
|
||||
// 选择输出函数
|
||||
var output func(args ...interface{})
|
||||
if debugOutput {
|
||||
output = log.Debugln
|
||||
|
||||
@@ -43,7 +43,7 @@ func readConfig() {
|
||||
},
|
||||
})
|
||||
|
||||
//生成配置文件
|
||||
// 生成配置文件
|
||||
if exist, e := tool.File.Exists(Flags.Path); e != nil {
|
||||
log.Fatalln("[init] 读取配置文件失败:", e)
|
||||
} else if !exist {
|
||||
@@ -55,7 +55,7 @@ func readConfig() {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
//读取配置文件
|
||||
// 读取配置文件
|
||||
viper.SetConfigFile(Flags.Path)
|
||||
if e := viper.ReadInConfig(); e != nil {
|
||||
log.Fatalln("[init] 读取配置失败:", e)
|
||||
@@ -63,4 +63,12 @@ func readConfig() {
|
||||
if e := viper.Unmarshal(&Config); e != nil {
|
||||
log.Fatalln("[init] 解析配置失败:", e)
|
||||
}
|
||||
|
||||
// flag 配置覆写
|
||||
if Flags.Debug {
|
||||
Config.Settings.Log.DebugLevel = true
|
||||
}
|
||||
if Flags.Acid != "" {
|
||||
Config.Meta.Acid = Flags.Acid
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,16 +5,23 @@ import (
|
||||
)
|
||||
|
||||
var Flags struct {
|
||||
//配置文件路径
|
||||
// 配置文件路径
|
||||
Path string
|
||||
|
||||
// settings overwrite
|
||||
Interface string
|
||||
Debug bool
|
||||
AutoAcid bool
|
||||
Acid string
|
||||
}
|
||||
|
||||
func initFlags() {
|
||||
flag.StringVar(&Flags.Path, "config", "Config.yaml", "config path")
|
||||
|
||||
flag.StringVar(&Flags.Interface, "interface", "", "specify the eth name")
|
||||
flag.BoolVar(&Flags.Debug, "debug", false, "enable debug mode")
|
||||
flag.BoolVar(&Flags.AutoAcid, "auto-acid", false, "auto detect acid")
|
||||
flag.StringVar(&Flags.Acid, "acid", "", "specify acid value")
|
||||
|
||||
flag.Parse()
|
||||
}
|
||||
|
||||
@@ -11,9 +11,6 @@ import (
|
||||
)
|
||||
|
||||
func initLog() {
|
||||
if Flags.Debug {
|
||||
Config.Settings.Log.DebugLevel = true
|
||||
}
|
||||
if Config.Settings.Log.DebugLevel {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user