mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-16 00:38:31 +01:00
8192ed07e0
* feat: export games and protocols besides GameDig * fix: revert ProtocolResolver rename * fix: imports on the attempt tools * docs: update changelog to note exports
36 lines
855 B
JavaScript
36 lines
855 B
JavaScript
import Minimist from 'minimist'
|
|
import { GameDig } from './../lib/index.js'
|
|
|
|
const argv = Minimist(process.argv.slice(2), {})
|
|
|
|
const options = {}
|
|
if (argv._.length >= 1) {
|
|
const target = argv._[0]
|
|
const split = target.split(':')
|
|
options.host = split[0]
|
|
if (split.length >= 2) {
|
|
options.port = split[1]
|
|
}
|
|
}
|
|
|
|
const gamedig = new GameDig(options)
|
|
|
|
const protocols = ['valve', 'gamespy1', 'gamespy2', 'gamespy3', 'goldsrc', 'minecraft', 'quake1', 'quake2', 'quake3', 'unreal2', 'valve']
|
|
|
|
const run = async () => {
|
|
for (const protocol of protocols) {
|
|
try {
|
|
const response = await gamedig.query({
|
|
...options,
|
|
debug: true,
|
|
type: `protocol-${protocol}`
|
|
})
|
|
console.log(response)
|
|
process.exit()
|
|
} catch (e) {
|
|
console.log(`Error on '${protocol}': ${e}`)
|
|
}
|
|
}
|
|
}
|
|
|
|
run().then(() => {})
|