protocol

package
v0.0.0-...-bd2efb5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// InvalidStreamNum is an invalid stream number.
	InvalidStreamNum = -1
	// MaxStreamCount is the maximum stream count value that can be sent in MAX_STREAMS frames
	// and as the stream count in the transport parameters
	MaxStreamCount StreamNum = 1 << 60
	// MaxStreamID is the maximum stream ID
	MaxStreamID StreamID = 4611686018427387903 // 2^62 - 1
)
View Source
const (
	// FirstIncomingBidiStreamServer is the first bidirectional stream accepted by the server
	FirstIncomingBidiStreamServer = FirstOutgoingBidiStreamClient
	// FirstIncomingUniStreamServer is the first unidirectional stream accepted by the server
	FirstIncomingUniStreamServer = FirstOutgoingUniStreamClient
	// FirstIncomingBidiStreamClient is the first bidirectional stream accepted by the client
	FirstIncomingBidiStreamClient = FirstOutgoingBidiStreamServer
	// FirstIncomingUniStreamClient is the first unidirectional stream accepted by the client
	FirstIncomingUniStreamClient = FirstOutgoingUniStreamServer
)
View Source
const ConnectionFlowControlMultiplier = 1.5

ConnectionFlowControlMultiplier determines how much larger the connection flow control windows needs to be relative to any stream's flow control window This is the value that Chromium is using

View Source
const TimerGranularity = time.Millisecond

Estimated timer granularity. The loss detection timer will not be set to a value smaller than granularity.

View Source
const WindowUpdateThreshold = 0.25

WindowUpdateThreshold is the fraction of the receive window that has to be consumed before an higher offset is advertised to the client

Variables

View Source
var SupportedVersions = []Version{Version1, Version2}

SupportedVersions lists the versions that the server supports must be in sorted descending order

Functions

func IsSupportedVersion

func IsSupportedVersion(supported []Version, v Version) bool

IsSupportedVersion returns true if the server supports this version

func IsValidVersion

func IsValidVersion(v Version) bool

IsValidVersion says if the version is known to quic-go

Types

type ByteCount

type ByteCount int64

type Perspective

type Perspective int

Perspective determines if we're acting as a server or a client

const (
	PerspectiveServer Perspective = 1
	PerspectiveClient Perspective = 2
)

the perspectives

func (Perspective) Opposite

func (p Perspective) Opposite() Perspective

Opposite returns the perspective of the peer

func (Perspective) String

func (p Perspective) String() string

type StreamID

type StreamID int64

A StreamID in QUIC

const (
	// FirstOutgoingBidiStreamClient is the first bidirectional stream opened by the client
	FirstOutgoingBidiStreamClient StreamID = 0
	// FirstOutgoingUniStreamClient is the first unidirectional stream opened by the client
	FirstOutgoingUniStreamClient StreamID = 2
	// FirstOutgoingBidiStreamServer is the first bidirectional stream opened by the server
	FirstOutgoingBidiStreamServer StreamID = 1
	// FirstOutgoingUniStreamServer is the first unidirectional stream opened by the server
	FirstOutgoingUniStreamServer StreamID = 3
)
const InvalidStreamID StreamID = -1

InvalidPacketNumber is a stream ID that is invalid. The first valid stream ID in QUIC is 0.

func (StreamID) InitiatedBy

func (s StreamID) InitiatedBy() Perspective

InitiatedBy says if the stream was initiated by the client or by the server

func (StreamID) StreamNum

func (s StreamID) StreamNum() StreamNum

StreamNum returns how many streams in total are below this Example: for stream 9 it returns 3 (i.e. streams 1, 5 and 9)

func (StreamID) Type

func (s StreamID) Type() StreamType

Type says if this is a unidirectional or bidirectional stream

type StreamNum

type StreamNum int64

StreamNum is the stream number

func (StreamNum) StreamID

func (s StreamNum) StreamID(stype StreamType, pers Perspective) StreamID

StreamID calculates the stream ID.

type StreamType

type StreamType uint8

StreamType encodes if this is a unidirectional or bidirectional stream

const (
	// StreamTypeUni is a unidirectional stream
	StreamTypeUni StreamType = iota
	// StreamTypeBidi is a bidirectional stream
	StreamTypeBidi
)

type Version

type Version uint32

Version is a version number as int

const (
	VersionUnknown Version = math.MaxUint32

	Version1 Version = 0x1
	Version2 Version = 0x6b3343cf
)

The version numbers, making grepping easier

func ChooseSupportedVersion

func ChooseSupportedVersion(ours, theirs []Version) (Version, bool)

ChooseSupportedVersion finds the best version in the overlap of ours and theirs ours is a slice of versions that we support, sorted by our preference (descending) theirs is a slice of versions offered by the peer. The order does not matter. The bool returned indicates if a matching version was found.

func GetGreasedVersions

func GetGreasedVersions(supported []Version) []Version

GetGreasedVersions adds one reserved version number to a slice of version numbers, at a random position. It doesn't modify the supported slice.

func (Version) String

func (vn Version) String() string

Jump to

Keyboard shortcuts

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