go.crypto/ssh: support OpenSSH keepalives

Fixes golang/go#4552.

R=minux.ma, agl
CC=golang-dev
https://golang.org/cl/6948059
This commit is contained in:
Eric Milliken
2012-12-18 11:33:58 -05:00
committed by Adam Langley
parent d95b28330d
commit 61ab4d36df
3 changed files with 46 additions and 1 deletions
+7 -1
View File
@@ -404,7 +404,13 @@ func (s *Session) wait() error {
}
wm.lang = safeString(string(lang))
default:
return fmt.Errorf("wait: unexpected channel request: %v", msg)
// This handles keepalives and matches
// OpenSSH's behaviour.
if msg.WantReply {
s.writePacket(marshal(msgChannelFailure, channelRequestFailureMsg{
PeersId: s.remoteId,
}))
}
}
default:
return fmt.Errorf("wait: unexpected packet %T received: %v", msg, msg)