expose a StatelessResetError

This commit is contained in:
Marten Seemann 2021-04-25 19:10:15 +07:00
parent 1ce572228b
commit 93cfef57ca
8 changed files with 53 additions and 24 deletions

View file

@ -18,19 +18,6 @@ import (
"github.com/lucas-clemente/quic-go/logging"
)
type statelessResetErr struct {
token protocol.StatelessResetToken
}
func (e *statelessResetErr) Error() string {
return fmt.Sprintf("received a stateless reset with token %x", e.token)
}
func (e *statelessResetErr) Is(target error) bool {
_, ok := target.(*statelessResetErr)
return ok
}
type zeroRTTQueue struct {
queue []*receivedPacket
retireTimer *time.Timer
@ -435,7 +422,7 @@ func (h *packetHandlerMap) maybeHandleStatelessReset(data []byte) bool {
copy(token[:], data[len(data)-16:])
if sess, ok := h.resetTokens[token]; ok {
h.logger.Debugf("Received a stateless reset with token %#x. Closing session.", token)
go sess.destroy(&statelessResetErr{token: token})
go sess.destroy(&StatelessResetError{Token: token})
return true
}
return false