go.crypto/ssh: add a error return to decode(), and avoid casting decode() output.

R=dave, kardianos, agl
CC=gobot, golang-dev
https://golang.org/cl/9738053
This commit is contained in:
Han-Wen Nienhuys
2013-06-06 10:24:21 -04:00
committed by Adam Langley
parent e8889f5e72
commit 36bf31eb71
4 changed files with 27 additions and 13 deletions
+9 -2
View File
@@ -249,8 +249,15 @@ func (c *ClientConn) mainLoop() {
ch.stderr.write(packet)
}
default:
msg := decode(packet)
switch msg := msg.(type) {
decoded, err := decode(packet)
if err != nil {
if _, ok := err.(UnexpectedMessageError); ok {
fmt.Printf("mainLoop: unexpected message: %v\n", err)
continue
}
return
}
switch msg := decoded.(type) {
case *channelOpenMsg:
c.handleChanOpen(msg)
case *channelOpenConfirmMsg: