quic

package
v0.0.0-...-46dc631 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HandshakeIdleTimeout = 5 * time.Second
	MaxIdleTimeout       = 5 * time.Second
	MaxIdlePingPeriod    = 1 * time.Second

	// MaxIncomingStreams is 2^60, which is the maximum supported value by Quic-Go
	MaxIncomingStreams = 1 << 60
)
View Source
const (
	MaxDatagramFrameSize = 1350
)

Variables

This section is empty.

Functions

func SuffixSessionID

func SuffixSessionID(sessionID uuid.UUID, b []byte) ([]byte, error)

SuffixSessionID appends the session ID at the end of the payload. Suffix is more performant than prefix because the payload slice might already have enough capacity to append the session ID at the end

func SuffixType

func SuffixType(b []byte, datagramType DatagramV2Type) ([]byte, error)

Types

type BaseDatagramMuxer

type BaseDatagramMuxer interface {
	// SendToSession suffix the session ID to the payload so the other end of the QUIC connection can demultiplex the
	// payload from multiple datagram sessions.
	SendToSession(session *packet.Session) error
	// ServeReceive starts a loop to receive datagrams from the QUIC connection
	ServeReceive(ctx context.Context) error
}

type DatagramMuxer

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

func NewDatagramMuxer

func NewDatagramMuxer(quicSession quic.Connection, log *zerolog.Logger, demuxChan chan<- *packet.Session) *DatagramMuxer

func (*DatagramMuxer) SendToSession

func (dm *DatagramMuxer) SendToSession(session *packet.Session) error

func (*DatagramMuxer) ServeReceive

func (dm *DatagramMuxer) ServeReceive(ctx context.Context) error

type DatagramMuxerV2

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

func NewDatagramMuxerV2

func NewDatagramMuxerV2(
	quicSession quic.Connection,
	log *zerolog.Logger,
	sessionDemuxChan chan<- *packet.Session,
) *DatagramMuxerV2

func (*DatagramMuxerV2) ReceivePacket

func (dm *DatagramMuxerV2) ReceivePacket(ctx context.Context) (pk Packet, err error)

func (*DatagramMuxerV2) SendPacket

func (dm *DatagramMuxerV2) SendPacket(pk Packet) error

SendPacket sends a packet with datagram version in the suffix. If ctx is a TracedContext, it adds the tracing context between payload and datagram version. The other end of the QUIC connection can demultiplex by parsing the payload as IP and look at the source and destination.

func (*DatagramMuxerV2) SendToSession

func (dm *DatagramMuxerV2) SendToSession(session *packet.Session) error

SendToSession suffix the session ID and datagram version to the payload so the other end of the QUIC connection can demultiplex the payload from multiple datagram sessions

func (*DatagramMuxerV2) ServeReceive

func (dm *DatagramMuxerV2) ServeReceive(ctx context.Context) error

Demux reads datagrams from the QUIC connection and demuxes depending on whether it's a session or packet

type DatagramV2Type

type DatagramV2Type byte
const (
	// UDP payload
	DatagramTypeUDP DatagramV2Type = iota
	// Full IP packet
	DatagramTypeIP
	// DatagramTypeIP + tracing ID
	DatagramTypeIPWithTrace
	// Tracing spans in protobuf format
	DatagramTypeTracingSpan
)

type Packet

type Packet interface {
	Type() DatagramV2Type
	Payload() []byte
	Metadata() []byte
}

type RawPacket

type RawPacket packet.RawPacket

func (RawPacket) Metadata

func (rw RawPacket) Metadata() []byte

func (RawPacket) Payload

func (rw RawPacket) Payload() []byte

func (RawPacket) Type

func (rw RawPacket) Type() DatagramV2Type

type SafeStreamCloser

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

func NewSafeStreamCloser

func NewSafeStreamCloser(stream quic.Stream, writeTimeout time.Duration, log *zerolog.Logger) *SafeStreamCloser

func (*SafeStreamCloser) Close

func (s *SafeStreamCloser) Close() error

func (*SafeStreamCloser) CloseWrite

func (s *SafeStreamCloser) CloseWrite() error

func (*SafeStreamCloser) Read

func (s *SafeStreamCloser) Read(p []byte) (n int, err error)

func (*SafeStreamCloser) SetDeadline

func (s *SafeStreamCloser) SetDeadline(deadline time.Time) error

func (*SafeStreamCloser) Write

func (s *SafeStreamCloser) Write(p []byte) (n int, err error)

type TracedPacket

type TracedPacket struct {
	Packet          packet.RawPacket
	TracingIdentity []byte
}

func (*TracedPacket) Metadata

func (tp *TracedPacket) Metadata() []byte

func (*TracedPacket) Payload

func (tp *TracedPacket) Payload() []byte

func (*TracedPacket) Type

func (tp *TracedPacket) Type() DatagramV2Type

type TracingSpanPacket

type TracingSpanPacket struct {
	Spans           []byte
	TracingIdentity []byte
}

func (*TracingSpanPacket) Metadata

func (tsp *TracingSpanPacket) Metadata() []byte

func (*TracingSpanPacket) Payload

func (tsp *TracingSpanPacket) Payload() []byte

func (*TracingSpanPacket) Type

func (tsp *TracingSpanPacket) Type() DatagramV2Type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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