core

package
v0.0.0-...-2a093ab Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderSize  = 2
	MaxBodySize = 4 * 1024 * 1024
)

Variables

This section is empty.

Functions

func ListenAndServeTcp

func ListenAndServeTcp(addrStr string, handler func(net.Conn), async bool, certs ...tls.Certificate) error

func NewRWSession

func NewRWSession(ph PacketHandler) *rwSession

Types

type BytesPacket

type BytesPacket []byte

func (BytesPacket) Bytes

func (p BytesPacket) Bytes() []byte

func (BytesPacket) Len

func (p BytesPacket) Len() int

type DecryptFunc

type DecryptFunc func(dst, src []byte)

type EncryptFunc

type EncryptFunc func(dst, src []byte)

type Packet

type Packet interface {
	Len() int
	Bytes() []byte
}

type PacketHandler

type PacketHandler func(b []byte)

type RWSession

type RWSession interface {
	// Conn return the real connection
	// of the current client
	Conn() net.Conn

	// Send send the packet
	Send(p Packet)

	// SetCryptFunc set crypt function
	// if not set crypt will use default crypt
	SetEncryptFunc(encrypt EncryptFunc)

	// SetDecryptFunc set decrypt function
	// if not set will use default decrypt
	SetDecryptFunc(decrypt DecryptFunc)

	// Run start read write session
	//
	// the nil val of start/end the service will
	// not notify when service start or end
	Run(start, end func())
}

Jump to

Keyboard shortcuts

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