release revsuit vBeta0.1.0 (#15)

Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
Li4n0
2021-05-16 12:11:35 +08:00
committed by GitHub
co-authored by E99p1ant
parent b39ee101f9
commit 5b63e90390
98 changed files with 2357 additions and 623 deletions
+26 -6
View File
@@ -1,16 +1,21 @@
package cli
import (
"fmt"
"os"
"sort"
"github.com/li4n0/revsuit/pkg/server"
"github.com/urfave/cli/v2"
"gopkg.in/yaml.v2"
"gopkg.in/yaml.v3"
log "unknwon.dev/clog/v2"
)
func Start() {
_ = log.NewConsole(100,
log.ConsoleConfig{
Level: log.LevelInfo,
})
app := &cli.App{
Name: "RevSuit",
Usage: "An Open-Sourced Reverse Platform Designed for Receive Various Kinds of Connection",
@@ -23,21 +28,32 @@ func Start() {
Name: "token",
Usage: "token used to manage platform",
},
&cli.StringFlag{
Name: "flags",
Usage: "for http and dns connection, platform will only record the connection those match these regex flags. * meaning record all",
},
&cli.StringFlag{
Name: "db",
Usage: "database file path",
},
&cli.StringFlag{
Name: "log",
Usage: "specify a log level from debug, info, warn, error, fatal. (default: info)",
},
&cli.PathFlag{
Name: "config",
Usage: "load configuration from FILE (default: config.yaml)",
},
},
Action: func(c *cli.Context) error {
var configFile = "config.yaml"
if c.Path("config") != "" {
configFile = c.Path("config")
}
conf := &server.Config{}
if content, err := os.ReadFile("config.yaml"); err == nil {
if content, err := os.ReadFile(configFile); err == nil {
if err := yaml.Unmarshal(content, conf); err != nil {
return err
}
} else if os.IsNotExist(err) && configFile == "config.yaml" {
log.Warn("Generate default configurations to config.yaml, please configure and run again.")
return os.WriteFile("config.yaml", configTemplate, 0644)
} else {
return err
}
@@ -50,6 +66,10 @@ func Start() {
if c.String("db") != "" {
conf.Database = c.String("db")
}
if c.String("log") != "" {
conf.Database = c.String("log")
}
fmt.Printf(banner, server.VERSION)
server.New(conf).Run()
return nil
},