feat: add domain and external ip configuration items (#18)

This commit is contained in:
Li4n0
2021-05-22 20:40:04 +08:00
committed by GitHub
parent bc6e3962f8
commit 1144f67d37
55 changed files with 228 additions and 143 deletions
+12 -1
View File
@@ -47,10 +47,21 @@ func Start() {
configFile = c.Path("config")
}
conf := &server.Config{}
tpl := &server.Config{}
_ = yaml.Unmarshal(configTemplate, tpl)
if content, err := os.ReadFile(configFile); err == nil {
if err := yaml.Unmarshal(content, conf); err != nil {
return err
}
if conf.Version != tpl.Version {
backup := fmt.Sprintf("%s_%.1f", configFile, conf.Version)
log.Warn("Old version of configuration file detected, new configuration file being generated, old configuration backed up to %s", backup)
if err := os.WriteFile(backup, content, 0644); err != nil {
return err
}
return os.WriteFile(configFile, configTemplate, 0644)
}
} 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)
@@ -69,13 +80,13 @@ func Start() {
if c.String("log") != "" {
conf.Database = c.String("log")
}
fmt.Printf(banner, server.VERSION)
server.New(conf).Run()
return nil
},
}
sort.Sort(cli.FlagsByName(app.Flags))
sort.Sort(cli.CommandsByName(app.Commands))
fmt.Printf(banner, server.VERSION)
err := app.Run(os.Args)
if err != nil {
+3 -2
View File
@@ -1,6 +1,8 @@
version: 4.0
version: 1.0
addr: :10000
token:
domain:
external_ip: # You need to make sure that your target can access the server through this ip.
database: revsuit.db
log_level: info
@@ -18,7 +20,6 @@ mysql:
ftp:
enable: true
addr: :21
pasv_ip: 127.0.0.1 # your public network ip
pasv_port: 2020
notice:
dingtalk: https://oapi.dingtalk.com/robot/send?access_token={token}