kcp

package
v1.8.10 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package kcp - A Fast and Reliable ARQ Protocol

Acknowledgement:

skywind3000@github for inventing the KCP protocol
xtaci@github for translating to Golang

Index

Constants

View Source
const (
	DataSegmentOverhead = 18
)

Variables

View Source
var (
	ErrIOTimeout        = newError("Read/Write timeout")
	ErrClosedListener   = newError("Listener closed.")
	ErrClosedConnection = newError("Connection closed.")
)
View Source
var File_transport_internet_kcp_config_proto protoreflect.FileDescriptor

Functions

func DialKCP

func DialKCP(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error)

DialKCP dials a new KCP connections to the specific destination.

func ListenKCP

func ListenKCP(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (internet.Listener, error)

func NewAEADAESGCMBasedOnSeed

func NewAEADAESGCMBasedOnSeed(seed string) cipher.AEAD

func NewSimpleAuthenticator

func NewSimpleAuthenticator() cipher.AEAD

NewSimpleAuthenticator creates a new SimpleAuthenticator

Types

type AckList

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

func NewAckList

func NewAckList(writer SegmentWriter) *AckList

func (*AckList) Add

func (l *AckList) Add(number uint32, timestamp uint32)

func (*AckList) Clear

func (l *AckList) Clear(una uint32)

func (*AckList) Flush

func (l *AckList) Flush(current uint32, rto uint32)

type AckSegment

type AckSegment struct {
	Conv            uint16
	Option          SegmentOption
	ReceivingWindow uint32
	ReceivingNext   uint32
	Timestamp       uint32
	NumberList      []uint32
}

func NewAckSegment

func NewAckSegment() *AckSegment

func (*AckSegment) ByteSize

func (s *AckSegment) ByteSize() int32

func (*AckSegment) Command

func (*AckSegment) Command() Command

func (*AckSegment) Conversation

func (s *AckSegment) Conversation() uint16

func (*AckSegment) IsEmpty

func (s *AckSegment) IsEmpty() bool

func (*AckSegment) IsFull

func (s *AckSegment) IsFull() bool

func (*AckSegment) PutNumber

func (s *AckSegment) PutNumber(number uint32)

func (*AckSegment) PutTimestamp

func (s *AckSegment) PutTimestamp(timestamp uint32)

func (*AckSegment) Release

func (s *AckSegment) Release()

func (*AckSegment) Serialize

func (s *AckSegment) Serialize(b []byte)

type CmdOnlySegment

type CmdOnlySegment struct {
	Conv          uint16
	Cmd           Command
	Option        SegmentOption
	SendingNext   uint32
	ReceivingNext uint32
	PeerRTO       uint32
}

func NewCmdOnlySegment

func NewCmdOnlySegment() *CmdOnlySegment

func (*CmdOnlySegment) ByteSize

func (*CmdOnlySegment) ByteSize() int32

func (*CmdOnlySegment) Command

func (s *CmdOnlySegment) Command() Command

func (*CmdOnlySegment) Conversation

func (s *CmdOnlySegment) Conversation() uint16

func (*CmdOnlySegment) Release

func (*CmdOnlySegment) Release()

func (*CmdOnlySegment) Serialize

func (s *CmdOnlySegment) Serialize(b []byte)

type Command

type Command byte

Command is a KCP command that indicate the purpose of a Segment.

const (
	// CommandACK indicates an AckSegment.
	CommandACK Command = 0
	// CommandData indicates a DataSegment.
	CommandData Command = 1
	// CommandTerminate indicates that peer terminates the connection.
	CommandTerminate Command = 2
	// CommandPing indicates a ping.
	CommandPing Command = 3
)

type Config

type Config struct {
	Mtu              *MTU                 `protobuf:"bytes,1,opt,name=mtu,proto3" json:"mtu,omitempty"`
	Tti              *TTI                 `protobuf:"bytes,2,opt,name=tti,proto3" json:"tti,omitempty"`
	UplinkCapacity   *UplinkCapacity      `protobuf:"bytes,3,opt,name=uplink_capacity,json=uplinkCapacity,proto3" json:"uplink_capacity,omitempty"`
	DownlinkCapacity *DownlinkCapacity    `protobuf:"bytes,4,opt,name=downlink_capacity,json=downlinkCapacity,proto3" json:"downlink_capacity,omitempty"`
	Congestion       bool                 `protobuf:"varint,5,opt,name=congestion,proto3" json:"congestion,omitempty"`
	WriteBuffer      *WriteBuffer         `protobuf:"bytes,6,opt,name=write_buffer,json=writeBuffer,proto3" json:"write_buffer,omitempty"`
	ReadBuffer       *ReadBuffer          `protobuf:"bytes,7,opt,name=read_buffer,json=readBuffer,proto3" json:"read_buffer,omitempty"`
	HeaderConfig     *serial.TypedMessage `protobuf:"bytes,8,opt,name=header_config,json=headerConfig,proto3" json:"header_config,omitempty"`
	Seed             *EncryptionSeed      `protobuf:"bytes,10,opt,name=seed,proto3" json:"seed,omitempty"`
	// contains filtered or unexported fields
}

func (*Config) Descriptor deprecated

func (*Config) Descriptor() ([]byte, []int)

Deprecated: Use Config.ProtoReflect.Descriptor instead.

func (*Config) GetCongestion

func (x *Config) GetCongestion() bool

func (*Config) GetDownlinkCapacity

func (x *Config) GetDownlinkCapacity() *DownlinkCapacity

func (*Config) GetDownlinkCapacityValue

func (c *Config) GetDownlinkCapacityValue() uint32

GetDownlinkCapacityValue returns the value of DownlinkCapacity settings.

func (*Config) GetHeaderConfig

func (x *Config) GetHeaderConfig() *serial.TypedMessage

func (*Config) GetMTUValue

func (c *Config) GetMTUValue() uint32

GetMTUValue returns the value of MTU settings.

func (*Config) GetMtu

func (x *Config) GetMtu() *MTU

func (*Config) GetPackerHeader

func (c *Config) GetPackerHeader() (internet.PacketHeader, error)

func (*Config) GetReadBuffer

func (x *Config) GetReadBuffer() *ReadBuffer

func (*Config) GetReadBufferSize

func (c *Config) GetReadBufferSize() uint32

GetReadBufferSize returns the size of ReadBuffer in bytes.

func (*Config) GetReceivingBufferSize

func (c *Config) GetReceivingBufferSize() uint32

func (*Config) GetReceivingInFlightSize

func (c *Config) GetReceivingInFlightSize() uint32

func (*Config) GetSecurity

func (c *Config) GetSecurity() (cipher.AEAD, error)

GetSecurity returns the security settings.

func (*Config) GetSeed

func (x *Config) GetSeed() *EncryptionSeed

func (*Config) GetSendingBufferSize

func (c *Config) GetSendingBufferSize() uint32

func (*Config) GetSendingInFlightSize

func (c *Config) GetSendingInFlightSize() uint32

func (*Config) GetTTIValue

func (c *Config) GetTTIValue() uint32

GetTTIValue returns the value of TTI settings.

func (*Config) GetTti

func (x *Config) GetTti() *TTI

func (*Config) GetUplinkCapacity

func (x *Config) GetUplinkCapacity() *UplinkCapacity

func (*Config) GetUplinkCapacityValue

func (c *Config) GetUplinkCapacityValue() uint32

GetUplinkCapacityValue returns the value of UplinkCapacity settings.

func (*Config) GetWriteBuffer

func (x *Config) GetWriteBuffer() *WriteBuffer

func (*Config) GetWriteBufferSize

func (c *Config) GetWriteBufferSize() uint32

GetWriteBufferSize returns the size of WriterBuffer in bytes.

func (*Config) ProtoMessage

func (*Config) ProtoMessage()

func (*Config) ProtoReflect

func (x *Config) ProtoReflect() protoreflect.Message

func (*Config) Reset

func (x *Config) Reset()

func (*Config) String

func (x *Config) String() string

type ConnMetadata

type ConnMetadata struct {
	LocalAddr    net.Addr
	RemoteAddr   net.Addr
	Conversation uint16
}

type Connection

type Connection struct {
	Config *Config
	// contains filtered or unexported fields
}

Connection is a KCP connection over UDP.

func NewConnection

func NewConnection(meta ConnMetadata, writer PacketWriter, closer io.Closer, config *Config) *Connection

NewConnection create a new KCP connection between local and remote.

func (*Connection) Close

func (c *Connection) Close() error

Close closes the connection.

func (*Connection) Elapsed

func (c *Connection) Elapsed() uint32

func (*Connection) HandleOption

func (c *Connection) HandleOption(opt SegmentOption)

func (*Connection) Input

func (c *Connection) Input(segments []Segment)

Input when you received a low level packet (eg. UDP packet), call it

func (*Connection) LocalAddr

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

LocalAddr returns the local network address. The Addr returned is shared by all invocations of LocalAddr, so do not modify it.

func (*Connection) OnPeerClosed

func (c *Connection) OnPeerClosed()

func (*Connection) Ping

func (c *Connection) Ping(current uint32, cmd Command)

func (*Connection) Read

func (c *Connection) Read(b []byte) (int, error)

Read implements the Conn Read method.

func (*Connection) ReadMultiBuffer

func (c *Connection) ReadMultiBuffer() (buf.MultiBuffer, error)

ReadMultiBuffer implements buf.Reader.

func (*Connection) RemoteAddr

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

RemoteAddr returns the remote network address. The Addr returned is shared by all invocations of RemoteAddr, so do not modify it.

func (*Connection) SetDeadline

func (c *Connection) SetDeadline(t time.Time) error

SetDeadline sets the deadline associated with the listener. A zero time value disables the deadline.

func (*Connection) SetReadDeadline

func (c *Connection) SetReadDeadline(t time.Time) error

SetReadDeadline implements the Conn SetReadDeadline method.

func (*Connection) SetState

func (c *Connection) SetState(state State)

func (*Connection) SetWriteDeadline

func (c *Connection) SetWriteDeadline(t time.Time) error

SetWriteDeadline implements the Conn SetWriteDeadline method.

func (*Connection) State

func (c *Connection) State() State

func (*Connection) Terminate

func (c *Connection) Terminate()

func (*Connection) Write

func (c *Connection) Write(b []byte) (int, error)

Write implements io.Writer.

func (*Connection) WriteMultiBuffer

func (c *Connection) WriteMultiBuffer(mb buf.MultiBuffer) error

WriteMultiBuffer implements buf.Writer.

type ConnectionID

type ConnectionID struct {
	Remote net.Address
	Port   net.Port
	Conv   uint16
}

type ConnectionReuse

type ConnectionReuse struct {
	Enable bool `protobuf:"varint,1,opt,name=enable,proto3" json:"enable,omitempty"`
	// contains filtered or unexported fields
}

func (*ConnectionReuse) Descriptor deprecated

func (*ConnectionReuse) Descriptor() ([]byte, []int)

Deprecated: Use ConnectionReuse.ProtoReflect.Descriptor instead.

func (*ConnectionReuse) GetEnable

func (x *ConnectionReuse) GetEnable() bool

func (*ConnectionReuse) ProtoMessage

func (*ConnectionReuse) ProtoMessage()

func (*ConnectionReuse) ProtoReflect

func (x *ConnectionReuse) ProtoReflect() protoreflect.Message

func (*ConnectionReuse) Reset

func (x *ConnectionReuse) Reset()

func (*ConnectionReuse) String

func (x *ConnectionReuse) String() string

type DataSegment

type DataSegment struct {
	Conv        uint16
	Option      SegmentOption
	Timestamp   uint32
	Number      uint32
	SendingNext uint32
	// contains filtered or unexported fields
}

func NewDataSegment

func NewDataSegment() *DataSegment

func (*DataSegment) ByteSize

func (s *DataSegment) ByteSize() int32

func (*DataSegment) Command

func (*DataSegment) Command() Command

func (*DataSegment) Conversation

func (s *DataSegment) Conversation() uint16

func (*DataSegment) Data

func (s *DataSegment) Data() *buf.Buffer

func (*DataSegment) Detach

func (s *DataSegment) Detach() *buf.Buffer

func (*DataSegment) Release

func (s *DataSegment) Release()

func (*DataSegment) Serialize

func (s *DataSegment) Serialize(b []byte)

type DownlinkCapacity

type DownlinkCapacity struct {
	Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

Downlink capacity, in MB.

func (*DownlinkCapacity) Descriptor deprecated

func (*DownlinkCapacity) Descriptor() ([]byte, []int)

Deprecated: Use DownlinkCapacity.ProtoReflect.Descriptor instead.

func (*DownlinkCapacity) GetValue

func (x *DownlinkCapacity) GetValue() uint32

func (*DownlinkCapacity) ProtoMessage

func (*DownlinkCapacity) ProtoMessage()

func (*DownlinkCapacity) ProtoReflect

func (x *DownlinkCapacity) ProtoReflect() protoreflect.Message

func (*DownlinkCapacity) Reset

func (x *DownlinkCapacity) Reset()

func (*DownlinkCapacity) String

func (x *DownlinkCapacity) String() string

type EncryptionSeed

type EncryptionSeed struct {
	Seed string `protobuf:"bytes,1,opt,name=seed,proto3" json:"seed,omitempty"`
	// contains filtered or unexported fields
}

Maximum Transmission Unit, in bytes.

func (*EncryptionSeed) Descriptor deprecated

func (*EncryptionSeed) Descriptor() ([]byte, []int)

Deprecated: Use EncryptionSeed.ProtoReflect.Descriptor instead.

func (*EncryptionSeed) GetSeed

func (x *EncryptionSeed) GetSeed() string

func (*EncryptionSeed) ProtoMessage

func (*EncryptionSeed) ProtoMessage()

func (*EncryptionSeed) ProtoReflect

func (x *EncryptionSeed) ProtoReflect() protoreflect.Message

func (*EncryptionSeed) Reset

func (x *EncryptionSeed) Reset()

func (*EncryptionSeed) String

func (x *EncryptionSeed) String() string

type KCPPacketReader

type KCPPacketReader struct {
	Security cipher.AEAD
	Header   internet.PacketHeader
}

func (*KCPPacketReader) Read

func (r *KCPPacketReader) Read(b []byte) []Segment

type KCPPacketWriter

type KCPPacketWriter struct {
	Header   internet.PacketHeader
	Security cipher.AEAD
	Writer   io.Writer
}

func (*KCPPacketWriter) Overhead

func (w *KCPPacketWriter) Overhead() int

func (*KCPPacketWriter) Write

func (w *KCPPacketWriter) Write(b []byte) (int, error)

type Listener

type Listener struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Listener defines a server listening for connections

func NewListener

func NewListener(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (*Listener, error)

func (*Listener) ActiveConnections

func (l *Listener) ActiveConnections() int

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

Addr returns the listener's network address, The Addr returned is shared by all invocations of Addr, so do not modify it.

func (*Listener) Close

func (l *Listener) Close() error

Close stops listening on the UDP address. Already Accepted connections are not closed.

func (*Listener) OnReceive

func (l *Listener) OnReceive(payload *buf.Buffer, src net.Destination)

func (*Listener) Remove

func (l *Listener) Remove(id ConnectionID)

type MTU

type MTU struct {
	Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

Maximum Transmission Unit, in bytes.

func (*MTU) Descriptor deprecated

func (*MTU) Descriptor() ([]byte, []int)

Deprecated: Use MTU.ProtoReflect.Descriptor instead.

func (*MTU) GetValue

func (x *MTU) GetValue() uint32

func (*MTU) ProtoMessage

func (*MTU) ProtoMessage()

func (*MTU) ProtoReflect

func (x *MTU) ProtoReflect() protoreflect.Message

func (*MTU) Reset

func (x *MTU) Reset()

func (*MTU) String

func (x *MTU) String() string

type PacketReader

type PacketReader interface {
	Read([]byte) []Segment
}

type PacketWriter

type PacketWriter interface {
	Overhead() int
	io.Writer
}

type ReadBuffer

type ReadBuffer struct {

	// Buffer size in bytes.
	Size uint32 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"`
	// contains filtered or unexported fields
}

func (*ReadBuffer) Descriptor deprecated

func (*ReadBuffer) Descriptor() ([]byte, []int)

Deprecated: Use ReadBuffer.ProtoReflect.Descriptor instead.

func (*ReadBuffer) GetSize

func (x *ReadBuffer) GetSize() uint32

func (*ReadBuffer) ProtoMessage

func (*ReadBuffer) ProtoMessage()

func (*ReadBuffer) ProtoReflect

func (x *ReadBuffer) ProtoReflect() protoreflect.Message

func (*ReadBuffer) Reset

func (x *ReadBuffer) Reset()

func (*ReadBuffer) String

func (x *ReadBuffer) String() string

type ReceivingWindow

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

func NewReceivingWindow

func NewReceivingWindow() *ReceivingWindow

func (*ReceivingWindow) Has

func (w *ReceivingWindow) Has(id uint32) bool

func (*ReceivingWindow) Remove

func (w *ReceivingWindow) Remove(id uint32) *DataSegment

func (*ReceivingWindow) Set

func (w *ReceivingWindow) Set(id uint32, value *DataSegment) bool

type ReceivingWorker

type ReceivingWorker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewReceivingWorker

func NewReceivingWorker(kcp *Connection) *ReceivingWorker

func (*ReceivingWorker) CloseRead

func (*ReceivingWorker) CloseRead()

func (*ReceivingWorker) Flush

func (w *ReceivingWorker) Flush(current uint32)

func (*ReceivingWorker) IsDataAvailable

func (w *ReceivingWorker) IsDataAvailable() bool

func (*ReceivingWorker) NextNumber

func (w *ReceivingWorker) NextNumber() uint32

func (*ReceivingWorker) ProcessSegment

func (w *ReceivingWorker) ProcessSegment(seg *DataSegment)

func (*ReceivingWorker) ProcessSendingNext

func (w *ReceivingWorker) ProcessSendingNext(number uint32)

func (*ReceivingWorker) Read

func (w *ReceivingWorker) Read(b []byte) int

func (*ReceivingWorker) ReadMultiBuffer

func (w *ReceivingWorker) ReadMultiBuffer() buf.MultiBuffer

func (*ReceivingWorker) Release

func (w *ReceivingWorker) Release()

func (*ReceivingWorker) UpdateNecessary

func (w *ReceivingWorker) UpdateNecessary() bool

func (*ReceivingWorker) Write

func (w *ReceivingWorker) Write(seg Segment) error

type RetryableWriter

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

func (*RetryableWriter) Write

func (w *RetryableWriter) Write(seg Segment) error

type RoundTripInfo

type RoundTripInfo struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*RoundTripInfo) SmoothedTime

func (info *RoundTripInfo) SmoothedTime() uint32

func (*RoundTripInfo) Timeout

func (info *RoundTripInfo) Timeout() uint32

func (*RoundTripInfo) Update

func (info *RoundTripInfo) Update(rtt uint32, current uint32)

func (*RoundTripInfo) UpdatePeerRTO

func (info *RoundTripInfo) UpdatePeerRTO(rto uint32, current uint32)

type Segment

type Segment interface {
	Release()
	Conversation() uint16
	Command() Command
	ByteSize() int32
	Serialize([]byte)
	// contains filtered or unexported methods
}

func ReadSegment

func ReadSegment(buf []byte) (Segment, []byte)

type SegmentOption

type SegmentOption byte
const (
	SegmentOptionClose SegmentOption = 1
)

type SegmentWriter

type SegmentWriter interface {
	Write(seg Segment) error
}

func NewRetryableWriter

func NewRetryableWriter(writer SegmentWriter) SegmentWriter

func NewSegmentWriter

func NewSegmentWriter(writer io.Writer) SegmentWriter

type SendingWindow

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

func NewSendingWindow

func NewSendingWindow(writer SegmentWriter, onPacketLoss func(uint32)) *SendingWindow

func (*SendingWindow) Clear

func (sw *SendingWindow) Clear(una uint32)

func (*SendingWindow) FirstNumber

func (sw *SendingWindow) FirstNumber() uint32

func (*SendingWindow) Flush

func (sw *SendingWindow) Flush(current uint32, rto uint32, maxInFlightSize uint32)

func (*SendingWindow) HandleFastAck

func (sw *SendingWindow) HandleFastAck(number uint32, rto uint32)

func (*SendingWindow) IsEmpty

func (sw *SendingWindow) IsEmpty() bool

func (*SendingWindow) Len

func (sw *SendingWindow) Len() uint32

func (*SendingWindow) Push

func (sw *SendingWindow) Push(number uint32, b *buf.Buffer)

func (*SendingWindow) Release

func (sw *SendingWindow) Release()

func (*SendingWindow) Remove

func (sw *SendingWindow) Remove(number uint32) bool

func (*SendingWindow) Visit

func (sw *SendingWindow) Visit(visitor func(seg *DataSegment) bool)

type SendingWorker

type SendingWorker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSendingWorker

func NewSendingWorker(kcp *Connection) *SendingWorker

func (*SendingWorker) CloseWrite

func (w *SendingWorker) CloseWrite()

func (*SendingWorker) FindFirstUnacknowledged

func (w *SendingWorker) FindFirstUnacknowledged()

func (*SendingWorker) FirstUnacknowledged

func (w *SendingWorker) FirstUnacknowledged() uint32

func (*SendingWorker) Flush

func (w *SendingWorker) Flush(current uint32)

func (*SendingWorker) IsEmpty

func (w *SendingWorker) IsEmpty() bool

func (*SendingWorker) OnPacketLoss

func (w *SendingWorker) OnPacketLoss(lossRate uint32)

func (*SendingWorker) ProcessReceivingNext

func (w *SendingWorker) ProcessReceivingNext(nextNumber uint32)

func (*SendingWorker) ProcessReceivingNextWithoutLock

func (w *SendingWorker) ProcessReceivingNextWithoutLock(nextNumber uint32)

func (*SendingWorker) ProcessSegment

func (w *SendingWorker) ProcessSegment(current uint32, seg *AckSegment, rto uint32)

func (*SendingWorker) Push

func (w *SendingWorker) Push(b *buf.Buffer) bool

func (*SendingWorker) Release

func (w *SendingWorker) Release()

func (*SendingWorker) UpdateNecessary

func (w *SendingWorker) UpdateNecessary() bool

func (*SendingWorker) Write

func (w *SendingWorker) Write(seg Segment) error

type SimpleAuthenticator

type SimpleAuthenticator struct{}

SimpleAuthenticator is a legacy AEAD used for KCP encryption.

func (*SimpleAuthenticator) NonceSize

func (*SimpleAuthenticator) NonceSize() int

NonceSize implements cipher.AEAD.NonceSize().

func (*SimpleAuthenticator) Open

func (a *SimpleAuthenticator) Open(dst, nonce, cipherText, extra []byte) ([]byte, error)

Open implements cipher.AEAD.Open().

func (*SimpleAuthenticator) Overhead

func (*SimpleAuthenticator) Overhead() int

Overhead implements cipher.AEAD.NonceSize().

func (*SimpleAuthenticator) Seal

func (a *SimpleAuthenticator) Seal(dst, nonce, plain, extra []byte) []byte

Seal implements cipher.AEAD.Seal().

type SimpleSegmentWriter

type SimpleSegmentWriter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*SimpleSegmentWriter) Write

func (w *SimpleSegmentWriter) Write(seg Segment) error

type State

type State int32

State of the connection

const (
	StateActive          State = 0 // Connection is active
	StateReadyToClose    State = 1 // Connection is closed locally
	StatePeerClosed      State = 2 // Connection is closed on remote
	StateTerminating     State = 3 // Connection is ready to be destroyed locally
	StatePeerTerminating State = 4 // Connection is ready to be destroyed on remote
	StateTerminated      State = 5 // Connection is destroyed.
)

func (State) Is

func (s State) Is(states ...State) bool

Is returns true if current State is one of the candidates.

type TTI

type TTI struct {
	Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

Transmission Time Interview, in milli-sec.

func (*TTI) Descriptor deprecated

func (*TTI) Descriptor() ([]byte, []int)

Deprecated: Use TTI.ProtoReflect.Descriptor instead.

func (*TTI) GetValue

func (x *TTI) GetValue() uint32

func (*TTI) ProtoMessage

func (*TTI) ProtoMessage()

func (*TTI) ProtoReflect

func (x *TTI) ProtoReflect() protoreflect.Message

func (*TTI) Reset

func (x *TTI) Reset()

func (*TTI) String

func (x *TTI) String() string

type Updater

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

func NewUpdater

func NewUpdater(interval uint32, shouldContinue func() bool, shouldTerminate func() bool, updateFunc func()) *Updater

func (*Updater) Interval

func (u *Updater) Interval() time.Duration

func (*Updater) SetInterval

func (u *Updater) SetInterval(d time.Duration)

func (*Updater) WakeUp

func (u *Updater) WakeUp()

type UplinkCapacity

type UplinkCapacity struct {
	Value uint32 `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

Uplink capacity, in MB.

func (*UplinkCapacity) Descriptor deprecated

func (*UplinkCapacity) Descriptor() ([]byte, []int)

Deprecated: Use UplinkCapacity.ProtoReflect.Descriptor instead.

func (*UplinkCapacity) GetValue

func (x *UplinkCapacity) GetValue() uint32

func (*UplinkCapacity) ProtoMessage

func (*UplinkCapacity) ProtoMessage()

func (*UplinkCapacity) ProtoReflect

func (x *UplinkCapacity) ProtoReflect() protoreflect.Message

func (*UplinkCapacity) Reset

func (x *UplinkCapacity) Reset()

func (*UplinkCapacity) String

func (x *UplinkCapacity) String() string

type WriteBuffer

type WriteBuffer struct {

	// Buffer size in bytes.
	Size uint32 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"`
	// contains filtered or unexported fields
}

func (*WriteBuffer) Descriptor deprecated

func (*WriteBuffer) Descriptor() ([]byte, []int)

Deprecated: Use WriteBuffer.ProtoReflect.Descriptor instead.

func (*WriteBuffer) GetSize

func (x *WriteBuffer) GetSize() uint32

func (*WriteBuffer) ProtoMessage

func (*WriteBuffer) ProtoMessage()

func (*WriteBuffer) ProtoReflect

func (x *WriteBuffer) ProtoReflect() protoreflect.Message

func (*WriteBuffer) Reset

func (x *WriteBuffer) Reset()

func (*WriteBuffer) String

func (x *WriteBuffer) String() string

type Writer

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

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Write

func (w *Writer) Write(payload []byte) (int, error)

Jump to

Keyboard shortcuts

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