retire stateless reset tokens instead of deleting them immediately

This commit is contained in:
Marten Seemann 2019-10-26 07:02:14 +07:00
parent 772ffd3d20
commit ffbb810fcc
5 changed files with 35 additions and 34 deletions

View file

@ -249,22 +249,21 @@ var _ = Describe("Packet Handler Map", func() {
Eventually(destroyed).Should(BeClosed())
})
It("deletes reset tokens", func() {
It("retires reset tokens", func() {
handler.deleteRetiredSessionsAfter = scaleDuration(10 * time.Millisecond)
connID := protocol.ConnectionID{0xde, 0xad, 0xbe, 0xef, 0x42}
packetHandler := NewMockPacketHandler(mockCtrl)
handler.Add(connID, packetHandler)
token := [16]byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}
handler.AddResetToken(token, NewMockPacketHandler(mockCtrl))
handler.RemoveResetToken(token)
handler.RetireResetToken(token)
packetHandler.EXPECT().handlePacket(gomock.Any())
p := append([]byte{0x40} /* short header packet */, connID.Bytes()...)
p = append(p, make([]byte, 50)...)
p = append(p, token[:]...)
time.Sleep(scaleDuration(30 * time.Millisecond))
handler.handlePacket(nil, nil, p)
// destroy() would be called from a separate go routine
// make sure we give it enough time to be called to cause an error here
time.Sleep(scaleDuration(25 * time.Millisecond))
})
It("ignores packets too small to contain a stateless reset", func() {