utils

package
v0.15.8 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const InfDuration = time.Duration(math.MaxInt64)

InfDuration is a duration of infinite length

Variables

This section is empty.

Functions

func AbsDuration

func AbsDuration(d time.Duration) time.Duration

AbsDuration returns the absolute value of a time duration

func Max

func Max(a, b int) int

Max returns the maximum of two Ints

func MaxByteCount added in v0.8.0

func MaxByteCount(a, b protocol.ByteCount) protocol.ByteCount

MaxByteCount returns the maximum of two ByteCounts

func MaxDuration

func MaxDuration(a, b time.Duration) time.Duration

MaxDuration returns the max duration

func MaxInt64

func MaxInt64(a, b int64) int64

MaxInt64 returns the minimum of two int64

func MaxPacketNumber

func MaxPacketNumber(a, b protocol.PacketNumber) protocol.PacketNumber

MaxPacketNumber returns the max packet number

func MaxTime added in v0.7.0

func MaxTime(a, b time.Time) time.Time

MaxTime returns the later time

func MaxUint32

func MaxUint32(a, b uint32) uint32

MaxUint32 returns the maximum of two uint32

func MaxUint64

func MaxUint64(a, b uint64) uint64

MaxUint64 returns the maximum of two uint64

func Min

func Min(a, b int) int

Min returns the minimum of two Ints

func MinByteCount

func MinByteCount(a, b protocol.ByteCount) protocol.ByteCount

MinByteCount returns the minimum of two ByteCounts

func MinDuration

func MinDuration(a, b time.Duration) time.Duration

MinDuration returns the minimum duration

func MinInt64

func MinInt64(a, b int64) int64

MinInt64 returns the minimum of two int64

func MinNonZeroDuration added in v0.15.0

func MinNonZeroDuration(a, b time.Duration) time.Duration

MinNonZeroDuration return the minimum duration that's not zero.

func MinNonZeroTime added in v0.11.0

func MinNonZeroTime(a, b time.Time) time.Time

MinNonZeroTime returns the earlist time that is not time.Time{} If both a and b are time.Time{}, it returns time.Time{}

func MinPacketNumber

func MinPacketNumber(a, b protocol.PacketNumber) protocol.PacketNumber

MinPacketNumber returns the min packet number

func MinTime

func MinTime(a, b time.Time) time.Time

MinTime returns the earlier time

func MinUint32

func MinUint32(a, b uint32) uint32

MinUint32 returns the maximum of two uint32

func MinUint64

func MinUint64(a, b uint64) uint64

MinUint64 returns the maximum of two uint64

func NewBufferedWriteCloser added in v0.15.3

func NewBufferedWriteCloser(writer *bufio.Writer, closer io.Closer) io.WriteCloser

NewBufferedWriteCloser creates an io.WriteCloser from a bufio.Writer and an io.Closer

func ReadVarInt

func ReadVarInt(b io.ByteReader) (uint64, error)

ReadVarInt reads a number in the QUIC varint format

func VarIntLen

func VarIntLen(i uint64) protocol.ByteCount

VarIntLen determines the number of bytes that will be needed to write a number

func WriteVarInt

func WriteVarInt(b *bytes.Buffer, i uint64)

WriteVarInt writes a number in the QUIC varint format

Types

type AtomicBool

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

An AtomicBool is an atomic bool

func (*AtomicBool) Get

func (a *AtomicBool) Get() bool

Get gets the value

func (*AtomicBool) Set

func (a *AtomicBool) Set(value bool)

Set sets the value

type ByteInterval

type ByteInterval struct {
	Start protocol.ByteCount
	End   protocol.ByteCount
}

ByteInterval is an interval from one ByteCount to the other

type ByteIntervalElement

type ByteIntervalElement struct {

	// The value stored with this element.
	Value ByteInterval
	// contains filtered or unexported fields
}

ByteIntervalElement is an element of a linked list.

func (*ByteIntervalElement) Next

Next returns the next list element or nil.

func (*ByteIntervalElement) Prev

Prev returns the previous list element or nil.

type ByteIntervalList

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

ByteIntervalList is a linked list of ByteIntervals.

func NewByteIntervalList

func NewByteIntervalList() *ByteIntervalList

NewByteIntervalList returns an initialized list.

func (*ByteIntervalList) Back

Back returns the last element of list l or nil if the list is empty.

func (*ByteIntervalList) Front

Front returns the first element of list l or nil if the list is empty.

func (*ByteIntervalList) Init

Init initializes or clears list l.

func (*ByteIntervalList) InsertAfter

InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.

func (*ByteIntervalList) InsertBefore

InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.

func (*ByteIntervalList) Len

func (l *ByteIntervalList) Len() int

Len returns the number of elements of list l. The complexity is O(1).

func (*ByteIntervalList) MoveAfter

func (l *ByteIntervalList) MoveAfter(e, mark *ByteIntervalElement)

MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.

func (*ByteIntervalList) MoveBefore

func (l *ByteIntervalList) MoveBefore(e, mark *ByteIntervalElement)

MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.

func (*ByteIntervalList) MoveToBack

func (l *ByteIntervalList) MoveToBack(e *ByteIntervalElement)

MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified. The element must not be nil.

func (*ByteIntervalList) MoveToFront

func (l *ByteIntervalList) MoveToFront(e *ByteIntervalElement)

MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.

func (*ByteIntervalList) PushBack

PushBack inserts a new element e with value v at the back of list l and returns e.

func (*ByteIntervalList) PushBackList

func (l *ByteIntervalList) PushBackList(other *ByteIntervalList)

PushBackList inserts a copy of an other list at the back of list l. The lists l and other may be the same. They must not be nil.

func (*ByteIntervalList) PushFront

PushFront inserts a new element e with value v at the front of list l and returns e.

func (*ByteIntervalList) PushFrontList

func (l *ByteIntervalList) PushFrontList(other *ByteIntervalList)

PushFrontList inserts a copy of an other list at the front of list l. The lists l and other may be the same. They must not be nil.

func (*ByteIntervalList) Remove

Remove removes e from l if e is an element of list l. It returns the element value e.Value. The element must not be nil.

type ByteOrder

type ByteOrder interface {
	ReadUint32(io.ByteReader) (uint32, error)
	ReadUint24(io.ByteReader) (uint32, error)
	ReadUint16(io.ByteReader) (uint16, error)

	WriteUint32(*bytes.Buffer, uint32)
	WriteUint24(*bytes.Buffer, uint32)
	WriteUint16(*bytes.Buffer, uint16)
}

A ByteOrder specifies how to convert byte sequences into 16-, 32-, or 64-bit unsigned integers.

var BigEndian ByteOrder = bigEndian{}

BigEndian is the big-endian implementation of ByteOrder.

type LogLevel

type LogLevel uint8

LogLevel of quic-go

const (
	// LogLevelNothing disables
	LogLevelNothing LogLevel = iota
	// LogLevelError enables err logs
	LogLevelError
	// LogLevelInfo enables info logs (e.g. packets)
	LogLevelInfo
	// LogLevelDebug enables debug logs (e.g. packet contents)
	LogLevelDebug
)

type Logger added in v0.8.0

type Logger interface {
	SetLogLevel(LogLevel)
	SetLogTimeFormat(format string)
	WithPrefix(prefix string) Logger
	Debug() bool

	Errorf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Debugf(format string, args ...interface{})
}

A Logger logs.

var DefaultLogger Logger

DefaultLogger is used by quic-go for logging.

type NewConnectionID added in v0.13.0

type NewConnectionID struct {
	SequenceNumber      uint64
	ConnectionID        protocol.ConnectionID
	StatelessResetToken *[16]byte
}

NewConnectionID is a new connection ID

type NewConnectionIDElement added in v0.13.0

type NewConnectionIDElement struct {

	// The value stored with this element.
	Value NewConnectionID
	// contains filtered or unexported fields
}

NewConnectionIDElement is an element of a linked list.

func (*NewConnectionIDElement) Next added in v0.13.0

Next returns the next list element or nil.

func (*NewConnectionIDElement) Prev added in v0.13.0

Prev returns the previous list element or nil.

type NewConnectionIDList added in v0.13.0

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

NewConnectionIDList is a linked list of NewConnectionIDs.

func NewNewConnectionIDList added in v0.13.0

func NewNewConnectionIDList() *NewConnectionIDList

NewNewConnectionIDList returns an initialized list.

func (*NewConnectionIDList) Back added in v0.13.0

Back returns the last element of list l or nil if the list is empty.

func (*NewConnectionIDList) Front added in v0.13.0

Front returns the first element of list l or nil if the list is empty.

func (*NewConnectionIDList) Init added in v0.13.0

Init initializes or clears list l.

func (*NewConnectionIDList) InsertAfter added in v0.13.0

InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.

func (*NewConnectionIDList) InsertBefore added in v0.13.0

InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.

func (*NewConnectionIDList) Len added in v0.13.0

func (l *NewConnectionIDList) Len() int

Len returns the number of elements of list l. The complexity is O(1).

func (*NewConnectionIDList) MoveAfter added in v0.13.0

func (l *NewConnectionIDList) MoveAfter(e, mark *NewConnectionIDElement)

MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.

func (*NewConnectionIDList) MoveBefore added in v0.13.0

func (l *NewConnectionIDList) MoveBefore(e, mark *NewConnectionIDElement)

MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.

func (*NewConnectionIDList) MoveToBack added in v0.13.0

func (l *NewConnectionIDList) MoveToBack(e *NewConnectionIDElement)

MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified. The element must not be nil.

func (*NewConnectionIDList) MoveToFront added in v0.13.0

func (l *NewConnectionIDList) MoveToFront(e *NewConnectionIDElement)

MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.

func (*NewConnectionIDList) PushBack added in v0.13.0

PushBack inserts a new element e with value v at the back of list l and returns e.

func (*NewConnectionIDList) PushBackList added in v0.13.0

func (l *NewConnectionIDList) PushBackList(other *NewConnectionIDList)

PushBackList inserts a copy of an other list at the back of list l. The lists l and other may be the same. They must not be nil.

func (*NewConnectionIDList) PushFront added in v0.13.0

PushFront inserts a new element e with value v at the front of list l and returns e.

func (*NewConnectionIDList) PushFrontList added in v0.13.0

func (l *NewConnectionIDList) PushFrontList(other *NewConnectionIDList)

PushFrontList inserts a copy of an other list at the front of list l. The lists l and other may be the same. They must not be nil.

func (*NewConnectionIDList) Remove added in v0.13.0

Remove removes e from l if e is an element of list l. It returns the element value e.Value. The element must not be nil.

type PacketInterval

type PacketInterval struct {
	Start protocol.PacketNumber
	End   protocol.PacketNumber
}

PacketInterval is an interval from one PacketNumber to the other

type PacketIntervalElement

type PacketIntervalElement struct {

	// The value stored with this element.
	Value PacketInterval
	// contains filtered or unexported fields
}

PacketIntervalElement is an element of a linked list.

func (*PacketIntervalElement) Next

Next returns the next list element or nil.

func (*PacketIntervalElement) Prev

Prev returns the previous list element or nil.

type PacketIntervalList

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

PacketIntervalList is a linked list of PacketIntervals.

func NewPacketIntervalList

func NewPacketIntervalList() *PacketIntervalList

NewPacketIntervalList returns an initialized list.

func (*PacketIntervalList) Back

Back returns the last element of list l or nil if the list is empty.

func (*PacketIntervalList) Front

Front returns the first element of list l or nil if the list is empty.

func (*PacketIntervalList) Init

Init initializes or clears list l.

func (*PacketIntervalList) InsertAfter

InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.

func (*PacketIntervalList) InsertBefore

InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.

func (*PacketIntervalList) Len

func (l *PacketIntervalList) Len() int

Len returns the number of elements of list l. The complexity is O(1).

func (*PacketIntervalList) MoveAfter

func (l *PacketIntervalList) MoveAfter(e, mark *PacketIntervalElement)

MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.

func (*PacketIntervalList) MoveBefore

func (l *PacketIntervalList) MoveBefore(e, mark *PacketIntervalElement)

MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.

func (*PacketIntervalList) MoveToBack

func (l *PacketIntervalList) MoveToBack(e *PacketIntervalElement)

MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified. The element must not be nil.

func (*PacketIntervalList) MoveToFront

func (l *PacketIntervalList) MoveToFront(e *PacketIntervalElement)

MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.

func (*PacketIntervalList) PushBack

PushBack inserts a new element e with value v at the back of list l and returns e.

func (*PacketIntervalList) PushBackList

func (l *PacketIntervalList) PushBackList(other *PacketIntervalList)

PushBackList inserts a copy of an other list at the back of list l. The lists l and other may be the same. They must not be nil.

func (*PacketIntervalList) PushFront

PushFront inserts a new element e with value v at the front of list l and returns e.

func (*PacketIntervalList) PushFrontList

func (l *PacketIntervalList) PushFrontList(other *PacketIntervalList)

PushFrontList inserts a copy of an other list at the front of list l. The lists l and other may be the same. They must not be nil.

func (*PacketIntervalList) Remove

Remove removes e from l if e is an element of list l. It returns the element value e.Value. The element must not be nil.

type Timer

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

A Timer wrapper that behaves correctly when resetting

func NewTimer

func NewTimer() *Timer

NewTimer creates a new timer that is not set

func (*Timer) Chan

func (t *Timer) Chan() <-chan time.Time

Chan returns the channel of the wrapped timer

func (*Timer) Reset

func (t *Timer) Reset(deadline time.Time)

Reset the timer, no matter whether the value was read or not

func (*Timer) SetRead

func (t *Timer) SetRead()

SetRead should be called after the value from the chan was read

func (*Timer) Stop added in v0.15.6

func (t *Timer) Stop()

Stop stops the timer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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