mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
don't send stateless resets for small packets
This prevents amplification and looping.
This commit is contained in:
parent
19cf46d736
commit
5c20519743
2 changed files with 12 additions and 0 deletions
|
@ -245,6 +245,11 @@ func (h *packetHandlerMap) GetStatelessResetToken(connID protocol.ConnectionID)
|
|||
|
||||
func (h *packetHandlerMap) maybeSendStatelessReset(p *receivedPacket, connID protocol.ConnectionID) {
|
||||
defer p.buffer.Release()
|
||||
// Don't send a stateless reset in response to very small packets.
|
||||
// This includes packets that could be stateless resets.
|
||||
if len(p.data) <= protocol.MinStatelessResetSize {
|
||||
return
|
||||
}
|
||||
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)
|
||||
|
|
|
@ -229,6 +229,13 @@ var _ = Describe("Packet Handler Map", func() {
|
|||
Expect(reset.data[0] & 0x80).To(BeZero()) // short header packet
|
||||
Expect(reset.data).To(HaveLen(protocol.MinStatelessResetSize))
|
||||
})
|
||||
|
||||
It("doesn't send stateless resets for small packets", func() {
|
||||
addr := &net.UDPAddr{IP: net.IPv4(192, 168, 0, 1), Port: 1337}
|
||||
p := append([]byte{40}, make([]byte, protocol.MinStatelessResetSize-2)...)
|
||||
handler.handlePacket(addr, getPacketBuffer(), p)
|
||||
Consistently(conn.dataWritten).ShouldNot(Receive())
|
||||
})
|
||||
})
|
||||
|
||||
Context("running a server", func() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue