Skip to content

Commit b887606

Browse files
author
octeep
committed
add print version flag
1 parent ab4a521 commit b887606

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

cmd/wireproxy/main.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
// an argument to denote that this process was spawned by -d
1515
const daemonProcess = "daemon-process"
1616

17+
var version = "dev"
18+
1719
// attempts to pledge and panic if it fails
1820
// this does nothing on non-OpenBSD systems
1921
func pledgeOrPanic(promises string) {
@@ -60,8 +62,9 @@ func main() {
6062
}
6163
parser := argparse.NewParser("wireproxy", "Userspace wireguard client for proxying")
6264

63-
config := parser.String("c", "config", &argparse.Options{Required: true, Help: "Path of configuration file"})
65+
config := parser.String("c", "config", &argparse.Options{Help: "Path of configuration file"})
6466
daemon := parser.Flag("d", "daemon", &argparse.Options{Help: "Make wireproxy run in background"})
67+
printVerison := parser.Flag("v", "version", &argparse.Options{Help: "Print version"})
6568
configTest := parser.Flag("n", "configtest", &argparse.Options{Help: "Configtest mode. Only check the configuration file for validity."})
6669

6770
err := parser.Parse(args)
@@ -70,6 +73,16 @@ func main() {
7073
return
7174
}
7275

76+
if *printVerison {
77+
fmt.Printf("wireproxy, version %s\n", version)
78+
return
79+
}
80+
81+
if *config == "" {
82+
fmt.Println("configuration path is required")
83+
return
84+
}
85+
7386
if !*daemon {
7487
// remove proc and exec if they are not needed
7588
pledgeOrPanic("stdio rpath inet dns")

0 commit comments

Comments
 (0)