forked from gamedig/node-gamedig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
attempt_protocols.js
41 lines (34 loc) · 1.11 KB
/
attempt_protocols.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import Minimist from 'minimist'
import { GameDig } from './../lib/index.js'
import * as protocols from './../protocols/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]
}
options.debug = argv._[1] === 'debug'
}
const gamedig = new GameDig(options)
const protocolList = []
Object.keys(protocols).forEach((key) => protocolList.push(key))
const ignoredProtocols = ['discord', 'beammpmaster', 'beammp', 'teamspeak2', 'teamspeak3', 'vintagestorymaster']
const protocolListFiltered = protocolList.filter((protocol) => !ignoredProtocols.includes(protocol))
const run = async () => {
for (const protocol of protocolListFiltered) {
try {
const response = await gamedig.query({
...options,
type: `protocol-${protocol}`
})
console.log(`Success on '${protocol}':`, response)
process.exit()
} catch (e) {
console.log(`Error on '${protocol}': ${e}`)
}
}
}
run().then(() => {})