Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func process(request string) string {
return "say \"status <hostname>\" to see vital stats of <hostname>"
}

parts[2] = cleanHostname(parts[2])
address, user, keypath := getSshEntryOrDefault(parts[2])
client, err := sshConnect(user, address, keypath)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions sshhelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"net"
"os"
"os/signal"
"regexp"
"strings"
"syscall"
)
Expand Down Expand Up @@ -141,6 +142,11 @@ func addKeyAuth(auths []ssh.AuthMethod, keypath string) []ssh.AuthMethod {
}
}

func cleanHostname(hostname string) string {
match := regexp.MustCompile(`\<?(?:http\:\/\/)?([\w\.\-\_]+)\|?`)
return match.FindStringSubmatch(hostname)[1]
}

func getAgentAuth() (auth ssh.AuthMethod, ok bool) {
if sock := os.Getenv("SSH_AUTH_SOCK"); len(sock) > 0 {
if agconn, err := net.Dial("unix", sock); err == nil {
Expand Down