Skip to content

InnoDevTM/vmsq

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vmsq npm version

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 or vmsq.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

About

query valve's master servers

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%