From 8f087e9ca1950d88205e459e2645594e11639009 Mon Sep 17 00:00:00 2001 From: Russ Magee Date: Sat, 12 May 2018 18:41:39 -0700 Subject: [PATCH] Added -v option (version) --- hkexsh/hkexsh.go | 8 ++++++++ hkexshd/hkexshd.go | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/hkexsh/hkexsh.go b/hkexsh/hkexsh.go index 12a08dc..1aaa95c 100644 --- a/hkexsh/hkexsh.go +++ b/hkexsh/hkexsh.go @@ -66,6 +66,8 @@ func getTermSize() (rows int, cols int, err error) { func main() { var wg sync.WaitGroup + version := "0.1pre (NO WARRANTY)" + var vopt bool var dbg bool var cAlg string var hAlg string @@ -79,6 +81,7 @@ func main() { isInteractive := false + flag.BoolVar(&vopt, "v", false, "show version") flag.StringVar(&cAlg, "c", "C_AES_256", "cipher [\"C_AES_256\" | \"C_TWOFISH_128\" | \"C_BLOWFISH_64\"]") flag.StringVar(&hAlg, "h", "H_SHA256", "hmac [\"H_SHA256\"]") flag.StringVar(&server, "s", "localhost:2000", "server hostname/address[:port]") @@ -91,6 +94,11 @@ func main() { flag.BoolVar(&dbg, "d", false, "debug logging") flag.Parse() + if vopt { + fmt.Printf("version v%s\n", version) + os.Exit(0) + } + if dbg { log.SetOutput(os.Stdout) } else { diff --git a/hkexshd/hkexshd.go b/hkexshd/hkexshd.go index 369a121..d2bbf56 100644 --- a/hkexshd/hkexshd.go +++ b/hkexshd/hkexshd.go @@ -158,12 +158,15 @@ func rejectUserMsg() string { // Listener and Conns. The KEx and encrypt/decrypt is done within the type. // Compare to 'serverp.go' in this directory to see the equivalence. func main() { + version := "0.1pre (NO WARRANTY)" + var vopt bool var chaffFreqMin uint var chaffFreqMax uint var chaffBytesMax uint var dbg bool var laddr string + flag.BoolVar(&vopt, "v", false, "show version") flag.StringVar(&laddr, "l", ":2000", "interface[:port] to listen") flag.UintVar(&chaffFreqMin, "cfm", 100, "chaff pkt freq min (msecs)") flag.UintVar(&chaffFreqMax, "cfM", 5000, "chaff pkt freq max (msecs)") @@ -171,6 +174,11 @@ func main() { flag.BoolVar(&dbg, "d", false, "debug logging") flag.Parse() + if vopt { + fmt.Printf("version v%s\n", version) + os.Exit(0) + } + if dbg { log.SetOutput(os.Stdout) } else {