tools

package
v0.0.0-...-74dbf8d Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BytesPool = sync.Pool{
	New: func() interface{} {
		var buffer = bytes.NewBuffer(make([]byte, 2048))
		return buffer
	},
}

BytesPool 字节数据流 池化

View Source
var TomlConfig = &tomlConfig{}

TomlConfig 配置

Functions

func Base64SuccMessage

func Base64SuccMessage() []byte

func CalReadData

func CalReadData(readLen int, buf []byte, temp []byte) (int32, []byte, []byte)

func CalSendByteData

func CalSendByteData(writeData []byte) []byte

func CalSendData

func CalSendData(writeData string) []byte

func CommonInit

func CommonInit()

CommonInit 初始化 统一的配置

func Debug

func Debug(args ...interface{})

func Error

func Error(args ...interface{})

func Handle

func Handle(conn net.Conn, agent net.Conn, gate *Gate)

Handle 客户端请求处理

func HandlerShake

func HandlerShake(conn net.Conn, dialTimeout time.Duration, conType ConnectType) (net.Conn, error)

HandlerShake 握手

func Info

func Info(args ...interface{})

func InitConfig

func InitConfig()

InitConfig 初始化配置

func InitLog

func InitLog(logPath string, errorPath string)

func InitLogSimple

func InitLogSimple()

func WsHandle

func WsHandle(conn net.Conn, agent net.Conn, gate *Gate)

WsHandle ws 客户端请求处理

func WsHandshake

func WsHandshake(conn net.Conn, dialTimeout time.Duration) (net.Conn, error)

WsHandshake 客户端握手 websocket

Types

type CommonConfig

type CommonConfig struct {
	DialRetry          int    `toml:"dial_retry"`
	HeaderIdentify     string `toml:"header_identify"`
	SuccessRespMessage string `toml:"success_resp_message"`
	ConnectTimeout     int64  `toml:"connect_timeout"`
	KcpIs              int64  `toml:"connect_timeout"`
	KcpReciprocity     bool   `toml:"kcp_reciprocity"`
}

type ConnectType

type ConnectType int
const (
	CONNECT_TYPE_TCP ConnectType = 0
	CONNECT_TYPE_KCP ConnectType = 1
	CONNECT_TYPE_WS  ConnectType = 2
)

type Gate

type Gate struct {
	Port        int  `toml:"port"`
	Enabled     bool `toml:"enabled"`
	DialTimeout int  `toml:"dial_timeout"`
	ZeroCopy    bool `toml:"zero_copy"`
}

Gate 配置

type IKeyIdentify

type IKeyIdentify interface {
	// contains filtered or unexported methods
}

IKeyIdentify 接口

type IpHostIdentify

type IpHostIdentify struct {
}

IpHostIdentify ip:port

type JwtKeyIdentify

type JwtKeyIdentify struct {
}

JwtKeyIdentify jwt token

Jump to

Keyboard shortcuts

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