mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
add the APPLICATION_ERROR, use it in CONNECTION_CLOSE frames
This commit is contained in:
parent
6d61dccc2f
commit
09e16b7602
4 changed files with 8 additions and 9 deletions
|
@ -23,6 +23,7 @@ const (
|
|||
ConnectionIDLimitError ErrorCode = 0x9
|
||||
ProtocolViolation ErrorCode = 0xa
|
||||
InvalidToken ErrorCode = 0xb
|
||||
ApplicationError ErrorCode = 0xc
|
||||
CryptoBufferExceeded ErrorCode = 0xd
|
||||
)
|
||||
|
||||
|
@ -72,6 +73,8 @@ func (e ErrorCode) String() string {
|
|||
return "PROTOCOL_VIOLATION"
|
||||
case InvalidToken:
|
||||
return "INVALID_TOKEN"
|
||||
case ApplicationError:
|
||||
return "APPLICATION_ERROR"
|
||||
case CryptoBufferExceeded:
|
||||
return "CRYPTO_BUFFER_EXCEEDED"
|
||||
default:
|
||||
|
|
|
@ -16,10 +16,6 @@ type QuicError struct {
|
|||
|
||||
var _ net.Error = &QuicError{}
|
||||
|
||||
// UserCanceledError is used if the application closes the connection
|
||||
// before the handshake completes.
|
||||
var UserCanceledError = &QuicError{ErrorCode: 0x15a}
|
||||
|
||||
// NewError creates a new QuicError instance
|
||||
func NewError(errorCode ErrorCode, errorMessage string) *QuicError {
|
||||
return &QuicError{
|
||||
|
|
|
@ -216,7 +216,7 @@ func (p *packetPacker) PackConnectionClose(quicErr *qerr.QuicError) (*coalescedP
|
|||
if encLevel == protocol.EncryptionInitial || encLevel == protocol.EncryptionHandshake {
|
||||
// don't send application errors in Initial or Handshake packets
|
||||
if quicErr.IsApplicationError() {
|
||||
quicErrToSend = qerr.UserCanceledError
|
||||
quicErrToSend = qerr.NewError(qerr.ApplicationError, "")
|
||||
reasonPhrase = ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -336,7 +336,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(p.packets[0].frames[0].Frame).To(BeAssignableToTypeOf(&wire.ConnectionCloseFrame{}))
|
||||
ccf := p.packets[0].frames[0].Frame.(*wire.ConnectionCloseFrame)
|
||||
Expect(ccf.IsApplicationError).To(BeFalse())
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.UserCanceledError.ErrorCode))
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.ApplicationError))
|
||||
Expect(ccf.ReasonPhrase).To(BeEmpty())
|
||||
Expect(p.packets[1].header.Type).To(Equal(protocol.PacketTypeHandshake))
|
||||
Expect(p.packets[1].header.PacketNumber).To(Equal(protocol.PacketNumber(2)))
|
||||
|
@ -344,7 +344,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(p.packets[1].frames[0].Frame).To(BeAssignableToTypeOf(&wire.ConnectionCloseFrame{}))
|
||||
ccf = p.packets[1].frames[0].Frame.(*wire.ConnectionCloseFrame)
|
||||
Expect(ccf.IsApplicationError).To(BeFalse())
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.UserCanceledError.ErrorCode))
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.ApplicationError))
|
||||
Expect(ccf.ReasonPhrase).To(BeEmpty())
|
||||
Expect(p.packets[2].header.IsLongHeader).To(BeFalse())
|
||||
Expect(p.packets[2].header.PacketNumber).To(Equal(protocol.PacketNumber(3)))
|
||||
|
@ -376,7 +376,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(p.packets[0].frames[0].Frame).To(BeAssignableToTypeOf(&wire.ConnectionCloseFrame{}))
|
||||
ccf := p.packets[0].frames[0].Frame.(*wire.ConnectionCloseFrame)
|
||||
Expect(ccf.IsApplicationError).To(BeFalse())
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.UserCanceledError.ErrorCode))
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.ApplicationError))
|
||||
Expect(ccf.ReasonPhrase).To(BeEmpty())
|
||||
Expect(p.packets[1].header.IsLongHeader).To(BeFalse())
|
||||
Expect(p.packets[1].header.PacketNumber).To(Equal(protocol.PacketNumber(2)))
|
||||
|
@ -408,7 +408,7 @@ var _ = Describe("Packet packer", func() {
|
|||
Expect(p.packets[0].frames[0].Frame).To(BeAssignableToTypeOf(&wire.ConnectionCloseFrame{}))
|
||||
ccf := p.packets[0].frames[0].Frame.(*wire.ConnectionCloseFrame)
|
||||
Expect(ccf.IsApplicationError).To(BeFalse())
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.UserCanceledError.ErrorCode))
|
||||
Expect(ccf.ErrorCode).To(Equal(qerr.ApplicationError))
|
||||
Expect(ccf.ReasonPhrase).To(BeEmpty())
|
||||
Expect(p.packets[1].header.Type).To(Equal(protocol.PacketType0RTT))
|
||||
Expect(p.packets[1].header.PacketNumber).To(Equal(protocol.PacketNumber(2)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue