From 0b43319a1239a71532e94d3747006dc676fddd97 Mon Sep 17 00:00:00 2001 From: Dean Sheather Date: Thu, 27 Jun 2019 14:15:24 +1000 Subject: [PATCH] make :PORT optional in parseBindAddr --- main.go | 2 +- sshcode.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 0d16036..f637438 100644 --- a/main.go +++ b/main.go @@ -53,7 +53,7 @@ func (c *rootCmd) RegisterFlags(fl *flag.FlagSet) { fl.BoolVar(&c.skipSync, "skipsync", false, "skip syncing local settings and extensions to remote host") fl.BoolVar(&c.syncBack, "b", false, "sync extensions back on termination") fl.BoolVar(&c.printVersion, "version", false, "print version information and exit") - fl.StringVar(&c.bindAddr, "bind", "", "local bind address for ssh tunnel, in [HOST]:PORT syntax (default: 127.0.0.1)") + fl.StringVar(&c.bindAddr, "bind", "", "local bind address for SSH tunnel, in [HOST][:PORT] syntax (default: 127.0.0.1)") fl.StringVar(&c.sshFlags, "ssh-flags", "", "custom SSH flags") } diff --git a/sshcode.go b/sshcode.go index 97e7502..c43f0f7 100644 --- a/sshcode.go +++ b/sshcode.go @@ -168,8 +168,8 @@ func sshCode(host, dir string, o options) error { } func parseBindAddr(bindAddr string) (string, error) { - if bindAddr == "" { - bindAddr = ":" + if !strings.Contains(bindAddr, ":") { + bindAddr += ":" } host, port, err := net.SplitHostPort(bindAddr)