kcpwrapper

package module
v0.0.0-...-c12d7c1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Overview

Package kcpwrapper provides a wrapper around kcp that allows the use of regular net interfaces like dialing and listening. It is built to be compatible with servers and clients running github.com/xtaci/kcptun and duplicates some of the code from that project.

Index

Constants

View Source
const (
	// SALT is use for pbkdf2 key expansion
	SALT = "kcp-go"
)

Variables

This section is empty.

Functions

func Dialer

func Dialer(cfg *DialerConfig, onConn func(net.Conn) net.Conn) func(ctx context.Context, addr string) (net.Conn, error)

Dialer creates a new dialer function

func Listen

func Listen(cfg *ListenerConfig, onConn func(net.Conn) net.Conn) (net.Listener, error)

Listen listens with the given ListenerConfig. onConn is an optional function that can modify the underlying KCP connections accepted from the listener.

Types

type CommonConfig

type CommonConfig struct {
	Key          string `json:"key"`
	Crypt        string `json:"crypt"`
	Mode         string `json:"mode"`
	MTU          int    `json:"mtu"`
	SndWnd       int    `json:"sndwnd"`
	RcvWnd       int    `json:"rcvwnd"`
	DataShard    int    `json:"datashard"`
	ParityShard  int    `json:"parityshard"`
	DSCP         int    `json:"dscp"`
	NoComp       bool   `json:"nocomp"`
	AckNodelay   bool   `json:"acknodelay"`
	NoDelay      int    `json:"nodelay"`
	Interval     int    `json:"interval"`
	Resend       int    `json:"resend"`
	NoCongestion int    `json:"nc"`
	SockBuf      int    `json:"sockbuf"`
	KeepAlive    int    `json:"keepalive"`
	// contains filtered or unexported fields
}

CommonConfig contains common configuration parameters across dialers and listeners.

type DialerConfig

type DialerConfig struct {
	CommonConfig `mapstructure:",squash"`
	Conn         int `json:"conn"`
	AutoExpire   int `json:"autoexpire"`
	ScavengeTTL  int `json:"scavengettl"`
}

DialerConfig configures dialing

type ListenerConfig

type ListenerConfig struct {
	CommonConfig
	Listen string `json:"listen"`
}

ListenerConfig configures listening

Jump to

Keyboard shortcuts

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