diff --git a/client.go b/client.go index 983ea19..c914a6e 100644 --- a/client.go +++ b/client.go @@ -35,8 +35,8 @@ type Client struct { // // func NewClient(c net.Conn, config *ssh.ClientConfig, addr string, conf *Conf) (*Client, error) { - obfsConn := &TimedOutConn{c, conf.Timeout} - sshConn, newch, reqs, err := ssh.NewClientConn(obfsConn, addr, config) + //obfsConn := &TimedOutConn{c, conf.Timeout} + sshConn, newch, reqs, err := ssh.NewClientConn(c, addr, config) if err != nil { return nil, err } @@ -342,6 +342,7 @@ func (cc *Client) registerSignal() { // AddDynamicHTTPForward add a http dynamic forward through // secure channel func (cc *Client) AddDynamicHTTPForward(addr string) error { + Log(DEBUG, "add dynamic http listen: %s", addr) l, err := net.Listen("tcp", addr) if err != nil { Log(ERROR, "listen on %s failed, %s", addr, err) diff --git a/obfssh/ssh.go b/obfssh/ssh.go index 27fc009..b607125 100644 --- a/obfssh/ssh.go +++ b/obfssh/ssh.go @@ -51,6 +51,8 @@ func main() { obfssh.SSHLogLevel = obfssh.DEBUG } + obfssh.Log(obfssh.DEBUG, "obfssh client start") + auth := []ssh.AuthMethod{} var agentConn net.Conn @@ -188,6 +190,7 @@ func main() { err = fmt.Errorf("unsupported scheme: %s", cfg.Proxy.Scheme) } } else { + obfssh.Log(obfssh.DEBUG, "dail to %s", rhost) c, err = dialer.Dial("tcp", rhost) } @@ -195,28 +198,40 @@ func main() { log.Fatal(err) } - tlsConn := c + obfssh.Log(obfssh.DEBUG, "dail success") + + timeout := time.Duration(cfg.KeepaliveInterval*2) * time.Second + + var _conn = c + + conn := &obfssh.TimedOutConn{Conn: c, Timeout: timeout} + if cfg.TLS { - tlsConn = tls.Client(c, &tls.Config{ + obfssh.Log(obfssh.DEBUG, "begin tls handshake") + _conn = tls.Client(conn, &tls.Config{ ServerName: host, InsecureSkipVerify: cfg.TLSInsecure, }) - if err := tlsConn.(*tls.Conn).Handshake(); err != nil { + if err := _conn.(*tls.Conn).Handshake(); err != nil { log.Fatal(err) } + obfssh.Log(obfssh.DEBUG, "tls handshake done") } conf := &obfssh.Conf{ - Timeout: time.Duration(cfg.KeepaliveInterval*2) * time.Second, + Timeout: timeout, KeepAliveInterval: time.Duration(cfg.KeepaliveInterval) * time.Second, KeepAliveMax: cfg.KeepaliveMax, } - client, err := obfssh.NewClient(tlsConn, config, rhost, conf) + obfssh.Log(obfssh.DEBUG, "ssh negotation") + client, err := obfssh.NewClient(_conn, config, rhost, conf) if err != nil { log.Fatal(err) } + obfssh.Log(obfssh.DEBUG, "ssh negotation success") + var local, remote string // process port forward @@ -308,6 +323,7 @@ func main() { hasErr = true } + obfssh.Log(obfssh.DEBUG, "obfssh client exit") if hasErr { os.Exit(1) }