Documentation ¶
Index ¶
- Constants
- Variables
- func Clen(n []byte) int
- func NewServersMapFromList(input []string) map[string]*Server
- func ReadCString(input []byte) string
- func ReadPascalString(input []byte) string
- func ReadPascalStringStream(input []byte) (string, []byte)
- func WriteCString(input string) []byte
- func WritePascalString(input string) ([]byte, error)
- type Options
- type Packet
- type PacketType
- type Server
Constants ¶
View Source
const HeaderSize = 8
View Source
const MaxDataSize = MaxPacketSize - HeaderSize
View Source
const MaxPacketSize = 1500 // standard packet MTU
View Source
const RequestAllPackets = 0xff
View Source
const Version = 0x10
View Source
const VersionExt = 0x69
Variables ¶
View Source
var ErrorEmptyPacket = errors.New("empty packet received")
View Source
var (
ErrorPascalStringTooLong = errors.New("pascal string too long")
)
View Source
var ErrorUnknownPacketVersion = errors.New("unknown packet version")
Functions ¶
func Clen ¶
Clen returns the position of the first null byte in a given byte slice for null-terminated c strings, this returns the length of the string function was yanked from a golang stdlib private method.
func NewServersMapFromList ¶ added in v1.2.0
func ReadCString ¶ added in v1.2.0
func ReadPascalString ¶ added in v1.2.0
func ReadPascalStringStream ¶ added in v1.2.0
func WriteCString ¶ added in v1.2.0
func WritePascalString ¶ added in v1.2.0
Types ¶
type Packet ¶
type Packet struct { Version byte Type PacketType Number byte // packet number out of total; starts at 1 Total byte // total packets of info Key uint16 // used for verification and (transaction) id purposes ID uint16 // master server id (read from config file) Data []byte // MaxSize = (MaxPacketSize - HeaderSize) // implements encoding.BinaryMarshaler encoding.BinaryUnmarshaler fmt.Stringer }
func NewPacketWithData ¶ added in v1.2.0
func (*Packet) MarshalBinary ¶
func (*Packet) UnmarshalBinary ¶
type PacketType ¶
type PacketType int
const ( PingInfoQuery PacketType = iota + 0x03 PingInfoResponse MasterServerHeartbeat MasterServerList GameInfoQuery GameInfoResponse )
func (PacketType) String ¶
func (p PacketType) String() string
Click to show internal directories.
Click to hide internal directories.