|
|
@ -6,14 +6,36 @@ import ( |
|
|
|
quic "github.com/lucas-clemente/quic-go" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
reset quic.ErrorCode = 0 |
|
|
|
) |
|
|
|
|
|
|
|
type stream struct { |
|
|
|
quic.Stream |
|
|
|
} |
|
|
|
|
|
|
|
var _ mux.MuxedStream = &stream{} |
|
|
|
func (s *stream) Read(b []byte) (n int, err error) { |
|
|
|
n, err = s.Stream.Read(b) |
|
|
|
if serr, ok := err.(quic.StreamError); ok && serr.Canceled() { |
|
|
|
err = mux.ErrReset |
|
|
|
} |
|
|
|
|
|
|
|
return n, err |
|
|
|
} |
|
|
|
|
|
|
|
func (s *stream) Write(b []byte) (n int, err error) { |
|
|
|
n, err = s.Stream.Write(b) |
|
|
|
if serr, ok := err.(quic.StreamError); ok && serr.Canceled() { |
|
|
|
err = mux.ErrReset |
|
|
|
} |
|
|
|
|
|
|
|
return n, err |
|
|
|
} |
|
|
|
|
|
|
|
func (s *stream) Reset() error { |
|
|
|
s.Stream.CancelRead(0) |
|
|
|
s.Stream.CancelWrite(0) |
|
|
|
s.Stream.CancelRead(reset) |
|
|
|
s.Stream.CancelWrite(reset) |
|
|
|
return nil |
|
|
|
} |
|
|
|
|
|
|
|
var _ mux.MuxedStream = &stream{} |
|
|
|