Documentation ¶
Index ¶
- Constants
- Variables
- func DirectQuery(hosts []string) (*models.APIServerList, error)
- func GetInfoForServer(host string, timeout int) (models.SteamServerInfo, error)
- func GetPlayersForServer(host string, timeout int) ([]models.SteamPlayerInfo, error)
- func GetRulesForServer(host string, timeout int) (map[string]string, error)
- func Query(hostsgames map[string]string) (*models.APIServerList, error)
- func RetryFailedInfoReq(failed []string, retrycount int) map[string]models.SteamServerInfo
- func RetryFailedPlayersReq(failed []string, retrycount int) map[string][]models.SteamPlayerInfo
- func RetryFailedRulesReq(failed []string, retrycount int) map[string]map[string]string
- func StartMasterRetrieval(stop chan bool, filter filters.Filter, initialDelay int, ...)
- type MasterQuery
Constants ¶
const ( // QueryTimeout is the connect, read, and write timeout in seconds. It should // be greater than 1. QueryTimeout = 3 // QueryRetryCount is the number of times to re-request rules, players, and info // on failure. QueryRetryCount = 3 )
Variables ¶
var ( // ErrHostConnection is an error related to the establishment of a connection. ErrHostConnection = func(msg string) error { return fmt.Errorf("Steam: host connection error: %s", msg) } // ErrDataTransmit is an error related to sending data to a connection. ErrDataTransmit = func(msg string) error { return fmt.Errorf("Steam: data transmission error: %s", msg) } // ErrMultiPacketTransmit is an error related to sending data to a connection // in the multi-packet context of A2S_RULES. ErrMultiPacketTransmit = func(msg string) error { return fmt.Errorf("Steam: multi-packet data transmission error: %s", msg) } // ErrChallengeResponse is an error thrown for an invalid challense response // header. ErrChallengeResponse = errors.New("Steam: invalid challenge response header") // ErrPacketHeader is an error thrown upon detection of an invalid packet header. ErrPacketHeader = errors.New("Steam: invalid packet header") // ErrMultiPacketDuplicate is an error thrown when a duplicate packet is // detected int he multi-packet context of A2S_RULES. ErrMultiPacketDuplicate = errors.New( "Steam: multi-packet: duplicate packet detected") // ErrMultiPacketIDMismatch is an error thrown in the context of multi-packet // A2S_RULES when the current packet ID does match the packet ID for the batch // of multiple packets currently being processed. ErrMultiPacketIDMismatch = errors.New( "Steam: multi-packet error: packet ID mismatch") // ErrMultiPacketNumExceeded is an error thrown in the A2S_RULES multi-packet // context when the current packet's number is greater than the total number of // packets to be parsed within the current batch. ErrMultiPacketNumExceeded = errors.New( "Steam: multi-packet error: packet number greater than total") // ErrNoPlayers is a generic error thrown when a server is empty. ErrNoPlayers = errors.New("Steam: server contains no players") // ErrNoRules is a generic error thrown when no A2S_RULES data could be parsed // for the given server. ErrNoRules = errors.New("Steam: no A2S_RULES for server") // ErrNoInfo is a generic error thrown when no A2S_INFO could be parsed for the // given server. ErrNoInfo = errors.New("Steam: no A2S_INFO for server") )
Errors
Functions ¶
func DirectQuery ¶
func DirectQuery(hosts []string) (*models.APIServerList, error)
DirectQuery allows a user to query any host even if it is not in the internal server ID database. It is primarily intended for testing as it has two main issues: 1) obvious security implications, 2) determining which game a user- supplied host represents rests on potentially unreliable assumptions, which if not true would cause games with incomplete support for all three A2S queries (e.g. Reflex) to always fail. A production environment should use Query() instead.
func GetInfoForServer ¶
func GetInfoForServer(host string, timeout int) (models.SteamServerInfo, error)
GetInfoForServer requests A2S_INFO for a given host within timeout seconds.
func GetPlayersForServer ¶
func GetPlayersForServer(host string, timeout int) ([]models.SteamPlayerInfo, error)
GetPlayersForServer requests A2S_PLAYER info for a given host within timeout seconds.
func GetRulesForServer ¶
GetRulesForServer requests A2S_RULES info for a given host within timeout seconds.
func Query ¶
func Query(hostsgames map[string]string) (*models.APIServerList, error)
Query retrieves the server information for a given set of host to game pairs and returns it in a format that is presented to the API. It takes a map consisting of host(s) and their corresponding game names (i.e: k:127.0.0.1:27960, v:"QuakeLive")
func RetryFailedInfoReq ¶
func RetryFailedInfoReq(failed []string, retrycount int) map[string]models.SteamServerInfo
RetryFailedInfoReq retries a failed A2S_INFO request for a specified group of failed hosts for a total of retrycount times, returning a host to A2S_INFO mapping for any hosts that were successfully retried.
func RetryFailedPlayersReq ¶
func RetryFailedPlayersReq(failed []string, retrycount int) map[string][]models.SteamPlayerInfo
RetryFailedPlayersReq retries a failed A2S_PLAYER request for a specified group of failed hosts for a total of retrycount times, returning a host to A2S_PLAYER mapping for any hosts that were successfully retried.
func RetryFailedRulesReq ¶
RetryFailedRulesReq retries a failed A2S_RULES request for a specified group of failed hosts for a total of retrycount times, returning a host to A2S_RULES mapping for any hosts that were successfully retried.
func StartMasterRetrieval ¶
func StartMasterRetrieval(stop chan bool, filter filters.Filter, initialDelay int, timeBetweenQueries int)
StartMasterRetrieval starts a timed retrieval of servers specified by a given filter from the Steam Master server after an initial delay of initialDelay seconds. It retrieves the list every timeBetweenQueries seconds thereafter. A bool can be sent to the stop channel to cancel all timed retrievals.
Types ¶
type MasterQuery ¶
type MasterQuery struct {
Servers []string
}
MasterQuery contains the servers returned by a query to the Steam master server.
func NewMasterQuery ¶
func NewMasterQuery(filter filters.Filter) (MasterQuery, error)
NewMasterQuery initiates a new Steam Master server query for a given filter, returning a MasterQuery struct containing the hosts retrieved in the event of success or an empty struct and an error in the event of failure.
func NewMasterWebQuery ¶
func NewMasterWebQuery(filter filters.Filter) (MasterQuery, error)
NewMasterWebQuery initiates a new Steam "Master" server query using the Steam Web API for a given filter, returning a MasterQuery struct containing the hosts retrieved in the event of success or an empty struct and an error in the event of failure.