core: v2ray.com/core/transport/internet/kcp Index | Files

package kcp

import "v2ray.com/core/transport/internet/kcp"

Package kcp - A Fast and Reliable ARQ Protocol

Acknowledgement:

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

Index

Package Files

config.go config.pb.go connection.go crypt.go dialer.go errors.generated.go io.go kcp.go listener.go output.go receiving.go segment.go sending.go xor_amd64.go

Constants

const (
    DataSegmentOverhead = 18
)

Variables

var (
    ErrIOTimeout        = newError("Read/Write timeout")
    ErrClosedListener   = newError("Listener closed.")
    ErrClosedConnection = newError("Connection closed.")
)

func DialKCP Uses

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

DialKCP dials a new KCP connections to the specific destination.

func ListenKCP Uses

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

func NewSimpleAuthenticator Uses

func NewSimpleAuthenticator() cipher.AEAD

NewSimpleAuthenticator creates a new SimpleAuthenticator

type AckList Uses

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

func NewAckList Uses

func NewAckList(writer SegmentWriter) *AckList

func (*AckList) Add Uses

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

func (*AckList) Clear Uses

func (l *AckList) Clear(una uint32)

func (*AckList) Flush Uses

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

type AckSegment Uses

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

func NewAckSegment Uses

func NewAckSegment() *AckSegment

func (*AckSegment) ByteSize Uses

func (s *AckSegment) ByteSize() int32

func (*AckSegment) Command Uses

func (*AckSegment) Command() Command

func (*AckSegment) Conversation Uses

func (s *AckSegment) Conversation() uint16

func (*AckSegment) IsEmpty Uses

func (s *AckSegment) IsEmpty() bool

func (*AckSegment) IsFull Uses

func (s *AckSegment) IsFull() bool

func (*AckSegment) PutNumber Uses

func (s *AckSegment) PutNumber(number uint32)

func (*AckSegment) PutTimestamp Uses

func (s *AckSegment) PutTimestamp(timestamp uint32)

func (*AckSegment) Release Uses

func (s *AckSegment) Release()

func (*AckSegment) Serialize Uses

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

type CmdOnlySegment Uses

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

func NewCmdOnlySegment Uses

func NewCmdOnlySegment() *CmdOnlySegment

func (*CmdOnlySegment) ByteSize Uses

func (*CmdOnlySegment) ByteSize() int32

func (*CmdOnlySegment) Command Uses

func (s *CmdOnlySegment) Command() Command

func (*CmdOnlySegment) Conversation Uses

func (s *CmdOnlySegment) Conversation() uint16

func (*CmdOnlySegment) Release Uses

func (*CmdOnlySegment) Release()

func (*CmdOnlySegment) Serialize Uses

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

type Command Uses

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 Uses

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"`
    XXX_NoUnkeyedLiteral struct{}             `json:"-"`
    XXX_unrecognized     []byte               `json:"-"`
    XXX_sizecache        int32                `json:"-"`
}

func (*Config) Descriptor Uses

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

func (*Config) GetCongestion Uses

func (m *Config) GetCongestion() bool

func (*Config) GetDownlinkCapacity Uses

func (m *Config) GetDownlinkCapacity() *DownlinkCapacity

func (*Config) GetDownlinkCapacityValue Uses

func (c *Config) GetDownlinkCapacityValue() uint32

GetDownlinkCapacityValue returns the value of DownlinkCapacity settings.

func (*Config) GetHeaderConfig Uses

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

func (*Config) GetMTUValue Uses

func (c *Config) GetMTUValue() uint32

GetMTUValue returns the value of MTU settings.

func (*Config) GetMtu Uses

func (m *Config) GetMtu() *MTU

func (*Config) GetPackerHeader Uses

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

func (*Config) GetReadBuffer Uses

func (m *Config) GetReadBuffer() *ReadBuffer

func (*Config) GetReadBufferSize Uses

func (c *Config) GetReadBufferSize() uint32

GetReadBufferSize returns the size of ReadBuffer in bytes.

func (*Config) GetReceivingBufferSize Uses

func (c *Config) GetReceivingBufferSize() uint32

func (*Config) GetReceivingInFlightSize Uses

func (c *Config) GetReceivingInFlightSize() uint32

func (*Config) GetSecurity Uses

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

GetSecurity returns the security settings.

func (*Config) GetSendingBufferSize Uses

func (c *Config) GetSendingBufferSize() uint32

func (*Config) GetSendingInFlightSize Uses

func (c *Config) GetSendingInFlightSize() uint32

func (*Config) GetTTIValue Uses

func (c *Config) GetTTIValue() uint32

GetTTIValue returns the value of TTI settings.

func (*Config) GetTti Uses

func (m *Config) GetTti() *TTI

func (*Config) GetUplinkCapacity Uses

func (m *Config) GetUplinkCapacity() *UplinkCapacity

func (*Config) GetUplinkCapacityValue Uses

func (c *Config) GetUplinkCapacityValue() uint32

GetUplinkCapacityValue returns the value of UplinkCapacity settings.

func (*Config) GetWriteBuffer Uses

func (m *Config) GetWriteBuffer() *WriteBuffer

func (*Config) GetWriteBufferSize Uses

func (c *Config) GetWriteBufferSize() uint32

GetWriteBufferSize returns the size of WriterBuffer in bytes.

func (*Config) ProtoMessage Uses

func (*Config) ProtoMessage()

func (*Config) Reset Uses

func (m *Config) Reset()

func (*Config) String Uses

func (m *Config) String() string

func (*Config) XXX_DiscardUnknown Uses

func (m *Config) XXX_DiscardUnknown()

func (*Config) XXX_Marshal Uses

func (m *Config) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Config) XXX_Merge Uses

func (m *Config) XXX_Merge(src proto.Message)

func (*Config) XXX_Size Uses

func (m *Config) XXX_Size() int

func (*Config) XXX_Unmarshal Uses

func (m *Config) XXX_Unmarshal(b []byte) error

type ConnMetadata Uses

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

type Connection Uses

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

Connection is a KCP connection over UDP.

func NewConnection Uses

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 Uses

func (c *Connection) Close() error

Close closes the connection.

func (*Connection) Elapsed Uses

func (c *Connection) Elapsed() uint32

func (*Connection) HandleOption Uses

func (c *Connection) HandleOption(opt SegmentOption)

func (*Connection) Input Uses

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

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

func (*Connection) LocalAddr Uses

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 Uses

func (c *Connection) OnPeerClosed()

func (*Connection) Ping Uses

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

func (*Connection) Read Uses

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

Read implements the Conn Read method.

func (*Connection) ReadMultiBuffer Uses

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

ReadMultiBuffer implements buf.Reader.

func (*Connection) RemoteAddr Uses

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 Uses

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 Uses

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

SetReadDeadline implements the Conn SetReadDeadline method.

func (*Connection) SetState Uses

func (c *Connection) SetState(state State)

func (*Connection) SetWriteDeadline Uses

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

SetWriteDeadline implements the Conn SetWriteDeadline method.

func (*Connection) State Uses

func (c *Connection) State() State

func (*Connection) Terminate Uses

func (c *Connection) Terminate()

func (*Connection) Write Uses

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

Write implements io.Writer.

func (*Connection) WriteMultiBuffer Uses

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

WriteMultiBuffer implements buf.Writer.

type ConnectionID Uses

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

type ConnectionReuse Uses

type ConnectionReuse struct {
    Enable               bool     `protobuf:"varint,1,opt,name=enable,proto3" json:"enable,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*ConnectionReuse) Descriptor Uses

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

func (*ConnectionReuse) GetEnable Uses

func (m *ConnectionReuse) GetEnable() bool

func (*ConnectionReuse) ProtoMessage Uses

func (*ConnectionReuse) ProtoMessage()

func (*ConnectionReuse) Reset Uses

func (m *ConnectionReuse) Reset()

func (*ConnectionReuse) String Uses

func (m *ConnectionReuse) String() string

func (*ConnectionReuse) XXX_DiscardUnknown Uses

func (m *ConnectionReuse) XXX_DiscardUnknown()

func (*ConnectionReuse) XXX_Marshal Uses

func (m *ConnectionReuse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ConnectionReuse) XXX_Merge Uses

func (m *ConnectionReuse) XXX_Merge(src proto.Message)

func (*ConnectionReuse) XXX_Size Uses

func (m *ConnectionReuse) XXX_Size() int

func (*ConnectionReuse) XXX_Unmarshal Uses

func (m *ConnectionReuse) XXX_Unmarshal(b []byte) error

type DataSegment Uses

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

func NewDataSegment Uses

func NewDataSegment() *DataSegment

func (*DataSegment) ByteSize Uses

func (s *DataSegment) ByteSize() int32

func (*DataSegment) Command Uses

func (*DataSegment) Command() Command

func (*DataSegment) Conversation Uses

func (s *DataSegment) Conversation() uint16

func (*DataSegment) Data Uses

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

func (*DataSegment) Detach Uses

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

func (*DataSegment) Release Uses

func (s *DataSegment) Release()

func (*DataSegment) Serialize Uses

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

type DownlinkCapacity Uses

type DownlinkCapacity struct {
    Value                uint32   `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

Downlink capacity, in MB.

func (*DownlinkCapacity) Descriptor Uses

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

func (*DownlinkCapacity) GetValue Uses

func (m *DownlinkCapacity) GetValue() uint32

func (*DownlinkCapacity) ProtoMessage Uses

func (*DownlinkCapacity) ProtoMessage()

func (*DownlinkCapacity) Reset Uses

func (m *DownlinkCapacity) Reset()

func (*DownlinkCapacity) String Uses

func (m *DownlinkCapacity) String() string

func (*DownlinkCapacity) XXX_DiscardUnknown Uses

func (m *DownlinkCapacity) XXX_DiscardUnknown()

func (*DownlinkCapacity) XXX_Marshal Uses

func (m *DownlinkCapacity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DownlinkCapacity) XXX_Merge Uses

func (m *DownlinkCapacity) XXX_Merge(src proto.Message)

func (*DownlinkCapacity) XXX_Size Uses

func (m *DownlinkCapacity) XXX_Size() int

func (*DownlinkCapacity) XXX_Unmarshal Uses

func (m *DownlinkCapacity) XXX_Unmarshal(b []byte) error

type KCPPacketReader Uses

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

func (*KCPPacketReader) Read Uses

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

type KCPPacketWriter Uses

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

func (*KCPPacketWriter) Overhead Uses

func (w *KCPPacketWriter) Overhead() int

func (*KCPPacketWriter) Write Uses

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

type Listener Uses

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

Listener defines a server listening for connections

func NewListener Uses

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

func (*Listener) ActiveConnections Uses

func (l *Listener) ActiveConnections() int

func (*Listener) Addr Uses

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 Uses

func (l *Listener) Close() error

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

func (*Listener) OnReceive Uses

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

func (*Listener) Remove Uses

func (l *Listener) Remove(id ConnectionID)

type MTU Uses

type MTU struct {
    Value                uint32   `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

Maximum Transmission Unit, in bytes.

func (*MTU) Descriptor Uses

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

func (*MTU) GetValue Uses

func (m *MTU) GetValue() uint32

func (*MTU) ProtoMessage Uses

func (*MTU) ProtoMessage()

func (*MTU) Reset Uses

func (m *MTU) Reset()

func (*MTU) String Uses

func (m *MTU) String() string

func (*MTU) XXX_DiscardUnknown Uses

func (m *MTU) XXX_DiscardUnknown()

func (*MTU) XXX_Marshal Uses

func (m *MTU) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MTU) XXX_Merge Uses

func (m *MTU) XXX_Merge(src proto.Message)

func (*MTU) XXX_Size Uses

func (m *MTU) XXX_Size() int

func (*MTU) XXX_Unmarshal Uses

func (m *MTU) XXX_Unmarshal(b []byte) error

type PacketReader Uses

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

type PacketWriter Uses

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

type ReadBuffer Uses

type ReadBuffer struct {
    // Buffer size in bytes.
    Size                 uint32   `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*ReadBuffer) Descriptor Uses

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

func (*ReadBuffer) GetSize Uses

func (m *ReadBuffer) GetSize() uint32

func (*ReadBuffer) ProtoMessage Uses

func (*ReadBuffer) ProtoMessage()

func (*ReadBuffer) Reset Uses

func (m *ReadBuffer) Reset()

func (*ReadBuffer) String Uses

func (m *ReadBuffer) String() string

func (*ReadBuffer) XXX_DiscardUnknown Uses

func (m *ReadBuffer) XXX_DiscardUnknown()

func (*ReadBuffer) XXX_Marshal Uses

func (m *ReadBuffer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ReadBuffer) XXX_Merge Uses

func (m *ReadBuffer) XXX_Merge(src proto.Message)

func (*ReadBuffer) XXX_Size Uses

func (m *ReadBuffer) XXX_Size() int

func (*ReadBuffer) XXX_Unmarshal Uses

func (m *ReadBuffer) XXX_Unmarshal(b []byte) error

type ReceivingWindow Uses

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

func NewReceivingWindow Uses

func NewReceivingWindow() *ReceivingWindow

func (*ReceivingWindow) Has Uses

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

func (*ReceivingWindow) Remove Uses

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

func (*ReceivingWindow) Set Uses

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

type ReceivingWorker Uses

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

func NewReceivingWorker Uses

func NewReceivingWorker(kcp *Connection) *ReceivingWorker

func (*ReceivingWorker) CloseRead Uses

func (*ReceivingWorker) CloseRead()

func (*ReceivingWorker) Flush Uses

func (w *ReceivingWorker) Flush(current uint32)

func (*ReceivingWorker) IsDataAvailable Uses

func (w *ReceivingWorker) IsDataAvailable() bool

func (*ReceivingWorker) NextNumber Uses

func (w *ReceivingWorker) NextNumber() uint32

func (*ReceivingWorker) ProcessSegment Uses

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

func (*ReceivingWorker) ProcessSendingNext Uses

func (w *ReceivingWorker) ProcessSendingNext(number uint32)

func (*ReceivingWorker) Read Uses

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

func (*ReceivingWorker) ReadMultiBuffer Uses

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

func (*ReceivingWorker) Release Uses

func (w *ReceivingWorker) Release()

func (*ReceivingWorker) UpdateNecessary Uses

func (w *ReceivingWorker) UpdateNecessary() bool

func (*ReceivingWorker) Write Uses

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

type RetryableWriter Uses

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

func (*RetryableWriter) Write Uses

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

type RoundTripInfo Uses

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

func (*RoundTripInfo) SmoothedTime Uses

func (info *RoundTripInfo) SmoothedTime() uint32

func (*RoundTripInfo) Timeout Uses

func (info *RoundTripInfo) Timeout() uint32

func (*RoundTripInfo) Update Uses

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

func (*RoundTripInfo) UpdatePeerRTO Uses

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

type Segment Uses

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

func ReadSegment Uses

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

type SegmentOption Uses

type SegmentOption byte
const (
    SegmentOptionClose SegmentOption = 1
)

type SegmentWriter Uses

type SegmentWriter interface {
    Write(seg Segment) error
}

func NewRetryableWriter Uses

func NewRetryableWriter(writer SegmentWriter) SegmentWriter

func NewSegmentWriter Uses

func NewSegmentWriter(writer io.Writer) SegmentWriter

type SendingWindow Uses

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

func NewSendingWindow Uses

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

func (*SendingWindow) Clear Uses

func (sw *SendingWindow) Clear(una uint32)

func (*SendingWindow) FirstNumber Uses

func (sw *SendingWindow) FirstNumber() uint32

func (*SendingWindow) Flush Uses

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

func (*SendingWindow) HandleFastAck Uses

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

func (*SendingWindow) IsEmpty Uses

func (sw *SendingWindow) IsEmpty() bool

func (*SendingWindow) Len Uses

func (sw *SendingWindow) Len() uint32

func (*SendingWindow) Push Uses

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

func (*SendingWindow) Release Uses

func (sw *SendingWindow) Release()

func (*SendingWindow) Remove Uses

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

func (*SendingWindow) Visit Uses

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

type SendingWorker Uses

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

func NewSendingWorker Uses

func NewSendingWorker(kcp *Connection) *SendingWorker

func (*SendingWorker) CloseWrite Uses

func (w *SendingWorker) CloseWrite()

func (*SendingWorker) FindFirstUnacknowledged Uses

func (w *SendingWorker) FindFirstUnacknowledged()

func (*SendingWorker) FirstUnacknowledged Uses

func (w *SendingWorker) FirstUnacknowledged() uint32

func (*SendingWorker) Flush Uses

func (w *SendingWorker) Flush(current uint32)

func (*SendingWorker) IsEmpty Uses

func (w *SendingWorker) IsEmpty() bool

func (*SendingWorker) OnPacketLoss Uses

func (w *SendingWorker) OnPacketLoss(lossRate uint32)

func (*SendingWorker) ProcessReceivingNext Uses

func (w *SendingWorker) ProcessReceivingNext(nextNumber uint32)

func (*SendingWorker) ProcessReceivingNextWithoutLock Uses

func (w *SendingWorker) ProcessReceivingNextWithoutLock(nextNumber uint32)

func (*SendingWorker) ProcessSegment Uses

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

func (*SendingWorker) Push Uses

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

func (*SendingWorker) Release Uses

func (w *SendingWorker) Release()

func (*SendingWorker) UpdateNecessary Uses

func (w *SendingWorker) UpdateNecessary() bool

func (*SendingWorker) Write Uses

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

type SimpleAuthenticator Uses

type SimpleAuthenticator struct{}

SimpleAuthenticator is a legacy AEAD used for KCP encryption.

func (*SimpleAuthenticator) NonceSize Uses

func (*SimpleAuthenticator) NonceSize() int

NonceSize implements cipher.AEAD.NonceSize().

func (*SimpleAuthenticator) Open Uses

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

Open implements cipher.AEAD.Open().

func (*SimpleAuthenticator) Overhead Uses

func (*SimpleAuthenticator) Overhead() int

Overhead implements cipher.AEAD.NonceSize().

func (*SimpleAuthenticator) Seal Uses

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

Seal implements cipher.AEAD.Seal().

type SimpleSegmentWriter Uses

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

func (*SimpleSegmentWriter) Write Uses

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

type State Uses

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 Uses

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

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

type TTI Uses

type TTI struct {
    Value                uint32   `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

Transmission Time Interview, in milli-sec.

func (*TTI) Descriptor Uses

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

func (*TTI) GetValue Uses

func (m *TTI) GetValue() uint32

func (*TTI) ProtoMessage Uses

func (*TTI) ProtoMessage()

func (*TTI) Reset Uses

func (m *TTI) Reset()

func (*TTI) String Uses

func (m *TTI) String() string

func (*TTI) XXX_DiscardUnknown Uses

func (m *TTI) XXX_DiscardUnknown()

func (*TTI) XXX_Marshal Uses

func (m *TTI) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TTI) XXX_Merge Uses

func (m *TTI) XXX_Merge(src proto.Message)

func (*TTI) XXX_Size Uses

func (m *TTI) XXX_Size() int

func (*TTI) XXX_Unmarshal Uses

func (m *TTI) XXX_Unmarshal(b []byte) error

type Updater Uses

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

func NewUpdater Uses

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

func (*Updater) Interval Uses

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

func (*Updater) SetInterval Uses

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

func (*Updater) WakeUp Uses

func (u *Updater) WakeUp()

type UplinkCapacity Uses

type UplinkCapacity struct {
    Value                uint32   `protobuf:"varint,1,opt,name=value,proto3" json:"value,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

Uplink capacity, in MB.

func (*UplinkCapacity) Descriptor Uses

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

func (*UplinkCapacity) GetValue Uses

func (m *UplinkCapacity) GetValue() uint32

func (*UplinkCapacity) ProtoMessage Uses

func (*UplinkCapacity) ProtoMessage()

func (*UplinkCapacity) Reset Uses

func (m *UplinkCapacity) Reset()

func (*UplinkCapacity) String Uses

func (m *UplinkCapacity) String() string

func (*UplinkCapacity) XXX_DiscardUnknown Uses

func (m *UplinkCapacity) XXX_DiscardUnknown()

func (*UplinkCapacity) XXX_Marshal Uses

func (m *UplinkCapacity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UplinkCapacity) XXX_Merge Uses

func (m *UplinkCapacity) XXX_Merge(src proto.Message)

func (*UplinkCapacity) XXX_Size Uses

func (m *UplinkCapacity) XXX_Size() int

func (*UplinkCapacity) XXX_Unmarshal Uses

func (m *UplinkCapacity) XXX_Unmarshal(b []byte) error

type WriteBuffer Uses

type WriteBuffer struct {
    // Buffer size in bytes.
    Size                 uint32   `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"`
    XXX_NoUnkeyedLiteral struct{} `json:"-"`
    XXX_unrecognized     []byte   `json:"-"`
    XXX_sizecache        int32    `json:"-"`
}

func (*WriteBuffer) Descriptor Uses

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

func (*WriteBuffer) GetSize Uses

func (m *WriteBuffer) GetSize() uint32

func (*WriteBuffer) ProtoMessage Uses

func (*WriteBuffer) ProtoMessage()

func (*WriteBuffer) Reset Uses

func (m *WriteBuffer) Reset()

func (*WriteBuffer) String Uses

func (m *WriteBuffer) String() string

func (*WriteBuffer) XXX_DiscardUnknown Uses

func (m *WriteBuffer) XXX_DiscardUnknown()

func (*WriteBuffer) XXX_Marshal Uses

func (m *WriteBuffer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*WriteBuffer) XXX_Merge Uses

func (m *WriteBuffer) XXX_Merge(src proto.Message)

func (*WriteBuffer) XXX_Size Uses

func (m *WriteBuffer) XXX_Size() int

func (*WriteBuffer) XXX_Unmarshal Uses

func (m *WriteBuffer) XXX_Unmarshal(b []byte) error

type Writer Uses

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

func (*Writer) Close Uses

func (w *Writer) Close() error

func (*Writer) Write Uses

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

Package kcp imports 29 packages (graph) and is imported by 6 packages. Updated 2019-04-20. Refresh now. Tools for package owners.