From 2da371c186e44f72e4de8961dc980f042b6fb464 Mon Sep 17 00:00:00 2001 From: ivanfoo Date: Sun, 8 Nov 2015 13:53:39 +0100 Subject: [PATCH] Fixed hostnames bug --- main.go | 1 + sshhelper.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/main.go b/main.go index a7f80ad..b394bae 100644 --- a/main.go +++ b/main.go @@ -196,6 +196,7 @@ func process(request string) string { return "say \"status \" to see vital stats of " } + parts[2] = cleanHostname(parts[2]) address, user, keypath := getSshEntryOrDefault(parts[2]) client, err := sshConnect(user, address, keypath) if err != nil { diff --git a/sshhelper.go b/sshhelper.go index 39b5f86..f277882 100644 --- a/sshhelper.go +++ b/sshhelper.go @@ -39,6 +39,7 @@ import ( "net" "os" "os/signal" + "regexp" "strings" "syscall" ) @@ -141,6 +142,11 @@ func addKeyAuth(auths []ssh.AuthMethod, keypath string) []ssh.AuthMethod { } } +func cleanHostname(hostname string) string { + match := regexp.MustCompile(`\ 0 { if agconn, err := net.Dial("unix", sock); err == nil {