packet

package
v0.0.0-...-745f9b5 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadBytes

func ReadBytes(r DecodeReader) ([]byte, error)

ReadBytes decodes a byte stream and cuts the first Packet as a byte array out

func ReadNBytes

func ReadNBytes(r DecodeReader, n int) (bs []byte, err error)

ReadNBytes read N bytes from bytes.Reader

func Scan

func Scan(r DecodeReader, fields ...FieldDecoder) error

Scan decodes a byte stream into fields

Types

type Angle

type Angle = UnsignedByte

Angle is rotation angle in steps of 1/256 of a full turn

type Boolean

type Boolean bool

Boolean of True is encoded as 0x01, false as 0x00.

func (*Boolean) Decode

func (b *Boolean) Decode(r DecodeReader) error

Decode a Boolean

func (Boolean) Encode

func (b Boolean) Encode() []byte

Encode a Boolean

type Byte

type Byte int8

Byte is signed 8-bit integer, two's complement

func (*Byte) Decode

func (b *Byte) Decode(r DecodeReader) error

Decode a Byte

func (Byte) Encode

func (b Byte) Encode() []byte

Encode a Byte

type ByteArray

type ByteArray []byte

ByteArray is []byte with prefix VarInt as length

func (*ByteArray) Decode

func (b *ByteArray) Decode(r DecodeReader) error

Decode a ByteArray

func (ByteArray) Encode

func (b ByteArray) Encode() []byte

Encode a ByteArray

type Chat

type Chat = String

Chat is encoded as a String with max length of 32767.

type DecodeReader

type DecodeReader interface {
	io.ByteReader
	io.Reader
}

DecodeReader is both io.Reader and io.ByteReader

type Double

type Double float64

A Double is a double-precision 64-bit IEEE 754 floating point number

func (*Double) Decode

func (d *Double) Decode(r DecodeReader) error

Decode a Double

func (Double) Encode

func (d Double) Encode() []byte

Encode a Double

type Field

type Field interface {
	FieldEncoder
	FieldDecoder
}

A Field is both FieldEncoder and FieldDecoder

type FieldDecoder

type FieldDecoder interface {
	Decode(r DecodeReader) error
}

A FieldDecoder can Decode from minecraft protocol

type FieldEncoder

type FieldEncoder interface {
	Encode() []byte
}

A FieldEncoder can be encode as minecraft protocol used.

type Float

type Float float32

A Float is a single-precision 32-bit IEEE 754 floating point number

func (*Float) Decode

func (f *Float) Decode(r DecodeReader) error

Decode a Float

func (Float) Encode

func (f Float) Encode() []byte

Encode a Float

type Identifier

type Identifier = String

Identifier is encoded as a String with max length of 32767.

type IdentifierArray

type IdentifierArray []Identifier

IdentifierArray is a slice of Identifier

func (*IdentifierArray) Decode

func (ia *IdentifierArray) Decode(r DecodeReader) error

Decode a IdentifierArray

func (IdentifierArray) Encode

func (ia IdentifierArray) Encode() []byte

Encode a IdentifierArray

type Int

type Int int32

Int is signed 32-bit integer, two's complement

func (*Int) Decode

func (i *Int) Decode(r DecodeReader) error

Decode a Int

func (Int) Encode

func (i Int) Encode() []byte

Encode a Int

type Long

type Long int64

Long is signed 64-bit integer, two's complement

func (*Long) Decode

func (l *Long) Decode(r DecodeReader) error

Decode a Long

func (Long) Encode

func (l Long) Encode() []byte

Encode a Long

type NBT

type NBT struct {
	V interface{}
}

NBT encode a value as Named Binary Tag

func (NBT) Decode

func (n NBT) Decode(r DecodeReader) error

Decode a NBT

func (NBT) Encode

func (n NBT) Encode() []byte

Encode a NBT

type OptionalByteArray

type OptionalByteArray []byte

OptionalByteArray is []byte without prefix VarInt as length

func (*OptionalByteArray) Decode

func (b *OptionalByteArray) Decode(r DecodeReader) error

Decode a OptionalByteArray

func (OptionalByteArray) Encode

func (b OptionalByteArray) Encode() []byte

Encode a OptionalByteArray

type Packet

type Packet struct {
	ID   byte
	Data []byte
}

A Packet is the raw representation of message that is send between the client and the server

func Marshal

func Marshal(ID byte, fields ...FieldEncoder) Packet

Marshal transforms an ID and Fields into a Packet

func Peek

func Peek(p PeekReader, isZlib bool) (Packet, error)

Peek decodes and decompresses a byte stream and peeks the first Packet

func Read

func Read(r DecodeReader, isZlib bool) (Packet, error)

Read decodes and decompresses a byte stream and cuts the first Packet out

func Unmarshal

func Unmarshal(data []byte) (Packet, error)

Unmarshal decodes and decompresses a byte array into a Packet

func (*Packet) Marshal

func (pk *Packet) Marshal(threshold int) ([]byte, error)

Marshal encodes the packet and compresses it if it is larger then the given threshold

func (Packet) Scan

func (pk Packet) Scan(fields ...FieldDecoder) error

Scan decodes and copies the Packet data into the fields

type PeekReader

type PeekReader interface {
	Peek(n int) ([]byte, error)
	io.Reader
}

type Position

type Position struct {
	X, Y, Z int
}

Position x as a 26-bit integer, followed by y as a 12-bit integer, followed by z as a 26-bit integer (all signed, two's complement)

func (*Position) Decode

func (p *Position) Decode(r DecodeReader) error

Decode a Position

func (Position) Encode

func (p Position) Encode() []byte

Encode a Position

type Short

type Short int16

Short is signed 16-bit integer, two's complement

func (*Short) Decode

func (s *Short) Decode(r DecodeReader) error

Decode a Short

func (Short) Encode

func (s Short) Encode() []byte

Encode a Signed Short

type String

type String string

String is sequence of Unicode scalar values

func (*String) Decode

func (s *String) Decode(r DecodeReader) error

Decode a String

func (String) Encode

func (s String) Encode() (p []byte)

Encode a String

type UUID

type UUID uuid.UUID

UUID encoded as an unsigned 128-bit integer

func (*UUID) Decode

func (u *UUID) Decode(r DecodeReader) error

Decode a UUID

func (UUID) Encode

func (u UUID) Encode() []byte

Encode a UUID

type UnsignedByte

type UnsignedByte uint8

UnsignedByte is unsigned 8-bit integer

func (*UnsignedByte) Decode

func (ub *UnsignedByte) Decode(r DecodeReader) error

Decode a UnsignedByte

func (UnsignedByte) Encode

func (ub UnsignedByte) Encode() []byte

Encode a UnsignedByte

type UnsignedShort

type UnsignedShort uint16

UnsignedShort is unsigned 16-bit integer

func (*UnsignedShort) Decode

func (us *UnsignedShort) Decode(r DecodeReader) error

Decode a UnsignedShort

func (UnsignedShort) Encode

func (us UnsignedShort) Encode() []byte

Encode a Unsigned Short

type VarInt

type VarInt int32

VarInt is variable-length data encoding a two's complement signed 32-bit integer

func (*VarInt) Decode

func (v *VarInt) Decode(r DecodeReader) error

Decode a VarInt

func (VarInt) Encode

func (v VarInt) Encode() (vi []byte)

Encode a VarInt

type VarIntArray

type VarIntArray []VarInt

VarIntArray is a slice of VarInt

func (*VarIntArray) Decode

func (ia *VarIntArray) Decode(r DecodeReader) error

Decode a VarIntArray

func (VarIntArray) Encode

func (ia VarIntArray) Encode() []byte

Encode a VarIntArray

type VarLong

type VarLong int64

VarLong is variable-length data encoding a two's complement signed 64-bit integer

func (*VarLong) Decode

func (v *VarLong) Decode(r DecodeReader) error

Decode a VarLong

func (VarLong) Encode

func (v VarLong) Encode() (vi []byte)

Encode a VarLong

Directories

Path Synopsis
All credits go to Ilmari Karonen Source: https://stackoverflow.com/questions/23897809/different-results-in-go-and-pycrypto-when-using-aes-cfb/37234233#37234233
All credits go to Ilmari Karonen Source: https://stackoverflow.com/questions/23897809/different-results-in-go-and-pycrypto-when-using-aes-cfb/37234233#37234233

Jump to

Keyboard shortcuts

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