Skip to content

Commit

Permalink
Adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jan 29, 2021
1 parent 04b1373 commit 88a1f1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
9 changes: 5 additions & 4 deletions cmd/bridge/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ import (
"strings"
"syscall"

flag "github.com/spf13/pflag"
"github.com/wzshiming/bridge/bridge"
_ "github.com/wzshiming/bridge/command"
_ "github.com/wzshiming/bridge/connect"
"github.com/wzshiming/bridge/internal/log"
"github.com/wzshiming/bridge/internal/scheme"
_ "github.com/wzshiming/bridge/netcat"
_ "github.com/wzshiming/bridge/shadowsocks"
_ "github.com/wzshiming/bridge/smux"
Expand All @@ -21,6 +17,11 @@ import (
_ "github.com/wzshiming/bridge/ssh"
_ "github.com/wzshiming/bridge/tls"
_ "github.com/wzshiming/bridge/ws"

flag "github.com/spf13/pflag"
"github.com/wzshiming/bridge/bridge"
"github.com/wzshiming/bridge/internal/log"
"github.com/wzshiming/bridge/internal/scheme"
"github.com/wzshiming/notify"
)

Expand Down
17 changes: 9 additions & 8 deletions ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func (c *client) reset() {
c.sshCli.Close()
c.sshCli = nil
}

func (c *client) getCli(ctx context.Context) (*ssh.Client, error) {
c.mut.Lock()
defer c.mut.Unlock()
Expand Down Expand Up @@ -171,18 +172,18 @@ func config(addr string) (host string, config *ssh.ClientConfig, err error) {
user = ur.User.Username()
pwd, isPwd = ur.User.Password()
}
host = ur.Hostname()
port := ur.Port()

host, port, err := net.SplitHostPort(ur.Host)
if err != nil {
return "", nil, err
}
if port == "" {
port = "22"
}
host += ":" + port

config = &ssh.ClientConfig{
User: user,
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
return nil
},
User: user,
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
}

if isPwd {
Expand Down Expand Up @@ -211,5 +212,5 @@ func config(addr string) (host string, config *ssh.ClientConfig, err error) {
}
config.Auth = append(config.Auth, ssh.PublicKeys(signer))
}
return host, config, nil
return net.JoinHostPort(host, port), config, nil
}

0 comments on commit 88a1f1f

Please sign in to comment.