From c25f33774f4ee735853c249d1c573667706e55e4 Mon Sep 17 00:00:00 2001 From: Mike Crute Date: Fri, 4 Aug 2023 11:57:40 -0700 Subject: Report version in server/client --- clientmain.go | 4 +++- cmd/client/client.go | 8 ++++---- main.go | 5 +++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/clientmain.go b/clientmain.go index d75b8bc..91fcae0 100644 --- a/clientmain.go +++ b/clientmain.go @@ -12,8 +12,10 @@ import ( _ "time/tzdata" ) +var appVersion string + func main() { - cmd := client.NewClientCommand() + cmd := client.NewClientCommand(appVersion) if err := cmd.Execute(); err != nil { log.Fatalf("Error running root command: %s", err) diff --git a/cmd/client/client.go b/cmd/client/client.go index da4015e..f25e151 100644 --- a/cmd/client/client.go +++ b/cmd/client/client.go @@ -26,10 +26,10 @@ import ( // This should be compiled into the binary var clientId string -func NewClientCommand() *cobra.Command { +func NewClientCommand(appVersion string) *cobra.Command { clientCmd := &cobra.Command{ Use: "client proxy-host ssh-to-host ssh-port username", - Short: "Run websocket client", + Short: fmt.Sprintf("Run websocket client (version %s)", appVersion), Args: cobra.ExactArgs(3), Run: func(c *cobra.Command, args []string) { cfg := app.Config{} @@ -41,8 +41,8 @@ func NewClientCommand() *cobra.Command { return clientCmd } -func Register(root *cobra.Command) { - root.AddCommand(NewClientCommand()) +func Register(root *cobra.Command, appVersion string) { + root.AddCommand(NewClientCommand(appVersion)) } func generateCertificateRequest(username, host string) (ed25519.PrivateKey, []byte, error) { diff --git a/main.go b/main.go index a9c084d..c64f374 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ package main import ( "embed" + "fmt" "io/fs" "log" @@ -32,7 +33,7 @@ var appVersion string func main() { rootCmd := &cobra.Command{ Use: "web-server", - Short: "SSH proxy web server", + Short: fmt.Sprintf("SSH proxy web server (version %s)", appVersion), } cli.AddFlags(rootCmd, &app.Config{}, app.DefaultConfig, "") @@ -42,7 +43,7 @@ func main() { } web.Register(rootCmd, templates, embeddedClients, appVersion) - client.Register(rootCmd) + client.Register(rootCmd, appVersion) register.Register(rootCmd) if err := rootCmd.Execute(); err != nil { -- cgit v1.2.3