kcp

package
v1.7.10 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = (&Options{
	Key:          "it's a secrecy",
	Crypt:        "",
	Mode:         "fast",
	MTU:          1350,
	SndWnd:       32,
	RcvWnd:       32,
	DataShard:    0,
	ParityShard:  0,
	DSCP:         0,
	AckNodelay:   false,
	NoDelay:      0,
	Interval:     30,
	Resend:       2,
	NoCongestion: 1,
	SockBuf:      4194304,
}).Apply()

DefaultOptions default kcp options

Functions

func New

func New() transport.Factory

New a kcp transport factory

func WithOptions

func WithOptions(option *Options) transport.Option

WithOptions to wrap the kcp options

Types

type Options

type Options struct {
	Key          string         `json:"key"`
	Crypt        string         `json:"crypt"`              // aes, aes-128, aes-192, salsa20, blowfish, twofish, cast5, 3des, tea, xtea, xor, sm4, none
	Mode         string         `json:"mode"`               // fast3, fast2, fast, normal, manual
	MTU          int            `json:"mtu,string"`         // set maximum transmission unit for UDP packets
	SndWnd       int            `json:"sndwnd,string"`      // set send window size(num of packets)
	RcvWnd       int            `json:"rcvwnd,string"`      // set receive window size(num of packets)
	DataShard    int            `json:"datashard,string"`   // set reed-solomon erasure coding - datashard
	ParityShard  int            `json:"parityshard,string"` // set reed-solomon erasure coding - parityshard
	DSCP         int            `json:"dscp,string"`        // set DSCP(6bit)
	AckNodelay   bool           `json:"acknodelay,string"`  // flush ack immediately when a packet is received
	NoDelay      int            `json:"nodelay,string"`
	Interval     int            `json:"interval,string"`
	Resend       int            `json:"resend,string"`
	NoCongestion int            `json:"nc,string"`
	SockBuf      int            `json:"sockbuf,string"` // per-socket buffer in bytes
	Block        kcp.BlockCrypt `json:"-"`
}

Options to define the kcp

func FromContext

func FromContext(ctx context.Context, def *Options) *Options

FromContext to unwrap the kcp options

func (*Options) Apply

func (o *Options) Apply() *Options

Apply the kcp mode & encryption options

Jump to

Keyboard shortcuts

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