dquicwrap

package
v0.0.0-...-d223f38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package dquicwrap declares QUIC wrapper types to ensure the quic.Connection values exposed to the application are able to interoperate with the low level streams managed internally by the dragon stack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

Conn wraps a dquic.Conn, for the dpeerset package.

Normally one might embed the wrapped interface value, but in this case we want to be extremely precise about the behavior of every method.

func NewConn

func NewConn(q dquic.Conn, incomingStreams <-chan *Stream) *Conn

NewConn returns a Conn wrapping the given plain dquic.Conn.

The incomingStreams channel determines the streams that reach AcceptStream. There should be another goroutine that accepts the raw streams, and then parses the first byte in order to determine whether the stream should be routed to the "application layer" (here) or remain in the protocol layer. (In practice, the [*dpeerset.peerInboundProcessor] does this work.)

func (*Conn) AcceptStream

func (c *Conn) AcceptStream(ctx context.Context) (dquic.Stream, error)

AcceptStream implements dquic.Conn.

func (*Conn) AcceptUniStream

func (c *Conn) AcceptUniStream(ctx context.Context) (dquic.ReceiveStream, error)

AcceptUniStream implements dquic.Conn.

func (*Conn) CloseWithError

func (c *Conn) CloseWithError(
	code dquic.ApplicationErrorCode, msg string,
) error

CloseWithError implements dquic.Conn.

func (*Conn) Context

func (c *Conn) Context() context.Context

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

LocalAddr implements dquic.Conn.

func (*Conn) OpenStreamSync

func (c *Conn) OpenStreamSync(ctx context.Context) (dquic.Stream, error)

OpenStreamSync implements dquic.Conn.

func (*Conn) OpenUniStreamSync

func (c *Conn) OpenUniStreamSync(ctx context.Context) (dquic.SendStream, error)

OpenUniStreamSync implements dquic.Conn.

func (*Conn) ReceiveDatagram

func (c *Conn) ReceiveDatagram(ctx context.Context) ([]byte, error)

ReceiveDatagram implements dquic.Conn.

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

RemoteAddr implements dquic.Conn.

func (*Conn) SendDatagram

func (c *Conn) SendDatagram(p []byte) error

SendDatagram implements dquic.Conn.

func (*Conn) TLSConnectionState

func (c *Conn) TLSConnectionState() tls.ConnectionState

TLSConnectionState implements dquic.Conn.

func (*Conn) WrapsConnection

func (c *Conn) WrapsConnection(conn dquic.Conn) bool

WrapsConnection reports whether c is wrapping conn. This is only intended for tests.

type Stream

type Stream struct {
	// Just embed the receive stream,
	// because we don't do any intercepting on receive streams.
	dquic.ReceiveStream
	// contains filtered or unexported fields
}

Stream wraps a real quic.Stream.

Normally one might embed the wrapped interface value, but in this case we want to be extremely precise about the behavior of every method.

func NewInboundStream

func NewInboundStream(
	q dquic.Stream,
	alreadyConsumedProtocolID byte,
) *Stream

NewInboundStream returns a wrapped stream that prepends the first read with the given alreadyConsumedProtocolID byte.

This is used when dragon internals intercept an incoming stream and then inspect the first byte, to decide whether the stream should be routed to the application layer or remain in the p2p protocol layer.

func NewOutboundStream

func NewOutboundStream(dqs dquic.Stream) *Stream

NewOutboundStream returns a wrapped stream that requires that the first outbound byte is >= dconn.MinAppProtocolID.

func (*Stream) CancelWrite

func (s *Stream) CancelWrite(code dquic.StreamErrorCode)

CancelWrite implements quic.SendStream.

func (*Stream) Close

func (s *Stream) Close() error

Close implements quic.SendStream.

func (*Stream) Read

func (s *Stream) Read(p []byte) (int, error)

TODO: we need to extract a ReceiveStream and move this declaration to that type.

func (*Stream) SetWriteDeadline

func (s *Stream) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements quic.SendStream.

func (*Stream) Write

func (s *Stream) Write(p []byte) (int, error)

Write implements quic.SendStream.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL