From d02fd5178a95a16f5e721fdd466a2c9662f3d6c4 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sat, 31 Aug 2019 12:33:53 +0700 Subject: [PATCH] adjust the minimum size for stateless resets to the new header format --- internal/protocol/protocol.go | 4 ++-- packet_handler_map.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/protocol/protocol.go b/internal/protocol/protocol.go index 7c4d6071..8c750e5f 100644 --- a/internal/protocol/protocol.go +++ b/internal/protocol/protocol.go @@ -56,8 +56,8 @@ const DefaultTCPMSS ByteCount = 1460 // MinInitialPacketSize is the minimum size an Initial packet is required to have. const MinInitialPacketSize = 1200 -// MinStatelessResetSize is the minimum size of a stateless reset packet -const MinStatelessResetSize = 1 /* first byte */ + 22 /* random bytes */ + 16 /* token */ +// MinStatelessResetSize is the minimum size of a stateless reset packet that we send +const MinStatelessResetSize = 1 /* first byte */ + 20 /* max. conn ID length */ + 4 /* max. packet number length */ + 1 /* min. payload length */ + 16 /* token */ // MinConnectionIDLenInitial is the minimum length of the destination connection ID on an Initial packet. const MinConnectionIDLenInitial = 8 diff --git a/packet_handler_map.go b/packet_handler_map.go index 12e2e70e..57a77f7a 100644 --- a/packet_handler_map.go +++ b/packet_handler_map.go @@ -264,7 +264,7 @@ func (h *packetHandlerMap) maybeSendStatelessReset(p *receivedPacket, connID pro } token := h.GetStatelessResetToken(connID) h.logger.Debugf("Sending stateless reset to %s (connection ID: %s). Token: %#x", p.remoteAddr, connID, token) - data := make([]byte, 23) + data := make([]byte, protocol.MinStatelessResetSize-16, protocol.MinStatelessResetSize) rand.Read(data) data[0] = (data[0] & 0x7f) | 0x40 data = append(data, token[:]...)