protocol

package
v0.0.0-...-d78c878 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const MaxPacket = 1 << 21

Variables

This section is empty.

Functions

func GetBuffer

func GetBuffer(size int) *bytes.Buffer

func PutBuffer

func PutBuffer(b *bytes.Buffer)

func VarIntSize

func VarIntSize[T int | int32](n T) (i int)

VarIntSize returns the number of bytes n takes up

Types

type Decoder

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

Decoder decodes packet headers and returns the payload

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) DecodePacket

func (dec *Decoder) DecodePacket() ([]byte, error)

DecodePacket reads from the underlying reader and returns a packet's payload. The slice returned is valid until the next call.

func (*Decoder) EnableDecompression

func (dec *Decoder) EnableDecompression()

EnableDecompression Enables zlib decompression

func (*Decoder) EnableDecryption

func (dec *Decoder) EnableDecryption(block cipher.Block, iv []byte)

type Encoder

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

Encoder writes packet payload with the header

func NewEncoder

func NewEncoder(b *bytes.Buffer) *Encoder

func (*Encoder) EnableCompression

func (enc *Encoder) EnableCompression(threshold int)

func (*Encoder) EnableEncryption

func (enc *Encoder) EnableEncryption(block cipher.Block, iv []byte)

func (*Encoder) EncodePacket

func (enc *Encoder) EncodePacket(data []byte) error

func (*Encoder) Flush

func (enc *Encoder) Flush() []byte

type PlayerListUpdateAction

type PlayerListUpdateAction byte
const (
	AddPlayer PlayerListUpdateAction = 1 << iota
	InitializeChat
	UpdateGameMode
	UpdateListed
	UpdateLatency
	UpdateDisplayName
)

type Reader

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

Reader wraps bufio.Reader and adds decryption functionality.

func NewReader

func NewReader(r io.Reader) *Reader

func (*Reader) EnableDecryption

func (r *Reader) EnableDecryption(block cipher.Block, iv []byte)

func (*Reader) Next

func (r *Reader) Next(n int) ([]byte, error)

Next returns the next n bytes in the buffer and advances the reader. If n is bigger than the buffer then it returns bufio.ErrBufferFull without data and won't advance the reader.

func (*Reader) Read

func (r *Reader) Read(p []byte) (int, error)

func (*Reader) ReadByte

func (r *Reader) ReadByte() (byte, error)

func (*Reader) ReadVarInt

func (r *Reader) ReadVarInt() (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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