mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-16 19:00:05 +07:00
feat: add flag disable-timestamp; check empty node list after subscription resolving
This commit is contained in:
15
cmd/run.go
15
cmd/run.go
@ -15,7 +15,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
cfgFile string
|
||||
cfgFile string
|
||||
disableTimestamp bool
|
||||
|
||||
runCmd = &cobra.Command{
|
||||
Use: "run",
|
||||
@ -24,7 +25,9 @@ var (
|
||||
if cfgFile == "" {
|
||||
logrus.Fatalln("Argument \"--config\" or \"-c\" is required but not provided.")
|
||||
}
|
||||
if err := Run(); err != nil {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
log := logger.NewLogger(2, disableTimestamp)
|
||||
if err := Run(log); err != nil {
|
||||
logrus.Fatalln(err)
|
||||
}
|
||||
},
|
||||
@ -33,11 +36,10 @@ var (
|
||||
|
||||
func init() {
|
||||
runCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file")
|
||||
runCmd.PersistentFlags().BoolVarP(&disableTimestamp, "disable-timestamp", "", false, "disable timestamp")
|
||||
}
|
||||
|
||||
func Run() (err error) {
|
||||
logrus.SetLevel(logrus.DebugLevel)
|
||||
log := logger.NewLogger(2)
|
||||
func Run(log *logrus.Logger) (err error) {
|
||||
|
||||
// Require "sudo" if necessary.
|
||||
internal.AutoSu()
|
||||
@ -58,6 +60,9 @@ func Run() (err error) {
|
||||
}
|
||||
nodeList = append(nodeList, nodes...)
|
||||
}
|
||||
if len(nodeList) == 0 {
|
||||
return fmt.Errorf("no node found, which could because all subscription resolving failed")
|
||||
}
|
||||
|
||||
if len(param.Global.LanInterface) == 0 && len(param.Global.WanInterface) == 0 {
|
||||
return fmt.Errorf("LanInterface and WanInterface cannot both be empty")
|
||||
|
Reference in New Issue
Block a user