only accept 3 retries

While the server is allowed to perform multiple Retries, the client
should impose a limit in order to avoid being caught in an endless loop.
This commit is contained in:
Marten Seemann
2018-08-14 18:35:25 +07:00
parent 872e1747f4
commit 9608e8563f
3 changed files with 65 additions and 1 deletions

View File

@@ -29,7 +29,8 @@ type client struct {
packetHandlers packetHandlerManager
token []byte
token []byte
numRetries int
versionNegotiated bool // has the server accepted our version
receivedVersionNegotiationPacket bool
@@ -495,6 +496,11 @@ func (c *client) handleRetryPacket(hdr *wire.Header) {
c.logger.Debugf("Received spoofed Retry. Original Destination Connection ID: %s, expected: %s", hdr.OrigDestConnectionID, c.destConnID)
return
}
c.numRetries++
if c.numRetries > protocol.MaxRetries {
c.session.destroy(qerr.CryptoTooManyRejects)
return
}
c.destConnID = hdr.SrcConnectionID
c.token = hdr.Token
c.session.destroy(errCloseSessionForRetry)