raknet

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	PacketRPC       uint8 = 20
	PacketTimestamp uint8 = 40
)
View Source
const (
	PacketConnectionAccepted uint8 = 34
)

Variables

View Source
var (
	ErrClosed          = errors.New("raknet: connection closed")
	ErrQueueFull       = errors.New("raknet: queue is full")
	ErrHandshake       = errors.New("raknet: handshake failed")
	ErrAttemptFailed   = errors.New("raknet: connection attempt failed")
	ErrServerFull      = errors.New("raknet: server is full")
	ErrServerClosed    = errors.New("raknet: server closed the connection")
	ErrConnectionLost  = errors.New("raknet: connection lost")
	ErrEncryption      = errors.New("raknet: failed to initialize encryption")
	ErrBanned          = errors.New("raknet: connection banned")
	ErrInvalidPassword = errors.New("raknet: invalid password")
)
View Source
var ErrEndOfBitStream = errors.New("raknet bitstream: insufficient data")
View Source
var ErrInvalidFrame = errors.New("raknet: invalid reliability frame")
View Source
var ErrNotRPC = errors.New("raknet: packet is not an RPC")

Functions

func DecodeDatagram

func DecodeDatagram(data []byte) ([]Range, []Frame, error)

func EncodeDatagram

func EncodeDatagram(acks []Range, frames []Frame) ([]byte, error)

func EncodeFrame

func EncodeFrame(f Frame) ([]byte, int, error)

func EncodeRPC

func EncodeRPC(id uint8, payload []byte, payloadBits int) []byte

Types

type Conn

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

func Dial

func Dial(ctx context.Context, address, password string) (*Conn, error)

func (*Conn) AcceptedPacket

func (c *Conn) AcceptedPacket() []byte

func (*Conn) Close

func (c *Conn) Close() error

Close mirrors RakPeer::Disconnect(500) from the native SA-MP client. The network loop owns the UDP socket and must send the reliable ordered ID_DISCONNECTION_NOTIFICATION before it exits; closing the socket first is indistinguishable from a timeout to the server.

func (*Conn) Read

func (c *Conn) Read(ctx context.Context) ([]byte, error)

func (*Conn) Write

func (c *Conn) Write(ctx context.Context, payload []byte, reliability Reliability) error

func (*Conn) WriteChannel

func (c *Conn) WriteChannel(ctx context.Context, payload []byte, reliability Reliability, channel uint8) error

type Frame

type Frame struct {
	MessageNumber   uint16
	Reliability     Reliability
	OrderingChannel uint8
	OrderingIndex   uint16
	Split           *Split
	Payload         []byte
	PayloadBits     int
}

func DecodeFrame

func DecodeFrame(r *Reader) (Frame, error)

type RPC

type RPC struct {
	ID          uint8
	Payload     []byte
	PayloadBits int
}

func DecodeRPC

func DecodeRPC(packet []byte) (RPC, error)

type Range

type Range struct{ Min, Max uint16 }

type Reader

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

func NewReader

func NewReader(data []byte) *Reader

func NewReaderBits

func NewReaderBits(data []byte, bits int) *Reader

func (*Reader) Align

func (r *Reader) Align() error

func (*Reader) Bit

func (r *Reader) Bit() (bool, error)

func (*Reader) Bits

func (r *Reader) Bits(count int, right bool) ([]byte, error)

func (*Reader) CompressedUint16

func (r *Reader) CompressedUint16() (uint16, error)

func (*Reader) CompressedUint32

func (r *Reader) CompressedUint32() (uint32, error)

func (*Reader) Float32

func (r *Reader) Float32() (float32, error)

func (*Reader) Int16

func (r *Reader) Int16() (int16, error)

func (*Reader) Remaining

func (r *Reader) Remaining() int

func (*Reader) String8

func (r *Reader) String8() (string, error)

func (*Reader) Uint8

func (r *Reader) Uint8() (uint8, error)

func (*Reader) Uint16

func (r *Reader) Uint16() (uint16, error)

func (*Reader) Uint32

func (r *Reader) Uint32() (uint32, error)

type Reliability

type Reliability uint8
const (
	Unreliable Reliability = 6 + iota
	UnreliableSequenced
	Reliable
	ReliableOrdered
	ReliableSequenced
)

type Split

type Split struct {
	ID           uint16
	Index, Count uint32
}

type Writer

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

func (*Writer) Align

func (w *Writer) Align()

func (*Writer) Bit

func (w *Writer) Bit(v bool)

func (*Writer) Bits

func (w *Writer) Bits(data []byte, count int, right bool)

func (*Writer) Bytes

func (w *Writer) Bytes() []byte

func (*Writer) CompressedUint16

func (w *Writer) CompressedUint16(v uint16)

func (*Writer) CompressedUint32

func (w *Writer) CompressedUint32(v uint32)

func (*Writer) Float32

func (w *Writer) Float32(v float32)

func (*Writer) Int16

func (w *Writer) Int16(v int16)

func (*Writer) LenBits

func (w *Writer) LenBits() int

func (*Writer) String8

func (w *Writer) String8(v string)

func (*Writer) Uint8

func (w *Writer) Uint8(v uint8)

func (*Writer) Uint16

func (w *Writer) Uint16(v uint16)

func (*Writer) Uint32

func (w *Writer) Uint32(v uint32)

Jump to

Keyboard shortcuts

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