filters

package
v0.0.0-...-555310e Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SrUsEastCoast  SrvRegion = []byte{0x00}
	SrUsWestCoast  SrvRegion = []byte{0x01}
	SrSouthAmerica SrvRegion = []byte{0x02}
	SrEurope       SrvRegion = []byte{0x03}
	SrAsia         SrvRegion = []byte{0x04}
	SrAustralia    SrvRegion = []byte{0x05}
	SrMiddleEast   SrvRegion = []byte{0x06}
	SrAfrica       SrvRegion = []byte{0x07}
	SrAll          SrvRegion = []byte{0xFF}

	// --------------------- "Constant" filters ---------------------
	// Dedicated servers
	SfDedicated SrvFilter = []byte("\\dedicated\\1")
	// Servers using anti-cheat technology (VAC, but maybe others as well)
	SfSecure SrvFilter = []byte("\\secure\\1")
	// Servers running on a Linux platform
	SfLinux SrvFilter = []byte("\\linux\\1")
	// Servers that are not empty
	SfNotEmpty SrvFilter = []byte("\\empty\\1")
	// Servers that are not full
	SfNotFull SrvFilter = []byte("\\full\\1")
	// Servers that spectator proxies
	SfSpectatorProxy SrvFilter = []byte("\\proxy\\1")
	// Servers that are empty
	SfEmpty SrvFilter = []byte("\\noplayers\\1")
	// Servers that are whitelisted
	SfWhitelisted SrvFilter = []byte("\\white\\1")
	// Return only one server for each unique IP address matched
	SfOneUniquePerIP SrvFilter = []byte("\\collapse_addr_hash\\1")
	// ALL servers
	SfAll SrvFilter = []byte{0x00}

	// ----------------Filters the take variable input ----------------
	// \appid\[appid] - Servers that are running game [appid]
	AppIDFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\appid\\%s", val))
	}
	// \gameaddr\[ip]Return only servers on the specified IP address
	// (port supported and optional)
	GameAddrFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\gameaddr\\%s", val))
	}
	// \gamedata\[tag,...] - Servers with all of the given tag(s) in their
	//'hidden' tags (L4D2)
	GameDataFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\gamedata\\%s", val))
	}
	// \gamedataor\[tag,...] - Servers with any of the given tag(s) in their
	// 'hidden' tags (L4D2)
	GameDataOrFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\gamedataor\\%s", val))
	}
	// \gamedir\[mod] - Servers running the specified modification (ex. cstrike)
	GameDirFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\gamedir\\%s", val))
	}
	// \gametype\[tag,...] - Servers with all of the given tag(s) in sv_tags
	GameTypeFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\gametype\\%s", val))
	}
	// \name_match\[hostname] - Servers with their hostname matching [hostname]
	// (can use * as a wildcard)
	NameMatchFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\name_match\\%s", val))
	}
	// \nand\[x] - A special filter, specifies that servers matching all of the
	// following [x] conditions should not be returned
	NAndFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\nand\\%s", val))
	}
	// \nor\[x] - A special filter, specifies that servers matching any of the
	//following [x] conditions should not be returned
	NOrFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\nor\\%s", val))
	}
	// \napp\[appid] - Servers that are NOT running game [appid]
	// (This was introduced to block Left 4 Dead games from the Steam Server Browser
	NAppIDFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\nappid\\%s", val))
	}
	// \map\[map] - Servers running the specified map (ex. cs_italy)
	MapFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\map\\%s", val))
	}
	// \version_match\[version] - Servers running version [version]
	// (can use * as a wildcard)
	VersionMatchFilter = func(val string) SrvFilter {
		return []byte(fmt.Sprintf("\\version_match\\%s", val))
	}
)

Regions and filters

View Source
var (
	// GameAlienSwarm Alien Swarm
	GameAlienSwarm = Game{
		Name:          "AlienSwarm",
		AppID:         630,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameARMA3 ARMA 3
	GameARMA3 = Game{
		Name:          "ARMA3",
		AppID:         107410,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameARKSurvivalEvolved ARK: Survival Evolved
	GameARKSurvivalEvolved = Game{
		Name:          "ARKSurvivalEvolved",
		AppID:         346110,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameCsGo Counter-Strike: GO
	GameCsGo = Game{
		Name:          "CSGO",
		AppID:         730,
		IgnoreRules:   true,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameCSSource Counter-Strike: Source
	GameCSSource = Game{
		Name:          "CSSource",
		AppID:         240,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameDayZ DayZ
	GameDayZ = Game{
		Name:          "DayZ",
		AppID:         221100,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameGarrysMod Garry's Mod
	GameGarrysMod = Game{
		Name:          "GarrysMod",
		AppID:         4000,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameHL2DM Half-Life 2: Deathmatch
	GameHL2DM = Game{
		Name:          "HL2DM",
		AppID:         320,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameL4D2 Left 4 Dead 2
	GameL4D2 = Game{
		Name:          "L4D2",
		AppID:         550,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameOpposingForce Half-Life: Opposing Force
	GameOpposingForce = Game{
		Name:          "OpposingForce",
		AppID:         50,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameQuakeLive Quake Live
	GameQuakeLive = Game{
		Name:          "QuakeLive",
		AppID:         282440,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameReflex Reflex
	GameReflex = Game{
		Name:          "Reflex",
		AppID:         328070,
		IgnoreRules:   true,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameRust Rust
	GameRust = Game{
		Name:          "Rust",
		AppID:         252490,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameTF2 Team Fortress 2
	GameTF2 = Game{
		Name:          "TF2",
		AppID:         440,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
	// GameUnspecified Unspecified game for direct server queries, if enabled;
	// if unspecified games actually ignore some A2S requests there will be issues.
	// This is intentionally left out of the defaultGames GameList struct so it
	//is not user-selectable in the configuration creation.
	GameUnspecified = Game{
		Name:          "Unspecified",
		AppID:         0,
		IgnoreRules:   false,
		IgnorePlayers: false,
		IgnoreInfo:    false,
	}
)

A few default games, additional games can be added from https://steamdb.info/apps/

Functions

func DumpDefaultGames

func DumpDefaultGames()

DumpDefaultGames writes the default struct containing the default games to disk on success, otherwise panics.

func GetGameNames

func GetGameNames() []string

GetGameNames returns a slice of strings containing the games' names.

func HasHighServerCount

func HasHighServerCount(name string) bool

HasHighServerCount determines if the specified game is in the list of games that are known to return more than 6930 servers, which is the value at which Valve begins to throttle future responses from the master server.

func IsValidGame

func IsValidGame(name string) bool

IsValidGame determines whether the specified game exists within the list of games and returns true if it does, otherwise false.

Types

type Filter

type Filter struct {
	Game    Game
	Region  SrvRegion
	Filters []SrvFilter
}

Filter is our internal wrapper for a specified game, and its Master server region code and Master server filters

func NewFilter

func NewFilter(game Game, region SrvRegion, filters []SrvFilter) Filter

NewFilter creates a new filter for use with a master server query based on a game to query, its region code, and any other additional master server filters that should be sent with the request to the master server.

type Game

type Game struct {
	Name  string `json:"name"`
	AppID uint64 `json:"appID"`
	// Some games (i.e. newer/beta ones) do not have all 3 of A2S_INFO,PLAYER,RULES
	// any of these ignore values set to true will skip that request when querying
	IgnoreRules   bool `json:"ignoreRules"`
	IgnorePlayers bool `json:"ignorePlayers"`
	IgnoreInfo    bool `json:"ignoreInfo"`
}

Game represents a queryable Steam game, including its application ID and whether particular A2S requests need to be ignored when querying.

func GetGameByAppID

func GetGameByAppID(appid uint64) Game

GetGameByAppID searches the list of pre-defined games and returns a Game struct based on the AppID of the game.

func GetGameByName

func GetGameByName(name string) Game

GetGameByName searches the list of pre-defined games and returns a a Game struct based on the name of the game.

func NewGame

func NewGame(name string, appid uint64, ignoreRules, ignorePlayers,
	ignoreInfo bool) Game

NewGame specifies a new game, including its name, Steam application-ID, and whether A2S_RULES, A2S_PLAYERS, and/or AS2_INFO requests should be ignored when performing a query.

func ReadGames

func ReadGames() []Game

ReadGames reads the game file from disk and returns a slice to a pointer of Game structs if successful, otherwise panics.

func (*Game) String

func (g *Game) String() string

type GameList

type GameList struct {
	Games []Game `json:"games"`
}

GameList represents the list of games.

type SrvFilter

type SrvFilter []byte

SrvFilter represents a Master server filter

type SrvRegion

type SrvRegion []byte

SrvRegion represents a Master server region code filter

Jump to

Keyboard shortcuts

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