utils

package
v0.0.0-...-2201134 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2018 License: MIT Imports: 14 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 Debug

func Debug() bool

Debug returns true if the log level is LogLevelDebug

func Debugf

func Debugf(format string, args ...interface{})

Debugf logs something

func Errorf

func Errorf(format string, args ...interface{})

Errorf logs something

func GenerateConnectionID

func GenerateConnectionID() (protocol.ConnectionID, error)

GenerateConnectionID generates a connection ID using cryptographic random

func HostnameFromAddr

func HostnameFromAddr(addr string) (string, error)

HostnameFromAddr determines the hostname in an address string

func Infof

func Infof(format string, args ...interface{})

Infof logs something

func Max

func Max(a, b int) int

Max returns the maximum of two Ints

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 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 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 ReadUfloat16

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

ReadUfloat16 reads a float in the QUIC-float16 format and returns its uint64 representation

func ReadUint16

func ReadUint16(b io.ByteReader) (uint16, error)

ReadUint16 reads a uint16

func ReadUint32

func ReadUint32(b io.ByteReader) (uint32, error)

ReadUint32 reads a uint32

func ReadUint64

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

ReadUint64 reads a uint64

func ReadUintN

func ReadUintN(b io.ByteReader, length uint8) (uint64, error)

ReadUintN reads N bytes

func SetLogLevel

func SetLogLevel(level LogLevel)

SetLogLevel sets the log level

func SetLogWriter

func SetLogWriter(w io.Writer)

SetLogWriter sets the log writer.

func WriteUfloat16

func WriteUfloat16(b *bytes.Buffer, value uint64)

WriteUfloat16 writes a float in the QUIC-float16 format from its uint64 representation

func WriteUint16

func WriteUint16(b *bytes.Buffer, i uint16)

WriteUint16 writes a uint16

func WriteUint24

func WriteUint24(b *bytes.Buffer, i uint32)

WriteUint24 writes 24 bit of a uint32

func WriteUint32

func WriteUint32(b *bytes.Buffer, i uint32)

WriteUint32 writes a uint32

func WriteUint40

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

WriteUint40 writes 40 bit of a uint64

func WriteUint48

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

WriteUint48 writes 48 bit of a uint64

func WriteUint56

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

WriteUint56 writes 56 bit of a uint64

func WriteUint64

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

WriteUint64 writes a uint64

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 +gen linkedlist

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 represents a doubly linked list. The zero value for ByteIntervalList is an empty list ready to use.

func NewByteIntervalList

func NewByteIntervalList() *ByteIntervalList

NewByteIntervalList returns an initialized list.

func (*ByteIntervalList) Back

Back returns the last element of list l or nil.

func (*ByteIntervalList) Front

Front returns the first element of list l or nil.

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.

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.

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 is not an element of l, or e == mark, the list is not modified.

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.

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.

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.

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.

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.

func (*ByteIntervalList) Remove

Remove removes e from l if e is an element of list l. It returns the element value e.Value.

type LogLevel

type LogLevel uint8

LogLevel of quic-go

const (

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

type PacketInterval

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

PacketInterval is an interval from one PacketNumber to the other +gen linkedlist

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 represents a doubly linked list. The zero value for PacketIntervalList is an empty list ready to use.

func NewPacketIntervalList

func NewPacketIntervalList() *PacketIntervalList

NewPacketIntervalList returns an initialized list.

func (*PacketIntervalList) Back

Back returns the last element of list l or nil.

func (*PacketIntervalList) Front

Front returns the first element of list l or nil.

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.

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.

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 is not an element of l, or e == mark, the list is not modified.

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.

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.

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.

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.

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.

func (*PacketIntervalList) Remove

Remove removes e from l if e is an element of list l. It returns the element value e.Value.

type Uint32Slice

type Uint32Slice []uint32

Uint32Slice attaches the methods of sort.Interface to []uint32, sorting in increasing order.

func (Uint32Slice) Len

func (s Uint32Slice) Len() int

func (Uint32Slice) Less

func (s Uint32Slice) Less(i, j int) bool

func (Uint32Slice) Swap

func (s Uint32Slice) Swap(i, j int)

Jump to

Keyboard shortcuts

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