battleye

package
v0.0.0-...-72f5b8e Latest Latest
Warning

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

Go to latest
Published: May 20, 2018 License: GPL-3.0 Imports: 5 Imported by: 3

Documentation

Overview

Package battleye is implementing the BattlEye Protocol(https://www.battleye.com/downloads/BERConProtocol.txt) for use in other projects.

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrUnknownPacketType .
	ErrUnknownPacketType = errors.New("received unknown packet type")
	//ErrInvalidLoginPacket .
	ErrInvalidLoginPacket = errors.New("received invalid login packet")
	//ErrInvalidLogin .
	ErrInvalidLogin = errors.New("server refused login")
	//ErrInvalidChecksum .
	ErrInvalidChecksum = errors.New("received invalid packet checksum")
	//ErrInvalidSizeNoHeader .
	ErrInvalidSizeNoHeader = errors.New("invalid packet size, no header found")
	//ErrInvalidSizeNoSequence .
	ErrInvalidSizeNoSequence = errors.New("invalid packet size, no sequence found")
	//ErrInvalidHeaderSize .
	ErrInvalidHeaderSize = errors.New("invalid packet header size")
	//ErrInvalidHeaderSyntax .
	ErrInvalidHeaderSyntax = errors.New("invalid packet header syntax")
	//ErrInvalidHeaderEnd .
	ErrInvalidHeaderEnd = errors.New("invalid packet header end")
	//ErrInvalidSize .
	ErrInvalidSize = errors.New("packet size too small")
	//ErrUnknownEventType .
	ErrUnknownEventType = errors.New("unknown event type")
	//ErrUnableToParse .
	ErrUnableToParse = errors.New("unable to parse")
)

Functions

This section is empty.

Types

type Packet

type Packet []byte

Packet is the real data sent between server and client

func BuildLoginResponse

func BuildLoginResponse(t Type) Packet

BuildLoginResponse for testing

type Protocol

type Protocol interface {
	//BuildPacket creates a new packet with data and type
	BuildPacket([]byte, Type) Packet

	//BuildLoginPacket creates a login packet with password
	BuildLoginPacket(string) Packet

	//BuildCmdPacket creates a packet with cmd and seq
	BuildCmdPacket([]byte, Sequence) Packet

	//BuildKeepAlivePacket creates a keepAlivePacket with seq
	BuildKeepAlivePacket(Sequence) Packet

	//BuildMsgAckPacket creates a server message packet with seq
	BuildMsgAckPacket(Sequence) Packet

	// Verify if the packet is valid
	Verify(Packet) error

	// Sequence extracts the seq number from a packet
	Sequence(Packet) (Sequence, error)

	// Type determines the kind of response from a packet
	Type(Packet) (Type, error)

	// Data returns the actual data inside the packet
	Data(Packet) ([]byte, error)

	// VerifyLogin returns nil on successful login
	// and a respective error on failed login
	VerifyLogin(Packet) error

	// Multi checks whether a packet is part of a multiPacketResponse
	// Returns: packetCount, currentPacket and isSingle
	Multi(Packet) (byte, byte, bool)
}

Protocol offers an interface representation for BattlEye communications

func New

func New() Protocol

New provides a real and tested implementation of Protocol

type Sequence

type Sequence uint32

Sequence is used by BattlEye to keep track of transactions

type Type

type Type byte

Type is the representation of a packets type

var Command Type = 0x01

Command is the default packet type on commands

var Login Type = 0x00

Login is the type used when sending logins to the server

var LoginFail Type = 0x00

LoginFail is being returned by the server on invalid credentials

var LoginOk Type = 0x01

LoginOk is being returned by the server on successful login

var MultiCommand Type = 0x00

MultiCommand is the packet type when the received packet is not complete yet and will be received in multiple pieces

var ServerMessage Type = 0x02

ServerMessage is the packet type when the server is sending events to clients

Jump to

Keyboard shortcuts

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