kcp

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: Apache-2.0 Imports: 33 Imported by: 0

README

KCP Packet-Conn Implementation

This is an implementation of the packet-conn common package that uses Kcp instead of Quic.

The primary advantage here is that Kcp supports very low MTU values, as well as custom block cyphers and compression.

Known issues:

  • Unencrypted streams currently do not work (raw streams)
  • The packet switching is buggy and prone to break
  • KCP in general is a bit buggy

This package is here as a stop-gap for xbee until we find a way to transmit the minimum 1000 bytes packet size for Quic over xbee.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CoordPacketType_name = map[int32]string{
		0: "CoordPacketType_UNKNOWN",
		1: "CoordPacketType_RSTREAM_ESTABLISH",
		2: "CoordPacketType_RSTREAM_ACK",
		3: "CoordPacketType_RSTREAM_CLOSE",
		4: "CoordPacketType_RSTREAM_NOOP",
	}
	CoordPacketType_value = map[string]int32{
		"CoordPacketType_UNKNOWN":           0,
		"CoordPacketType_RSTREAM_ESTABLISH": 1,
		"CoordPacketType_RSTREAM_ACK":       2,
		"CoordPacketType_RSTREAM_CLOSE":     3,
		"CoordPacketType_RSTREAM_NOOP":      4,
	}
)

Enum value maps for CoordPacketType.

View Source
var (
	KCPMode_name = map[int32]string{
		0: "KCPMode_UNKNOWN",
		1: "KCPMode_NORMAL",
		2: "KCPMode_FAST",
		3: "KCPMode_FAST2",
		4: "KCPMode_FAST3",
		5: "KCPMode_SLOW1",
	}
	KCPMode_value = map[string]int32{
		"KCPMode_UNKNOWN": 0,
		"KCPMode_NORMAL":  1,
		"KCPMode_FAST":    2,
		"KCPMode_FAST2":   3,
		"KCPMode_FAST3":   4,
		"KCPMode_SLOW1":   5,
	}
)

Enum value maps for KCPMode.

View Source
var (
	StreamMuxer_name = map[int32]string{
		0: "StreamMuxer_UNKNOWN",
		1: "StreamMuxer_XTACI_SMUX",
		2: "StreamMuxer_YAMUX",
	}
	StreamMuxer_value = map[string]int32{
		"StreamMuxer_UNKNOWN":    0,
		"StreamMuxer_XTACI_SMUX": 1,
		"StreamMuxer_YAMUX":      2,
	}
)

Enum value maps for StreamMuxer.

View Source
var (
	PacketType_name = map[int32]string{
		0: "PacketType_HANDSHAKE",
		1: "PacketType_RAW",
		2: "PacketType_KCP_SMUX",
		3: "PacketType_CLOSE_LINK",
	}
	PacketType_value = map[string]int32{
		"PacketType_HANDSHAKE":  0,
		"PacketType_RAW":        1,
		"PacketType_KCP_SMUX":   2,
		"PacketType_CLOSE_LINK": 3,
	}
)

Enum value maps for PacketType.

View Source
var File_github_com_aperturerobotics_bifrost_transport_common_kcp_coord_stream_proto protoreflect.FileDescriptor
View Source
var File_github_com_aperturerobotics_bifrost_transport_common_kcp_kcp_handshake_proto protoreflect.FileDescriptor
View Source
var File_github_com_aperturerobotics_bifrost_transport_common_kcp_kcp_proto protoreflect.FileDescriptor
View Source
var File_github_com_aperturerobotics_bifrost_transport_common_kcp_packet_type_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type CoordPacketType

type CoordPacketType int32

CoordPacketType is the packet type of a coordination stream packet.

const (
	CoordPacketType_CoordPacketType_UNKNOWN           CoordPacketType = 0
	CoordPacketType_CoordPacketType_RSTREAM_ESTABLISH CoordPacketType = 1
	CoordPacketType_CoordPacketType_RSTREAM_ACK       CoordPacketType = 2
	CoordPacketType_CoordPacketType_RSTREAM_CLOSE     CoordPacketType = 3
	CoordPacketType_CoordPacketType_RSTREAM_NOOP      CoordPacketType = 4
)

func (CoordPacketType) Descriptor added in v0.2.0

func (CoordPacketType) Enum added in v0.2.0

func (x CoordPacketType) Enum() *CoordPacketType

func (CoordPacketType) EnumDescriptor deprecated

func (CoordPacketType) EnumDescriptor() ([]byte, []int)

Deprecated: Use CoordPacketType.Descriptor instead.

func (CoordPacketType) Number added in v0.2.0

func (CoordPacketType) String

func (x CoordPacketType) String() string

func (CoordPacketType) Type added in v0.2.0

type CoordinationStreamPacket

type CoordinationStreamPacket struct {

	// PacketType is the coordination stream packet type.
	PacketType CoordPacketType `protobuf:"varint,1,opt,name=packet_type,json=packetType,proto3,enum=kcp.CoordPacketType" json:"packet_type,omitempty"`
	// RawStreamEstablish is the raw stream establish packet.
	RawStreamEstablish *RawStreamEstablish `protobuf:"bytes,2,opt,name=raw_stream_establish,json=rawStreamEstablish,proto3" json:"raw_stream_establish,omitempty"`
	// RawStreamAck is the raw stream ack packet.
	RawStreamAck *RawStreamAck `protobuf:"bytes,3,opt,name=raw_stream_ack,json=rawStreamAck,proto3" json:"raw_stream_ack,omitempty"`
	// RawStreamClose is the raw stream close packet.
	RawStreamClose *RawStreamClose `protobuf:"bytes,4,opt,name=raw_stream_close,json=rawStreamClose,proto3" json:"raw_stream_close,omitempty"`
	// contains filtered or unexported fields
}

CoordinationStreamPacket is the packet wrapper for a coordination stream packet.

func (*CoordinationStreamPacket) CloneMessageVT added in v0.15.6

func (m *CoordinationStreamPacket) CloneMessageVT() proto.Message

func (*CoordinationStreamPacket) CloneVT added in v0.8.3

func (*CoordinationStreamPacket) Descriptor deprecated

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

Deprecated: Use CoordinationStreamPacket.ProtoReflect.Descriptor instead.

func (*CoordinationStreamPacket) EqualMessageVT added in v0.15.6

func (this *CoordinationStreamPacket) EqualMessageVT(thatMsg proto.Message) bool

func (*CoordinationStreamPacket) EqualVT added in v0.3.0

func (*CoordinationStreamPacket) GetPacketType

func (x *CoordinationStreamPacket) GetPacketType() CoordPacketType

func (*CoordinationStreamPacket) GetRawStreamAck

func (x *CoordinationStreamPacket) GetRawStreamAck() *RawStreamAck

func (*CoordinationStreamPacket) GetRawStreamClose

func (x *CoordinationStreamPacket) GetRawStreamClose() *RawStreamClose

func (*CoordinationStreamPacket) GetRawStreamEstablish

func (x *CoordinationStreamPacket) GetRawStreamEstablish() *RawStreamEstablish

func (*CoordinationStreamPacket) MarshalToSizedBufferVT added in v0.2.0

func (m *CoordinationStreamPacket) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*CoordinationStreamPacket) MarshalToVT added in v0.2.0

func (m *CoordinationStreamPacket) MarshalToVT(dAtA []byte) (int, error)

func (*CoordinationStreamPacket) MarshalVT added in v0.2.0

func (m *CoordinationStreamPacket) MarshalVT() (dAtA []byte, err error)

func (*CoordinationStreamPacket) ProtoMessage

func (*CoordinationStreamPacket) ProtoMessage()

func (*CoordinationStreamPacket) ProtoReflect added in v0.2.0

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

func (*CoordinationStreamPacket) Reset

func (x *CoordinationStreamPacket) Reset()

func (*CoordinationStreamPacket) SizeVT added in v0.2.0

func (m *CoordinationStreamPacket) SizeVT() (n int)

func (*CoordinationStreamPacket) String

func (x *CoordinationStreamPacket) String() string

func (*CoordinationStreamPacket) UnmarshalVT added in v0.2.0

func (m *CoordinationStreamPacket) UnmarshalVT(dAtA []byte) error

type HandshakeExtraData

type HandshakeExtraData struct {

	// LocalTransportUuid is the transport uuid of the sender.
	// This is used for monitoring / analysis at a later time.
	// Coorelates the transport connections between two machines.
	LocalTransportUuid uint64 `protobuf:"varint,1,opt,name=local_transport_uuid,json=localTransportUuid,proto3" json:"local_transport_uuid,omitempty"`
	// contains filtered or unexported fields
}

HandshakeExtraData contains the extra data field of the pconn handshake.

func (*HandshakeExtraData) CloneMessageVT added in v0.15.6

func (m *HandshakeExtraData) CloneMessageVT() proto.Message

func (*HandshakeExtraData) CloneVT added in v0.8.3

func (m *HandshakeExtraData) CloneVT() *HandshakeExtraData

func (*HandshakeExtraData) Descriptor deprecated

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

Deprecated: Use HandshakeExtraData.ProtoReflect.Descriptor instead.

func (*HandshakeExtraData) EqualMessageVT added in v0.15.6

func (this *HandshakeExtraData) EqualMessageVT(thatMsg proto.Message) bool

func (*HandshakeExtraData) EqualVT added in v0.3.0

func (this *HandshakeExtraData) EqualVT(that *HandshakeExtraData) bool

func (*HandshakeExtraData) GetLocalTransportUuid

func (x *HandshakeExtraData) GetLocalTransportUuid() uint64

func (*HandshakeExtraData) MarshalToSizedBufferVT added in v0.2.0

func (m *HandshakeExtraData) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*HandshakeExtraData) MarshalToVT added in v0.2.0

func (m *HandshakeExtraData) MarshalToVT(dAtA []byte) (int, error)

func (*HandshakeExtraData) MarshalVT added in v0.2.0

func (m *HandshakeExtraData) MarshalVT() (dAtA []byte, err error)

func (*HandshakeExtraData) ProtoMessage

func (*HandshakeExtraData) ProtoMessage()

func (*HandshakeExtraData) ProtoReflect added in v0.2.0

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

func (*HandshakeExtraData) Reset

func (x *HandshakeExtraData) Reset()

func (*HandshakeExtraData) SizeVT added in v0.2.0

func (m *HandshakeExtraData) SizeVT() (n int)

func (*HandshakeExtraData) String

func (x *HandshakeExtraData) String() string

func (*HandshakeExtraData) UnmarshalVT added in v0.2.0

func (m *HandshakeExtraData) UnmarshalVT(dAtA []byte) error

type KCPMode

type KCPMode int32

KCPMode is the mode to set KCP to.

const (
	// KCPMode_UNKNOWN defaults to normal mode.
	KCPMode_KCPMode_UNKNOWN KCPMode = 0
	// KCPMode_NORMAL is the normal mode.
	// NoDelay = 0
	// Interval = 40
	// Resend = 2
	// NoCongestion = 1
	KCPMode_KCPMode_NORMAL KCPMode = 1
	// KCPMode_FAST is the "fast" mode.
	// NoDelay = 0
	// Interval = 30
	// Resend = 2
	// NoCongestion = 1
	KCPMode_KCPMode_FAST KCPMode = 2
	// KCPMode_FAST2 is the "fast2" mode.
	// NoDelay = 1
	// Interval = 20
	// Resend = 2
	// NoCongestion = 1
	KCPMode_KCPMode_FAST2 KCPMode = 3
	// KCPMode_FAST3 is the "fast3" mode.
	// NoDelay = 1
	// Interval = 10
	// Resend = 2
	// NoCongestion = 1
	KCPMode_KCPMode_FAST3 KCPMode = 4
	// KCPMode_SLOW1 is the slow 1 mode.
	// NoDelay = 0
	// Interval = 100
	// Resend = 0
	// NoCongestion = 0
	KCPMode_KCPMode_SLOW1 KCPMode = 5
)

func (KCPMode) Descriptor added in v0.2.0

func (KCPMode) Descriptor() protoreflect.EnumDescriptor

func (KCPMode) Enum added in v0.2.0

func (x KCPMode) Enum() *KCPMode

func (KCPMode) EnumDescriptor deprecated

func (KCPMode) EnumDescriptor() ([]byte, []int)

Deprecated: Use KCPMode.Descriptor instead.

func (KCPMode) Number added in v0.2.0

func (x KCPMode) Number() protoreflect.EnumNumber

func (KCPMode) String

func (x KCPMode) String() string

func (KCPMode) Type added in v0.2.0

func (KCPMode) Type() protoreflect.EnumType
type Link struct {
	// contains filtered or unexported fields
}

Link represents a KCP-based connection/link.

func NewLink(
	ctx context.Context,
	le *logrus.Entry,
	opts *Opts,
	localPeerID peer.ID,
	localAddr, remoteAddr net.Addr,
	transportUUID, remoteTransportUUID uint64,
	neg *identity.Result,
	writer func(b []byte, addr net.Addr) (n int, err error),
	initiator bool,
	closed func(),
) (*Link, error)

NewLink builds a new link.

func (*Link) AcceptStream

func (l *Link) AcceptStream() (stream.Stream, stream.OpenOpts, error)

AcceptStream accepts a stream from the link.

func (*Link) Close

func (l *Link) Close() error

Close closes the connection.

func (*Link) GetLocalPeer

func (l *Link) GetLocalPeer() peer.ID

GetLocalPeer returns the identity of the local peer.

func (*Link) GetRemotePeer

func (l *Link) GetRemotePeer() peer.ID

GetRemotePeer returns the identity of the remote peer if encrypted.

func (*Link) GetRemoteTransportUUID

func (l *Link) GetRemoteTransportUUID() uint64

GetRemoteTransportUUID returns the unique ID of the remote transport. Reported by the remote peer. May be zero or unreliable value.

func (*Link) GetTransportUUID

func (l *Link) GetTransportUUID() uint64

GetTransportUUID returns the unique ID of the transport.

func (*Link) GetUUID

func (l *Link) GetUUID() uint64

GetUUID returns the link unique id.

func (*Link) HandlePacket

func (l *Link) HandlePacket(packetType PacketType, data []byte)

HandlePacket handles a packet.

func (*Link) OpenStream

func (l *Link) OpenStream(opts stream.OpenOpts) (stream.Stream, error)

OpenStream opens a stream on the link, with the given parameters.

type Opts

type Opts struct {

	// DataShards are the number of FEC data shards to use. By adding t check
	// symbols to the data, a Reed–Solomon code can detect any combination of up
	// to t erroneous symbols, or correct up to ⌊t/2⌋ symbols. As an erasure code,
	// it can correct up to t known erasures, or it can detect and correct
	// combinations of errors and erasures. Furthermore, Reed–Solomon codes are
	// suitable as multiple-burst bit-error correcting codes, since a sequence of
	// b + 1 consecutive bit errors can affect at most two symbols of size b. The
	// choice of t is up to the designer of the code, and may be selected within
	// wide limits. Maximum is 256.
	// Recommended: 10
	// If zero, FEC is disabled.
	DataShards uint32 `protobuf:"varint,1,opt,name=data_shards,json=dataShards,proto3" json:"data_shards,omitempty"`
	// ParityShards are the number of FEC parity shards to use.
	// Recommended: 3
	ParityShards uint32 `protobuf:"varint,2,opt,name=parity_shards,json=parityShards,proto3" json:"parity_shards,omitempty"`
	// Mtu is the maximum transmission unit to use.
	// Defaults to 1350 (UDP safe packet size).
	Mtu uint32 `protobuf:"varint,3,opt,name=mtu,proto3" json:"mtu,omitempty"`
	// KcpMode is the KCP mode.
	KcpMode KCPMode `protobuf:"varint,4,opt,name=kcp_mode,json=kcpMode,proto3,enum=kcp.KCPMode" json:"kcp_mode,omitempty"`
	// BlockCrypt is the block crypto to use.
	// Defaults to AES256.
	// Uses the handshake-negotiated session key.
	BlockCrypt blockcrypt.BlockCrypt `protobuf:"varint,5,opt,name=block_crypt,json=blockCrypt,proto3,enum=blockcrypt.BlockCrypt" json:"block_crypt,omitempty"`
	// BlockCompress is the block compression to use.
	BlockCompress blockcompress.BlockCompress `` /* 134-byte string literal not displayed */
	// StreamMuxer is the stream muxer to use.
	// Defaults to smux.
	StreamMuxer StreamMuxer `protobuf:"varint,7,opt,name=stream_muxer,json=streamMuxer,proto3,enum=kcp.StreamMuxer" json:"stream_muxer,omitempty"`
	// contains filtered or unexported fields
}

Opts are extra options for the packet conn.

func (*Opts) CloneMessageVT added in v0.15.6

func (m *Opts) CloneMessageVT() proto.Message

func (*Opts) CloneVT added in v0.8.3

func (m *Opts) CloneVT() *Opts

func (*Opts) Descriptor deprecated

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

Deprecated: Use Opts.ProtoReflect.Descriptor instead.

func (*Opts) EqualMessageVT added in v0.15.6

func (this *Opts) EqualMessageVT(thatMsg proto.Message) bool

func (*Opts) EqualVT added in v0.3.0

func (this *Opts) EqualVT(that *Opts) bool

func (*Opts) GetBlockCompress

func (x *Opts) GetBlockCompress() blockcompress.BlockCompress

func (*Opts) GetBlockCrypt

func (x *Opts) GetBlockCrypt() blockcrypt.BlockCrypt

func (*Opts) GetDataShards

func (x *Opts) GetDataShards() uint32

func (*Opts) GetKcpMode

func (x *Opts) GetKcpMode() KCPMode

func (*Opts) GetMtu

func (x *Opts) GetMtu() uint32

func (*Opts) GetParityShards

func (x *Opts) GetParityShards() uint32

func (*Opts) GetStreamMuxer

func (x *Opts) GetStreamMuxer() StreamMuxer

func (*Opts) MarshalToSizedBufferVT added in v0.2.0

func (m *Opts) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Opts) MarshalToVT added in v0.2.0

func (m *Opts) MarshalToVT(dAtA []byte) (int, error)

func (*Opts) MarshalVT added in v0.2.0

func (m *Opts) MarshalVT() (dAtA []byte, err error)

func (*Opts) ProtoMessage

func (*Opts) ProtoMessage()

func (*Opts) ProtoReflect added in v0.2.0

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

func (*Opts) Reset

func (x *Opts) Reset()

func (*Opts) SizeVT added in v0.2.0

func (m *Opts) SizeVT() (n int)

func (*Opts) String

func (x *Opts) String() string

func (*Opts) UnmarshalVT added in v0.2.0

func (m *Opts) UnmarshalVT(dAtA []byte) error

type PacketBuffer

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

PacketBuffer implements a net.Conn backed by a packet buffer

func NewPacketBuffer

func NewPacketBuffer(
	ctx context.Context,
	writeFn func(data []byte) error,
) *PacketBuffer

func (*PacketBuffer) PushPacket

func (s *PacketBuffer) PushPacket(packet []byte)

PushPacket pushes a packet to the stream, dropping the oldest packet if necessary.

func (*PacketBuffer) Read

func (s *PacketBuffer) Read(b []byte) (n int, err error)

Read data from the stream.

func (*PacketBuffer) SetDeadline

func (s *PacketBuffer) SetDeadline(t time.Time) error

SetDeadline sets both read and write deadlines as defined by A zero time value disables the deadlines.

func (*PacketBuffer) SetReadDeadline

func (s *PacketBuffer) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline as defined by A zero time value disables the deadline.

func (*PacketBuffer) SetRemoteStreamID

func (s *PacketBuffer) SetRemoteStreamID(id uint32)

SetRemoteStreamID sets the remote stream ID varint trailer

func (*PacketBuffer) SetWriteDeadline

func (s *PacketBuffer) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline as defined by A zero time value disables the deadline.

func (*PacketBuffer) Write

func (s *PacketBuffer) Write(in []byte) (n int, err error)

Write data to the stream.

type PacketType

type PacketType int32

PacketType is a one-byte trailer indicating the type of packet.

const (
	PacketType_PacketType_HANDSHAKE  PacketType = 0
	PacketType_PacketType_RAW        PacketType = 1
	PacketType_PacketType_KCP_SMUX   PacketType = 2
	PacketType_PacketType_CLOSE_LINK PacketType = 3
)

func (PacketType) Descriptor added in v0.2.0

func (PacketType) Descriptor() protoreflect.EnumDescriptor

func (PacketType) Enum added in v0.2.0

func (x PacketType) Enum() *PacketType

func (PacketType) EnumDescriptor deprecated

func (PacketType) EnumDescriptor() ([]byte, []int)

Deprecated: Use PacketType.Descriptor instead.

func (PacketType) Number added in v0.2.0

func (x PacketType) Number() protoreflect.EnumNumber

func (PacketType) String

func (x PacketType) String() string

func (PacketType) Type added in v0.2.0

func (PacketType) Validate

func (t PacketType) Validate() error

Validate returns an error if the type is not valid.

type RawStreamAck

type RawStreamAck struct {

	// InitiatorStreamId is the stream ID the initiator wanted to use.
	InitiatorStreamId uint32 `protobuf:"varint,1,opt,name=initiator_stream_id,json=initiatorStreamId,proto3" json:"initiator_stream_id,omitempty"`
	// AckStreamId is the stream ID the responder wants to use.
	// Zero if the stream was rejected.
	AckStreamId uint32 `protobuf:"varint,2,opt,name=ack_stream_id,json=ackStreamId,proto3" json:"ack_stream_id,omitempty"`
	// AckError indicates an error establishing the stream, rejecting the stream.
	AckError string `protobuf:"bytes,3,opt,name=ack_error,json=ackError,proto3" json:"ack_error,omitempty"`
	// contains filtered or unexported fields
}

RawStreamAck is a coordination stream raw-stream acknowledge message.

func (*RawStreamAck) CloneMessageVT added in v0.15.6

func (m *RawStreamAck) CloneMessageVT() proto.Message

func (*RawStreamAck) CloneVT added in v0.8.3

func (m *RawStreamAck) CloneVT() *RawStreamAck

func (*RawStreamAck) Descriptor deprecated

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

Deprecated: Use RawStreamAck.ProtoReflect.Descriptor instead.

func (*RawStreamAck) EqualMessageVT added in v0.15.6

func (this *RawStreamAck) EqualMessageVT(thatMsg proto.Message) bool

func (*RawStreamAck) EqualVT added in v0.3.0

func (this *RawStreamAck) EqualVT(that *RawStreamAck) bool

func (*RawStreamAck) GetAckError

func (x *RawStreamAck) GetAckError() string

func (*RawStreamAck) GetAckStreamId

func (x *RawStreamAck) GetAckStreamId() uint32

func (*RawStreamAck) GetInitiatorStreamId

func (x *RawStreamAck) GetInitiatorStreamId() uint32

func (*RawStreamAck) MarshalToSizedBufferVT added in v0.2.0

func (m *RawStreamAck) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*RawStreamAck) MarshalToVT added in v0.2.0

func (m *RawStreamAck) MarshalToVT(dAtA []byte) (int, error)

func (*RawStreamAck) MarshalVT added in v0.2.0

func (m *RawStreamAck) MarshalVT() (dAtA []byte, err error)

func (*RawStreamAck) ProtoMessage

func (*RawStreamAck) ProtoMessage()

func (*RawStreamAck) ProtoReflect added in v0.2.0

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

func (*RawStreamAck) Reset

func (x *RawStreamAck) Reset()

func (*RawStreamAck) SizeVT added in v0.2.0

func (m *RawStreamAck) SizeVT() (n int)

func (*RawStreamAck) String

func (x *RawStreamAck) String() string

func (*RawStreamAck) UnmarshalVT added in v0.2.0

func (m *RawStreamAck) UnmarshalVT(dAtA []byte) error

func (*RawStreamAck) Validate

func (p *RawStreamAck) Validate() error

Validate validates the raw stream ack packet.

type RawStreamClose

type RawStreamClose struct {

	// StreamId is the stream ID the reciever indicated to use.
	StreamId uint32 `protobuf:"varint,1,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"`
	// CloseError indicates an error included with the stream close.
	CloseError string `protobuf:"bytes,2,opt,name=close_error,json=closeError,proto3" json:"close_error,omitempty"`
	// contains filtered or unexported fields
}

RawStreamClose indicates an intent to close a raw stream.

func (*RawStreamClose) CloneMessageVT added in v0.15.6

func (m *RawStreamClose) CloneMessageVT() proto.Message

func (*RawStreamClose) CloneVT added in v0.8.3

func (m *RawStreamClose) CloneVT() *RawStreamClose

func (*RawStreamClose) Descriptor deprecated

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

Deprecated: Use RawStreamClose.ProtoReflect.Descriptor instead.

func (*RawStreamClose) EqualMessageVT added in v0.15.6

func (this *RawStreamClose) EqualMessageVT(thatMsg proto.Message) bool

func (*RawStreamClose) EqualVT added in v0.3.0

func (this *RawStreamClose) EqualVT(that *RawStreamClose) bool

func (*RawStreamClose) GetCloseError

func (x *RawStreamClose) GetCloseError() string

func (*RawStreamClose) GetStreamId

func (x *RawStreamClose) GetStreamId() uint32

func (*RawStreamClose) MarshalToSizedBufferVT added in v0.2.0

func (m *RawStreamClose) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*RawStreamClose) MarshalToVT added in v0.2.0

func (m *RawStreamClose) MarshalToVT(dAtA []byte) (int, error)

func (*RawStreamClose) MarshalVT added in v0.2.0

func (m *RawStreamClose) MarshalVT() (dAtA []byte, err error)

func (*RawStreamClose) ProtoMessage

func (*RawStreamClose) ProtoMessage()

func (*RawStreamClose) ProtoReflect added in v0.2.0

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

func (*RawStreamClose) Reset

func (x *RawStreamClose) Reset()

func (*RawStreamClose) SizeVT added in v0.2.0

func (m *RawStreamClose) SizeVT() (n int)

func (*RawStreamClose) String

func (x *RawStreamClose) String() string

func (*RawStreamClose) UnmarshalVT added in v0.2.0

func (m *RawStreamClose) UnmarshalVT(dAtA []byte) error

type RawStreamEstablish

type RawStreamEstablish struct {

	// InitiatorStreamId is the stream ID the initiator wants to use.
	InitiatorStreamId uint32 `protobuf:"varint,1,opt,name=initiator_stream_id,json=initiatorStreamId,proto3" json:"initiator_stream_id,omitempty"`
	// contains filtered or unexported fields
}

RawStreamEstablish is a coordination stream raw-stream establish message.

func (*RawStreamEstablish) CloneMessageVT added in v0.15.6

func (m *RawStreamEstablish) CloneMessageVT() proto.Message

func (*RawStreamEstablish) CloneVT added in v0.8.3

func (m *RawStreamEstablish) CloneVT() *RawStreamEstablish

func (*RawStreamEstablish) Descriptor deprecated

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

Deprecated: Use RawStreamEstablish.ProtoReflect.Descriptor instead.

func (*RawStreamEstablish) EqualMessageVT added in v0.15.6

func (this *RawStreamEstablish) EqualMessageVT(thatMsg proto.Message) bool

func (*RawStreamEstablish) EqualVT added in v0.3.0

func (this *RawStreamEstablish) EqualVT(that *RawStreamEstablish) bool

func (*RawStreamEstablish) GetInitiatorStreamId

func (x *RawStreamEstablish) GetInitiatorStreamId() uint32

func (*RawStreamEstablish) MarshalToSizedBufferVT added in v0.2.0

func (m *RawStreamEstablish) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*RawStreamEstablish) MarshalToVT added in v0.2.0

func (m *RawStreamEstablish) MarshalToVT(dAtA []byte) (int, error)

func (*RawStreamEstablish) MarshalVT added in v0.2.0

func (m *RawStreamEstablish) MarshalVT() (dAtA []byte, err error)

func (*RawStreamEstablish) ProtoMessage

func (*RawStreamEstablish) ProtoMessage()

func (*RawStreamEstablish) ProtoReflect added in v0.2.0

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

func (*RawStreamEstablish) Reset

func (x *RawStreamEstablish) Reset()

func (*RawStreamEstablish) SizeVT added in v0.2.0

func (m *RawStreamEstablish) SizeVT() (n int)

func (*RawStreamEstablish) String

func (x *RawStreamEstablish) String() string

func (*RawStreamEstablish) UnmarshalVT added in v0.2.0

func (m *RawStreamEstablish) UnmarshalVT(dAtA []byte) error

type StreamMuxer

type StreamMuxer int32

StreamMuxer sets the type of stream muxer to use.

const (
	// StreamMuxer_UNKNOWN defaults to StreamMuxer_XTACI_SMUX
	StreamMuxer_StreamMuxer_UNKNOWN StreamMuxer = 0
	// StreamMuxer_XTACI_SMUX is the xtaci/smux muxer.
	StreamMuxer_StreamMuxer_XTACI_SMUX StreamMuxer = 1
	// StreamMuxer_YAMUX is the yamux muxer.
	StreamMuxer_StreamMuxer_YAMUX StreamMuxer = 2
)

func (StreamMuxer) Descriptor added in v0.2.0

func (StreamMuxer) Enum added in v0.2.0

func (x StreamMuxer) Enum() *StreamMuxer

func (StreamMuxer) EnumDescriptor deprecated

func (StreamMuxer) EnumDescriptor() ([]byte, []int)

Deprecated: Use StreamMuxer.Descriptor instead.

func (StreamMuxer) Number added in v0.2.0

func (x StreamMuxer) Number() protoreflect.EnumNumber

func (StreamMuxer) String

func (x StreamMuxer) String() string

func (StreamMuxer) Type added in v0.2.0

type Transport

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

Transport is a net.PacketConn based transport. The remote address string is used as an identifying key for sessions. It uses KCP to upgrade remote connections to reliable streams.

func New

func New(
	le *logrus.Entry,
	uuid uint64,
	pc net.PacketConn,
	pKey crypto.PrivKey,
	addrParser func(addr string) (net.Addr, error),
	tc transport.TransportHandler,
	opts *Opts,
) *Transport

New builds a new packet-conn based transport, listening on the addr.

func (*Transport) Close

func (u *Transport) Close() error

Close closes the transport.

func (*Transport) DialPeer

func (u *Transport) DialPeer(ctx context.Context, peerID peer.ID, as string) (bool, error)

DialPeer dials a peer given an address. The yielded link should be emitted to the transport handler. DialPeer should return nil if the link was established. DialPeer will then not be called again for the same peer ID and address tuple until the yielded link is lost.

func (*Transport) Execute

func (u *Transport) Execute(ctx context.Context) error

Execute processes the transport, emitting events to the handler. Fatal errors are returned.

func (*Transport) GetPeerID

func (u *Transport) GetPeerID() peer.ID

GetPeerID returns the node peer id.

func (*Transport) GetUUID

func (u *Transport) GetUUID() uint64

GetUUID returns a host-unique ID for this transport.

func (*Transport) HandleDirective

func (c *Transport) HandleDirective(ctx context.Context, di directive.Instance) (directive.Resolver, error)

HandleDirective asks if the handler can resolve the directive. If it can, it returns a resolver. If not, returns nil. Any unexpected errors are returned for logging. It is safe to add a reference to the directive during this call.

func (*Transport) LocalAddr

func (u *Transport) LocalAddr() net.Addr

LocalAddr returns the local address.

Jump to

Keyboard shortcuts

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