Skip to content

Commit

Permalink
update dep ssh
Browse files Browse the repository at this point in the history
  • Loading branch information
luopengift committed Dec 29, 2018
1 parent 949b420 commit 3e8238c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
2 changes: 1 addition & 1 deletion console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func StartConsole(ctx context.Context, conf *config.Config) error {
log.ConsoleWithRed("输入有误! 请输入 H/h 查看帮助.")
continue
}
endpoint := getEndpoint(inputList[1])
endpoint := ssh.NewEndpoint(inputList[1])
endpoint.Mask(conf.Global)
Login(endpoint, conf)
default:
Expand Down
22 changes: 0 additions & 22 deletions console/util.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package console

import (
"regexp"
"strings"

"github.com/luopengift/ssh"
)

func include(input string, items ...string) bool {
for _, v := range items {
if input == v {
Expand All @@ -31,18 +24,3 @@ func isVersion(str string) bool {
func isHelp(str string) bool {
return include(str, "h", "H", "help")
}

func getEndpoint(str string) *ssh.Endpoint {
endpoint := ssh.NewEndpoint()
if strings.Contains(str, "@") {
d := strings.Split(str, "@")
endpoint.User, endpoint.IP = d[0], d[1]
} else {
endpoint.IP = str
}
if strings.HasPrefix(endpoint.IP, "ip-") { // support aws hostname format
re := regexp.MustCompile(`[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}`)
endpoint.IP = strings.Replace(re.FindString(endpoint.IP), "-", ".", -1)
}
return endpoint
}

0 comments on commit 3e8238c

Please sign in to comment.