From c264138e5476498a53685fedb6095b5c6964ec5b Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sun, 5 Nov 2023 23:43:43 +0200 Subject: [PATCH] feat: Add a little tool that runs multiple protocols for an ip --- tools/attempt_protocols.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tools/attempt_protocols.js diff --git a/tools/attempt_protocols.js b/tools/attempt_protocols.js new file mode 100644 index 0000000..bf58559 --- /dev/null +++ b/tools/attempt_protocols.js @@ -0,0 +1,33 @@ +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'] + +protocols.forEach(protocol => { + gamedig.query({ + ...options, + debug: true, + type: `protocol-${protocol}` + }) + .then(data => { + console.log(data) + process.exit() + }) + .catch(error => { + console.log(`Error on '${protocol}': ${error}`) + }) +})