valve

package
v0.0.0-...-adb0082 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

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

View Source
const A2S_INFO_GOLDSRC uint8 = 0x6d

Official versions of the A2S_INFO reply.

View Source
const A2S_INFO_SOURCE uint8 = 0x49
View Source
const MasterServer = "hl2master.steampowered.com:27011"

MasterServer ...

Variables

View Source
var ErrBadChallengeResponse = errors.New("bad challenge response")
View Source
var ErrBadPacketHeader = errors.New("bad packet header")
View Source
var ErrBadPacketNumber = errors.New("packet number is out of sequence")
View Source
var ErrBadPlayersReply = errors.New("bad players reply")
View Source
var ErrBadResponseHeader = fmt.Errorf("bad response header")
View Source
var ErrBadRulesReply = errors.New("bad rules reply")
View Source
var ErrConfusedChallengeReply = errors.New("challenge reply is for the wrong query")
View Source
var ErrDuplicatePacket = errors.New("received duplicate numbered packets")
View Source
var ErrImmediateRulesReply = errors.New("immediate rules reply")
View Source
var ErrMistakenReply = errors.New("mistaken reply")
View Source
var ErrOutOfBounds = errors.New("read out of bounds")
View Source
var ErrUnknownGameEngine = errors.New("must query A2S_INFO first")
View Source
var ErrUnknownInfoVersion = errors.New("unknown A2S_INFO version")
View Source
var ErrWrongBz2Checksum = errors.New("bad bz2 checksum")
View Source
var ErrWrongBz2Size = errors.New("bad bz2 decompression size")
View Source
var Try = tryAndCatch

This can be changed to enable panics.

Functions

func BuildMasterQuery

func BuildMasterQuery(hostAndPort string, filters []string) []byte

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

func IsPreOrangeBoxApp(appId AppId) bool

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

type PacketBuilder struct {
	bytes.Buffer
}

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) ReadIPv4

func (this *PacketReader) ReadIPv4() (net.IP, error)

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 Player

type Player struct {

	// Name of the player.
	Name string `json:"Name"`

	// Player's score (usually "frags" or "kills".)
	Score uint32 `json:"Score"`

	// Time (in seconds) player has been connected to the server.
	Duration float32 `json:"Duration"`
}

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

type ServerList []*net.TCPAddr

A list of IP addresses and ports.

func (ServerList) Item

func (this ServerList) Item(index int) interface{}

Implements Batch.Item().

func (ServerList) Len

func (this ServerList) Len() int

Implements Batch.Len().

type ServerOS

type ServerOS int

The server operating system (windows, linux, or mac).

const (
	ServerOS_Unknown ServerOS = iota
	ServerOS_Windows
	ServerOS_Linux
	ServerOS_Mac
)

func (ServerOS) String

func (this ServerOS) String() string

Returns the operating system as a string.

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) Close

func (this *ServerQuerier) Close()

Close the socket used to query.

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

type SpecTvInfo struct {
	Port uint16
	Name string
}

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
}

func NewUdpSocket

func NewUdpSocket(address string, timeout time.Duration) (*UdpSocket, error)

func (*UdpSocket) Close

func (this *UdpSocket) Close()

func (*UdpSocket) Recv

func (this *UdpSocket) Recv() ([]byte, error)

func (*UdpSocket) RemoteAddr

func (this *UdpSocket) RemoteAddr() net.Addr

func (*UdpSocket) Send

func (this *UdpSocket) Send(bytes []byte) error

func (*UdpSocket) SetRateLimit

func (this *UdpSocket) SetRateLimit(ratePerMinute int)

func (*UdpSocket) SetTimeout

func (this *UdpSocket) SetTimeout(timeout time.Duration)

Jump to

Keyboard shortcuts

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