Documentation ¶
Index ¶
- Constants
- Variables
- func Clen(n []byte) (i int)
- func ReadCString(input []byte) string
- func ReadPascalString(input []byte) string
- func ReadPascalStringStream(input []byte) (string, []byte)
- func WriteCString(input string) (output []byte)
- func WritePascalString(input string) ([]byte, error)
- type GameInfo
- type Master
- func (m *Master) GeneratePackets(options *Options, key uint16, laddr net.Addr, raddr net.Addr) [][]byte
- func (m *Master) MarshalBinaryHeader() (output []byte)
- func (m *Master) MarshalBinarySet(options *Options, input map[string]*server.Server, laddr net.Addr, ...) (output []byte)
- func (m *Master) UnmarshalBinary(data []byte) (err error)
- func (m *Master) UnmarshalBinarySet(data [][]byte) (err error)
- type Options
- type Packet
- type PacketType
- type PingInfo
- type StatusBit
- type StatusByte
- type StatusByteStruct
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 ReadCString ¶
func ReadPascalString ¶
func ReadPascalStringStream ¶
func WriteCString ¶
func WritePascalString ¶
Types ¶
type Master ¶
type Master struct { *Packet `json:"-" csv:"-"` Address string CommonName string MOTDJunk string `json:"-" csv:"-"` MOTD string Servers map[string]*server.Server MasterID uint16 }
func NewMasterWithAddress ¶ added in v2.0.1
func (*Master) GeneratePackets ¶
func (*Master) MarshalBinaryHeader ¶
func (*Master) MarshalBinarySet ¶
func (m *Master) MarshalBinarySet(options *Options, input map[string]*server.Server, laddr net.Addr, raddr net.Addr) (output []byte)
MarshalBinarySet generates the body of a darkstar master packet laddr is the address of the interface the packet came in on raddr is the address of the request
func (*Master) UnmarshalBinary ¶
func (*Master) UnmarshalBinarySet ¶
type Packet ¶
type Packet struct { Version byte 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) Type PacketType // implements encoding.BinaryMarshaler `json:"-" csv:"-"` encoding.BinaryUnmarshaler `json:"-" csv:"-"` fmt.Stringer `json:"-" csv:"-"` }
func NewPacketWithData ¶
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
type PingInfo ¶
type PingInfo struct { GameMode byte `csv:"-"` // ?? PlayerCount byte `csv:"cur_players"` MaxPlayers byte `csv:"max_players"` GameStatus StatusByte `csv:"status"` Ping time.Duration `csv:"ping"` GameName []byte `csv:"-"` // es3a GameVersion []byte `csv:"-"` // V 001.000r Name []byte `csv:"server_name"` Address string `csv:"address"` *Packet `json:"-" csv:"-"` }
func (*PingInfo) MarshalBinary ¶
func (*PingInfo) MarshalJSON ¶ added in v2.1.1
func (*PingInfo) UnmarshalBinary ¶
type StatusByte ¶
type StatusByte byte
func (StatusByte) MarshalJSON ¶
func (s StatusByte) MarshalJSON() ([]byte, error)
func (StatusByte) String ¶
func (s StatusByte) String() string
func (StatusByte) StringSlice ¶
func (s StatusByte) StringSlice() (statusArr []string)
func (StatusByte) Struct ¶
func (s StatusByte) Struct() (output StatusByteStruct)
type StatusByteStruct ¶
type StatusByteStruct struct { Protected bool Dedicated bool AllowOldClients bool Started bool Dynamix bool WON bool Reserved1 bool Reserved2 bool }
func (StatusByteStruct) MarshalBinary ¶
func (s StatusByteStruct) MarshalBinary() (output byte)
Click to show internal directories.
Click to hide internal directories.