mirror of
https://github.com/whyvl/wireproxy.git
synced 2025-04-29 19:01:42 +02:00
add configtest flag
This commit is contained in:
parent
68b99e2c17
commit
ebdf73c840
2 changed files with 18 additions and 9 deletions
|
@ -27,14 +27,17 @@ anything.
|
|||
|
||||
```
|
||||
usage: wireproxy [-h|--help] -c|--config "<value>" [-d|--daemon]
|
||||
[-n|--configtest]
|
||||
|
||||
Userspace wireguard client for proxying
|
||||
|
||||
Arguments:
|
||||
|
||||
-h --help Print help information
|
||||
-c --config Path of configuration file
|
||||
-d --daemon Make wireproxy run in background
|
||||
-h --help Print help information
|
||||
-c --config Path of configuration file
|
||||
-d --daemon Make wireproxy run in background
|
||||
-n --configtest Configtest mode. Only check the configuration file for
|
||||
validity.
|
||||
```
|
||||
|
||||
# Sample config file
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue