diff --git a/connection.go b/connection.go index 9c8821d91ff..b922979644c 100644 --- a/connection.go +++ b/connection.go @@ -2358,9 +2358,10 @@ func (s *connection) SendDatagram(p []byte) error { } f := &wire.DatagramFrame{DataLenPresent: true} - if protocol.ByteCount(len(p)) > f.MaxDataLen(s.peerParams.MaxDatagramFrameSize, s.version) { + maxDataLen := f.MaxDataLen(s.peerParams.MaxDatagramFrameSize, s.version) + if protocol.ByteCount(len(p)) > maxDataLen { return &DatagramTooLargeError{ - PeerMaxDatagramFrameSize: int64(s.peerParams.MaxDatagramFrameSize), + PeerMaxDatagramFrameSize: int64(maxDataLen), } } f.Data = make([]byte, len(p)) diff --git a/errors.go b/errors.go index fda3c9247cc..a5fa87b1e6f 100644 --- a/errors.go +++ b/errors.go @@ -49,11 +49,6 @@ type StreamError struct { Remote bool } -func (e *StreamError) Is(target error) bool { - _, ok := target.(*StreamError) - return ok -} - func (e *StreamError) Error() string { pers := "local" if e.Remote { @@ -67,9 +62,4 @@ type DatagramTooLargeError struct { PeerMaxDatagramFrameSize int64 } -func (e *DatagramTooLargeError) Is(target error) bool { - _, ok := target.(*DatagramTooLargeError) - return ok -} - func (e *DatagramTooLargeError) Error() string { return "DATAGRAM frame too large" } diff --git a/integrationtests/self/cancelation_test.go b/integrationtests/self/cancelation_test.go index 28f3e009a96..9027886ca4f 100644 --- a/integrationtests/self/cancelation_test.go +++ b/integrationtests/self/cancelation_test.go @@ -246,6 +246,7 @@ var _ = Describe("Stream Cancellations", func() { Expect(err).To(MatchError(&quic.StreamError{ StreamID: str.StreamID(), ErrorCode: quic.StreamErrorCode(str.StreamID()), + Remote: true, })) return } @@ -356,6 +357,7 @@ var _ = Describe("Stream Cancellations", func() { Expect(err).To(MatchError(&quic.StreamError{ StreamID: str.StreamID(), ErrorCode: quic.StreamErrorCode(str.StreamID()), + Remote: true, })) return } @@ -396,6 +398,7 @@ var _ = Describe("Stream Cancellations", func() { Expect(err).To(MatchError(&quic.StreamError{ StreamID: str.StreamID(), ErrorCode: quic.StreamErrorCode(str.StreamID()), + Remote: true, })) return } @@ -441,6 +444,7 @@ var _ = Describe("Stream Cancellations", func() { Expect(err).To(MatchError(&quic.StreamError{ StreamID: str.StreamID(), ErrorCode: quic.StreamErrorCode(str.StreamID()), + Remote: true, })) return } @@ -486,6 +490,7 @@ var _ = Describe("Stream Cancellations", func() { Expect(err).To(MatchError(&quic.StreamError{ StreamID: str.StreamID(), ErrorCode: quic.StreamErrorCode(str.StreamID()), + Remote: true, })) return }