Documentation ¶
Overview ¶
Licensed under the GNU General Public License, version 3 or higher.
Licensed under the GNU General Public License, version 3 or higher.
Licensed under the GNU General Public License, version 3 or higher.
Licensed under the GNU General Public License, version 3 or higher.
Licensed under the GNU General Public License, version 3 or higher.
Licensed under the GNU General Public License, version 3 or higher.
Licensed under the GNU General Public License, version 3 or higher.
Index ¶
- Constants
- Variables
- func BuildMasterQuery(hostAndPort string, filters []string) []byte
- func IsPreOrangeBoxApp(appId AppId) bool
- type AppId
- type ExtendedInfo
- type GameEngine
- type MasterQueryCallback
- type MasterServerQuerier
- func (this *MasterServerQuerier) Close()
- func (this *MasterServerQuerier) FilterAppId(appId AppId)
- func (this *MasterServerQuerier) FilterAppIds(appIds []AppId)
- func (this *MasterServerQuerier) FilterGameaddr(serverIP string)
- func (this *MasterServerQuerier) FilterName(serverName string)
- func (this *MasterServerQuerier) Query(callback MasterQueryCallback) error
- type ModInfo
- type MultiPacketHeader
- type PacketBuilder
- type PacketReader
- func (this *PacketReader) More() bool
- func (this *PacketReader) Pos() int
- func (r *PacketReader) ReadFloat32() float32
- func (this *PacketReader) ReadIPv4() (net.IP, error)
- func (this *PacketReader) ReadInt32() int32
- func (this *PacketReader) ReadPort() (uint16, error)
- func (this *PacketReader) ReadString() string
- func (this *PacketReader) ReadUint16() uint16
- func (this *PacketReader) ReadUint32() uint32
- func (this *PacketReader) ReadUint64() uint64
- func (this *PacketReader) ReadUint8() uint8
- func (this *PacketReader) Slice(count int) []byte
- func (this *PacketReader) TryReadString() (string, bool)
- type Player
- type ServerInfo
- type ServerList
- type ServerOS
- type ServerQuerier
- type ServerType
- type SpecTvInfo
- type TheShipInfo
- type UdpSocket
Constants ¶
const A2S_INFO_GOLDSRC uint8 = 0x6d
Official versions of the A2S_INFO reply.
const A2S_INFO_SOURCE uint8 = 0x49
const MasterServer = "hl2master.steampowered.com:27011"
MasterServer ...
Variables ¶
var ErrBadChallengeResponse = errors.New("bad challenge response")
var ErrBadPacketHeader = errors.New("bad packet header")
var ErrBadPacketNumber = errors.New("packet number is out of sequence")
var ErrBadPlayersReply = errors.New("bad players reply")
var ErrBadResponseHeader = fmt.Errorf("bad response header")
var ErrBadRulesReply = errors.New("bad rules reply")
var ErrConfusedChallengeReply = errors.New("challenge reply is for the wrong query")
var ErrDuplicatePacket = errors.New("received duplicate numbered packets")
var ErrImmediateRulesReply = errors.New("immediate rules reply")
var ErrMistakenReply = errors.New("mistaken reply")
var ErrOutOfBounds = errors.New("read out of bounds")
var ErrUnknownGameEngine = errors.New("must query A2S_INFO first")
var ErrUnknownInfoVersion = errors.New("unknown A2S_INFO version")
var ErrWrongBz2Checksum = errors.New("bad bz2 checksum")
var ErrWrongBz2Size = errors.New("bad bz2 decompression size")
var HL1Apps = []AppId{ App_CS, App_TFC, App_DOD, App_DMC, App_OP4, App_Ricochet, App_HL, App_CS_CZ, }
var HL2Apps = []AppId{ App_SDK2006, App_SDK2007, App_CSS, App_DODS, App_HL2DM, App_HLDMS, App_TF2, App_L4D1, App_L4D2, App_AlienSwarm, App_CSGO, App_DarkMessiah, App_TheShip, App_BloodyGoodTime, App_GarrysMod, App_ZombiePanic, App_AgeOfChivalry, App_Synergy, App_DIPRIP, App_EternalSilence, App_PVK, App_Dystopia, App_InsurgencyMod, App_NuclearDawn, App_Smashball, App_EmpiresMod, App_DinoDDay, App_EYE, App_Insurgency, App_NoMoreRoomInHell, App_BladeSymphony, App_Contagion, App_SDK2013, App_Neotokyo, App_FortressForever, App_FistfulOfFrags, App_ModularCombat, App_CodenameCURE, App_BlackMesa, App_DayOfInfamy, App_IOSoccer, }
var Try = tryAndCatch
This can be changed to enable panics.
Functions ¶
func BuildMasterQuery ¶
Build a packet to query the master server, given an initial starting server ("0.0.0.0:0" for the initial batch) and an optional list of filter strings.
func IsPreOrangeBoxApp ¶
Types ¶
type AppId ¶
type AppId int32
const ( App_Unknown AppId = 0 // HL1 App_CS AppId = 10 App_TFC AppId = 20 App_DOD AppId = 30 App_DMC AppId = 40 App_OP4 AppId = 50 App_Ricochet AppId = 60 App_HL AppId = 70 App_CS_CZ AppId = 80 // HL2 App_SDK2006 AppId = 215 App_SDK2007 AppId = 218 App_CSS AppId = 240 App_DODS AppId = 300 App_HL2DM AppId = 320 App_HLDMS AppId = 360 App_TF2 AppId = 440 App_L4D1 AppId = 500 App_L4D2 AppId = 550 App_AlienSwarm AppId = 630 App_CSGO AppId = 730 App_DarkMessiah AppId = 2130 App_TheShip AppId = 2400 App_BloodyGoodTime AppId = 2450 App_GarrysMod AppId = 4000 App_ZombiePanic AppId = 17500 App_AgeOfChivalry AppId = 17510 App_Synergy AppId = 17520 App_DIPRIP AppId = 17530 App_EternalSilence AppId = 17550 App_PVK AppId = 17570 App_Dystopia AppId = 17580 App_InsurgencyMod AppId = 17700 App_NuclearDawn AppId = 17710 App_Smashball AppId = 17730 App_EmpiresMod AppId = 17740 App_DinoDDay AppId = 70000 App_EYE AppId = 91700 App_Insurgency AppId = 222880 App_NoMoreRoomInHell AppId = 224260 App_BladeSymphony AppId = 225600 App_Contagion AppId = 238430 App_SDK2013 AppId = 243750 App_Neotokyo AppId = 244630 App_FortressForever AppId = 253530 App_FistfulOfFrags AppId = 265630 App_ModularCombat AppId = 349480 App_CodenameCURE AppId = 355180 App_BlackMesa AppId = 362890 App_DayOfInfamy AppId = 447820 App_IOSoccer AppId = 673560 )
type ExtendedInfo ¶
type ExtendedInfo struct { AppId AppId GameVersion string Port uint16 // 0 if not present. SteamId uint64 // 0 if not present. GameModeDescription string // "" if not present. GameId uint64 // 0 if not present. }
Optional information available with A2S_INFO_SOURCE. This is a grab-bag of various optional bits. If some are not present they are left as 0. In the future this may change to distinguish from being present as 0.
type GameEngine ¶
type GameEngine int
The game engine (either HL1 or HL2).
const ( GOLDSRC GameEngine = GameEngine(1) SOURCE GameEngine = GameEngine(2) )
type MasterQueryCallback ¶
type MasterQueryCallback func(batch ServerList) error
The callback the master query tool uses to notify of a batch of servers that has just been received.
type MasterServerQuerier ¶
type MasterServerQuerier struct {
// contains filtered or unexported fields
}
Class for querying the master server.
func NewMasterServerQuerier ¶
func NewMasterServerQuerier(hostAndPort string) (*MasterServerQuerier, error)
Create a new master server querier on the given host and port.
func (*MasterServerQuerier) Close ¶
func (this *MasterServerQuerier) Close()
func (*MasterServerQuerier) FilterAppId ¶
func (this *MasterServerQuerier) FilterAppId(appId AppId)
func (*MasterServerQuerier) FilterAppIds ¶
func (this *MasterServerQuerier) FilterAppIds(appIds []AppId)
Adds by AppIds to the filter list.
func (*MasterServerQuerier) FilterGameaddr ¶
func (this *MasterServerQuerier) FilterGameaddr(serverIP string)
Adds by AppIds to the filter list.
func (*MasterServerQuerier) FilterName ¶
func (this *MasterServerQuerier) FilterName(serverName string)
Adds by AppIds to the filter list.
func (*MasterServerQuerier) Query ¶
func (this *MasterServerQuerier) Query(callback MasterQueryCallback) error
Query the master. Since the master server has timeout problems with lots of subsequent requests, we sleep for two seconds in between each batch request. This means the querying process is quite slow.
type ModInfo ¶
type ModInfo struct { Url string `json:"url"` DwlUrl string `json:"dwlurl"` Version uint32 `json:"version"` Size uint32 `json:"size"` Type uint8 `json:"type"` Dll uint8 `json:"dll"` }
Optional mod information returned by A2S_INFO_GOLDSRC.
type MultiPacketHeader ¶
type MultiPacketHeader struct { // Size of the packet header itself. Size int // Packet sequence id. Id uint32 // Packet number out of Total Packets. PacketNumber uint8 // Total number of packets to receive. TotalPackets uint8 // Packet size (0 if not present). PacketSize uint16 // Compression information. Compressed bool Payload []byte }
type PacketBuilder ¶
func (*PacketBuilder) WriteBytes ¶
func (this *PacketBuilder) WriteBytes(bytes []byte)
func (*PacketBuilder) WriteCString ¶
func (this *PacketBuilder) WriteCString(str string)
type PacketReader ¶
type PacketReader struct {
// contains filtered or unexported fields
}
func NewPacketReader ¶
func NewPacketReader(packet []byte) *PacketReader
func (*PacketReader) More ¶
func (this *PacketReader) More() bool
func (*PacketReader) Pos ¶
func (this *PacketReader) Pos() int
func (*PacketReader) ReadFloat32 ¶
func (r *PacketReader) ReadFloat32() float32
func (*PacketReader) ReadInt32 ¶
func (this *PacketReader) ReadInt32() int32
func (*PacketReader) ReadPort ¶
func (this *PacketReader) ReadPort() (uint16, error)
func (*PacketReader) ReadString ¶
func (this *PacketReader) ReadString() string
func (*PacketReader) ReadUint16 ¶
func (this *PacketReader) ReadUint16() uint16
func (*PacketReader) ReadUint32 ¶
func (this *PacketReader) ReadUint32() uint32
func (*PacketReader) ReadUint64 ¶
func (this *PacketReader) ReadUint64() uint64
func (*PacketReader) ReadUint8 ¶
func (this *PacketReader) ReadUint8() uint8
func (*PacketReader) Slice ¶
func (this *PacketReader) Slice(count int) []byte
func (*PacketReader) TryReadString ¶
func (this *PacketReader) TryReadString() (string, bool)
type ServerInfo ¶
type ServerInfo struct { // The address can be arbitrary in older replies; for Source servers, it is // computed as the address and port used to connect. It should not be relied // on for reconnecting to the server. Address string // One of the A2S_INFO constants. InfoVersion uint8 Protocol uint8 Name string MapName string Folder string Game string Players uint8 MaxPlayers uint8 Bots uint8 Type ServerType OS ServerOS Visibility uint8 Vac uint8 Mod *ModInfo TheShip *TheShipInfo SpecTv *SpecTvInfo Ext *ExtendedInfo }
Information returned by an A2S_INFO query. Most of this is returned as-is from the wire, except where otherwise noted.
func (*ServerInfo) GameEngine ¶
func (this *ServerInfo) GameEngine() GameEngine
Attempt to guess the game engine version.
func (*ServerInfo) IsPreOrangeBox ¶
func (this *ServerInfo) IsPreOrangeBox() bool
Determines whether or not a Source server is pre-orangebox. This should not be called on non-Source servers.
type ServerList ¶
A list of IP addresses and ports.
func (ServerList) Item ¶
func (this ServerList) Item(index int) interface{}
Implements Batch.Item().
type ServerQuerier ¶
type ServerQuerier struct {
// contains filtered or unexported fields
}
A ServerQuerier is used to issue A2S queries against an HL1/HL2 server.
func NewServerQuerier ¶
func NewServerQuerier(hostAndPort string, timeout time.Duration) (*ServerQuerier, error)
Create a new server querying object.
func (*ServerQuerier) QueryInfo ¶
func (this *ServerQuerier) QueryInfo() (*ServerInfo, error)
Query a server's info via A2S_INFO.
func (*ServerQuerier) QueryPlayers ¶
func (this *ServerQuerier) QueryPlayers() ([]*Player, error)
Send an A2S_PLAYER query to the server. This returns a mapping of cvar names to values.
func (*ServerQuerier) QueryRules ¶
func (this *ServerQuerier) QueryRules() (map[string]string, error)
Send an A2S_RULES query to the server. This returns a mapping of cvar names to values.
type ServerType ¶
type ServerType int
The server type (either dedicated or listen).
const ( ServerType_Unknown ServerType = iota ServerType_Dedicated ServerType_Listen ServerType_HLTV )
func (ServerType) String ¶
func (this ServerType) String() string
Returns the server type as a string.
type SpecTvInfo ¶
Optional information available with A2S_INFO_SOURCE.
type TheShipInfo ¶
type TheShipInfo struct { Mode uint8 `json:"mode"` Witnesses uint8 `json:"witnesses"` Duration uint8 `json:"duration"` }
Optional information returned by App_TheShip.
type UdpSocket ¶
type UdpSocket struct {
// contains filtered or unexported fields
}