network

package
v0.0.0-...-79a9f7e Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestTypeLogin  = 0x0A
	RequestTypeSimple = 0x0B
)

Variables

View Source
var (
	ErrSessionExpired    = errors.New("session expired")
	ErrPacketDropped     = errors.New("packet dropped")
	ErrInvalidPacketType = errors.New("invalid packet type")
)
View Source
var ErrConnectionClosed = errors.New("connection closed")
View Source
var WhiteListCommands = `` /* 2561-byte string literal not displayed */

Functions

This section is empty.

Types

type EncryptType

type EncryptType uint32
const (
	EncryptTypeNoEncrypt EncryptType = iota // 0x00
	EncryptTypeD2Key                        // 0x01
	EncryptTypeEmptyKey                     // 0x02
)

type Packet

type Packet struct {
	SequenceId  uint16
	CommandName string
	Payload     []byte
	Params      RequestParams
}

type Request

type Request struct {
	Type        RequestType
	EncryptType EncryptType
	SequenceID  int32
	Uin         int64
	CommandName string
	Body        []byte
}

type RequestParams

type RequestParams map[string]any

func (RequestParams) Bool

func (p RequestParams) Bool(k string) bool

func (RequestParams) Int32

func (p RequestParams) Int32(k string) int32

type RequestType

type RequestType uint32

type Response

type Response struct {
	Type        RequestType
	EncryptType EncryptType
	SequenceID  int32
	Uin         int64
	CommandName string
	Body        []byte

	Message string
}

type TCPClient

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

func (*TCPClient) Close

func (t *TCPClient) Close()

func (*TCPClient) Connect

func (t *TCPClient) Connect(addr string) error

func (*TCPClient) PlannedDisconnect

func (t *TCPClient) PlannedDisconnect(f func(*TCPClient))

PlannedDisconnect 预料中的断开连接 如调用 Close() Connect()

func (*TCPClient) ReadBytes

func (t *TCPClient) ReadBytes(len int) ([]byte, error)

func (*TCPClient) ReadInt32

func (t *TCPClient) ReadInt32() (int32, error)

func (*TCPClient) UnexpectedDisconnect

func (t *TCPClient) UnexpectedDisconnect(f func(*TCPClient, error))

UnexpectedDisconnect 未预料的断开连接

func (*TCPClient) Write

func (t *TCPClient) Write(buf []byte) error

type Transport

type Transport struct {
	Sig     *auth.SigInfo
	Version *auth.AppVersion
	Device  *auth.Device
}

Transport is a network transport.

func (*Transport) PackPacket

func (t *Transport) PackPacket(req *Request) []byte

PackPacket packs a packet.

func (*Transport) PackSecSign

func (t *Transport) PackSecSign(req *Request) []byte

func (*Transport) ReadResponse

func (t *Transport) ReadResponse(head []byte) (*Response, error)

Jump to

Keyboard shortcuts

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