2023-11-12 12:14:43 +01:00
|
|
|
import Minimist from 'minimist'
|
2023-11-20 10:35:31 +01:00
|
|
|
import { GameDig } from './../lib/index.js'
|
2024-01-17 12:07:30 +01:00
|
|
|
import * as protocols from './../protocols/index.js'
|
2023-11-12 12:14:43 +01:00
|
|
|
|
|
|
|
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]
|
|
|
|
}
|
2024-01-17 14:35:16 +01:00
|
|
|
options.debug = argv._[1] === 'debug'
|
2023-11-12 12:14:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const gamedig = new GameDig(options)
|
|
|
|
|
2024-01-17 12:07:30 +01:00
|
|
|
let protocolList = []
|
|
|
|
Object.keys(protocols).forEach((key) => protocolList.push(key))
|
|
|
|
|
|
|
|
const services = ['discord', 'beammpmaster', 'beammp', 'teamspeak2', 'teamspeak3']
|
|
|
|
const protocolListFiltered = protocolList.filter((protocol) => !services.includes(protocol))
|
|
|
|
|
2023-11-12 12:14:43 +01:00
|
|
|
|
|
|
|
const run = async () => {
|
2024-01-17 12:07:30 +01:00
|
|
|
for (const protocol of protocolListFiltered) {
|
2023-11-12 12:14:43 +01:00
|
|
|
try {
|
|
|
|
const response = await gamedig.query({
|
|
|
|
...options,
|
|
|
|
type: `protocol-${protocol}`
|
|
|
|
})
|
2024-01-21 19:27:05 +01:00
|
|
|
console.log(`Success on '${protocol}':`, response)
|
2023-11-12 12:14:43 +01:00
|
|
|
process.exit()
|
|
|
|
} catch (e) {
|
|
|
|
console.log(`Error on '${protocol}': ${e}`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
run().then(() => {})
|