vmsq
v2.1.0
Published
query valve's master servers
Downloads
9
Readme
vmsq
a library for querying valve's master servers with node.js
$ npm install vmsq
usage
vmsq(masterServer :: String, region :: Number, filters? :: Object) → ReadableStream
masterServer
: The master server to query, e.g.hl2master.steampowered.com:27011
region
: Region to query, e.g.0x03
orvmsq.EUROPE
filters
: Optional object that contains filters sent with the query
Returns a ReadableStream
emitting each server as a string one by one.
example
const vmsq = require('vmsq')
const stream = vmsq('hl2master.steampowered.com:27011', vmsq.EUROPE, {
gamedir: 'cstrike',
map: 'de_nuke',
empty: 1
})
const servers = []
stream.on('error', (err) => {
console.error(err)
})
stream.on('data', (ip) => {
console.log(ip)
servers.push(ip)
})
stream.on('end', () => {
console.log(`got ${servers.length} servers`)
})
output
88.241.39.16:27015
178.150.208.1:40000
...
got 24 servers
more on filters
\nor[x] A special filter, specifies that servers matching any of the following [x] conditions should not be returned \nand[x] A special filter, specifies that servers matching all of the following [x] conditions should not be returned
nor
and nand
filters are handled in a slightly different way and take an object:
vmsq('hl2master.steampowered.com:27011', vmsq.EUROPE, {
gamedir: 'cstrike',
// don't return servers that match all of the conditions
nand: {
map: 'de_nuke'
}
})
notes
- The master servers appear to be rate-limited, and sometimes stop replying during queries returning large number of servers. This results in a timeout error being emitted.
- Documentation of Master Server Query Protocol