github.com/Psiphon-Labs/psiphon-tunnel-core@v2.0.28+incompatible/psiphon/common/quic/gquic-go/crypto_stream.go (about) 1 package gquic 2 3 import ( 4 "io" 5 6 "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/quic/gquic-go/internal/flowcontrol" 7 "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/quic/gquic-go/internal/protocol" 8 "github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common/quic/gquic-go/internal/wire" 9 ) 10 11 type cryptoStream interface { 12 StreamID() protocol.StreamID 13 io.Reader 14 io.Writer 15 handleStreamFrame(*wire.StreamFrame) error 16 hasData() bool 17 popStreamFrame(protocol.ByteCount) (*wire.StreamFrame, bool) 18 closeForShutdown(error) 19 setReadOffset(protocol.ByteCount) 20 // methods needed for flow control 21 getWindowUpdate() protocol.ByteCount 22 handleMaxStreamDataFrame(*wire.MaxStreamDataFrame) 23 } 24 25 type cryptoStreamImpl struct { 26 *stream 27 } 28 29 var _ cryptoStream = &cryptoStreamImpl{} 30 31 func newCryptoStream(sender streamSender, flowController flowcontrol.StreamFlowController, version protocol.VersionNumber) cryptoStream { 32 str := newStream(version.CryptoStreamID(), sender, flowController, version) 33 return &cryptoStreamImpl{str} 34 } 35 36 // SetReadOffset sets the read offset. 37 // It is only needed for the crypto stream. 38 // It must not be called concurrently with any other stream methods, especially Read and Write. 39 func (s *cryptoStreamImpl) setReadOffset(offset protocol.ByteCount) { 40 s.receiveStream.readOffset = offset 41 s.receiveStream.frameQueue.readPos = offset 42 }