add configtest flag
This commit is contained in:
@@ -13,7 +13,7 @@ import (
|
||||
const daemonProcess = "daemon-process"
|
||||
|
||||
func main() {
|
||||
isDaemonProcess := os.Args[1] == daemonProcess
|
||||
isDaemonProcess := len(os.Args) > 1 && os.Args[1] == daemonProcess
|
||||
args := os.Args
|
||||
if isDaemonProcess {
|
||||
args = []string{args[0]}
|
||||
@@ -24,6 +24,7 @@ func main() {
|
||||
|
||||
config := parser.String("c", "config", &argparse.Options{Required: true, Help: "Path of configuration file"})
|
||||
daemon := parser.Flag("d", "daemon", &argparse.Options{Help: "Make wireproxy run in background"})
|
||||
configTest := parser.Flag("n", "configtest", &argparse.Options{Help: "Configtest mode. Only check the configuration file for validity."})
|
||||
|
||||
err := parser.Parse(args)
|
||||
if err != nil {
|
||||
@@ -31,6 +32,16 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
conf, err := wireproxy.ParseConfig(*config)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
if *configTest {
|
||||
fmt.Println("Config OK")
|
||||
return
|
||||
}
|
||||
|
||||
if isDaemonProcess {
|
||||
os.Stdout, _ = os.Open(os.DevNull)
|
||||
os.Stderr, _ = os.Open(os.DevNull)
|
||||
@@ -53,11 +64,6 @@ func main() {
|
||||
return
|
||||
}
|
||||
|
||||
conf, err := wireproxy.ParseConfig(*config)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
tnet, err := wireproxy.StartWireguard(conf.Device)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
|
||||
Reference in New Issue
Block a user