use dialer on package obfssh

tls
Dingjun 7 years ago
parent 441017d722
commit fb6c630cec

@ -232,7 +232,7 @@ func (cc *Client) handleLocalForward(conn net.Conn, remote string) {
} }
func (cc *Client) handleRemoteForward(conn net.Conn, local string) { func (cc *Client) handleRemoteForward(conn net.Conn, local string) {
lconn, err := net.Dial("tcp", local) lconn, err := dialer.Dial("tcp", local)
if err != nil { if err != nil {
Log(ERROR, "connect to %s failed: %s", local, err.Error()) Log(ERROR, "connect to %s failed: %s", local, err.Error())
conn.Close() conn.Close()

@ -5,6 +5,8 @@ import (
"time" "time"
) )
var dialer = &net.Dialer{Timeout: 10 * time.Second}
// TimedOutConn is a net.Conn with read/write timeout set // TimedOutConn is a net.Conn with read/write timeout set
type TimedOutConn struct { type TimedOutConn struct {
net.Conn net.Conn

@ -182,7 +182,7 @@ func handleDirectTcpip(newch ssh.NewChannel) {
Log(DEBUG, "create connection to %s:%d", r.Raddr, r.Rport) Log(DEBUG, "create connection to %s:%d", r.Raddr, r.Rport)
rconn, err := net.Dial("tcp", net.JoinHostPort(r.Raddr, fmt.Sprintf("%d", r.Rport))) rconn, err := dialer.Dial("tcp", net.JoinHostPort(r.Raddr, fmt.Sprintf("%d", r.Rport)))
if err != nil { if err != nil {
Log(ERROR, "%s", err.Error()) Log(ERROR, "%s", err.Error())
newch.Reject(ssh.ConnectionFailed, "invalid argument") newch.Reject(ssh.ConnectionFailed, "invalid argument")

Loading…
Cancel
Save