make original unit test happy

This commit is contained in:
tgic 2014-12-16 11:58:36 +08:00 committed by Boshi Lian
parent 0611c1218d
commit aafab2a9a9
4 changed files with 30 additions and 4 deletions

View file

@ -76,12 +76,21 @@ func NewClientConn(c net.Conn, addr string, config *ClientConfig) (Conn, <-chan
return nil, nil, nil, fmt.Errorf("ssh: handshake failed: %v", err)
}
conn.mux = newMux(conn.transport)
go conn.mux.loop()
return conn, conn.mux.incomingChannels, conn.mux.incomingRequests, nil
}
func (c *connection) clientHandshake(dialAddress string, config *ClientConfig) error {
if err := c.clientHandshakeNoAuth(dialAddress, config); err != nil {
return err
}
return c.clientAuthenticate(config)
}
// clientHandshake performs the client side key exchange. See RFC 4253 Section
// 7.
func (c *connection) clientHandshake(dialAddress string, config *ClientConfig) error {
func (c *connection) clientHandshakeNoAuth(dialAddress string, config *ClientConfig) error {
c.clientVersion = []byte(packageVersion)
if config.ClientVersion != "" {
c.clientVersion = []byte(config.ClientVersion)

View file

@ -15,7 +15,9 @@ func muxPair() (*mux, *mux) {
a, b := memPipe()
s := newMux(a)
go s.loop()
c := newMux(b)
go c.loop()
return s, c
}

View file

@ -157,8 +157,23 @@ func signAndMarshal(k Signer, rand io.Reader, data []byte) ([]byte, error) {
return Marshal(sig), nil
}
// handshake performs key exchange and user authentication.
func (s *connection) serverHandshake(config *ServerConfig) (*Permissions, error) {
if _, err := s.serverHandshakeNoAuth(config); err != nil {
return nil, err
}
perms, err := s.serverAuthenticate(config)
if err != nil {
return nil, err
}
s.mux = newMux(s.transport)
go s.mux.loop()
return perms, nil
}
// handshake performs key exchange and user authentication.
func (s *connection) serverHandshakeNoAuth(config *ServerConfig) (*Permissions, error) {
if len(config.hostKeys) == 0 {
return nil, errors.New("ssh: server has no host keys")
}

View file

@ -375,7 +375,7 @@ func newDownstream(c net.Conn, config *ServerConfig) (*downstream, error) {
sshConn: sshConn{conn: c},
}
_, err := s.serverHandshake(&fullConf)
_, err := s.serverHandshakeNoAuth(&fullConf)
if err != nil {
c.Close()
return nil, err
@ -392,7 +392,7 @@ func newUpstream(c net.Conn, addr string, config *ClientConfig) (*upstream, erro
sshConn: sshConn{conn: c},
}
if err := conn.clientHandshake(addr, &fullConf); err != nil {
if err := conn.clientHandshakeNoAuth(addr, &fullConf); err != nil {
c.Close()
return nil, err
}