introduce a dedicated qerr.TransportError and qerr.ApplicationError

This commit is contained in:
Marten Seemann 2021-04-24 22:11:06 +07:00
parent ddeb2281fc
commit 592fb9cad9
57 changed files with 845 additions and 521 deletions

View file

@ -22,10 +22,15 @@ type statelessResetErr struct {
token protocol.StatelessResetToken
}
func (e statelessResetErr) Error() string {
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
@ -430,7 +435,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(&statelessResetErr{token: token})
return true
}
return false