From 8784ab9b85120703bc6bc1c85ba5d9c8323d55b5 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sun, 1 Sep 2024 14:01:53 +0300 Subject: [PATCH 1/2] feat: add option --- CHANGELOG.md | 1 + README.md | 1 + bin/gamedig.js | 5 +++-- lib/QueryRunner.js | 3 ++- protocols/valve.js | 4 ++++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcf344de..b0c466e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Fix: `Deus Ex` using the wrong protocol (#621) * Fix: `Soldier ff Fortune` using the wrong protocol (#623) * Feat: For the Quake2 protocol `version`'s field, also look for `version` in the raw object +* Feat: Add option `requestPlayers`, defaults to `true`. ## 5.1.2 * Added Vintage Story support via the master server (#606) diff --git a/README.md b/README.md index 894a5ff4..aede004e 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Confused on how this works, or you want to see more? Checkout the [examples](/ex | **ipFamily** | number | 0 | IP family/version returned when looking up hostnames via DNS, can be 0 (IPv4 and IPv6), 4 (IPv4 only) or 6 (IPv6 only). | | **debug** | boolean | false | Enables massive amounts of debug logging to stdout. | | **requestRules** | boolean | false | Valve games only. Additional 'rules' may be fetched into the `raw` key. | +| **requestPlayers** | boolean | true | Valve games only. Disable this if you don't want players data. | | **requestRulesRequired** | boolean | false | Valve games only. `requestRules` is always required to have a response or the query will timeout. | | **requestPlayersRequired** | boolean | false | Valve games only. Querying players is always required to have a response or the query will timeout. Some [games](GAMES_LIST.md) may not provide a players response. | | **stripColors** | boolean | true | Enables stripping colors for protocols: unreal2, savage2, quake3, nadeo, gamespy2, doom3, armagetron. | diff --git a/bin/gamedig.js b/bin/gamedig.js index 38ed1ecc..20ea44bf 100644 --- a/bin/gamedig.js +++ b/bin/gamedig.js @@ -6,11 +6,12 @@ import Minimist from 'minimist' import { GameDig } from './../lib/index.js' const argv = Minimist(process.argv.slice(2), { - boolean: ['pretty', 'debug', 'givenPortOnly', 'requestRules', 'requestRulesRequired', 'requestPlayersRequired', 'stripColors', 'portCache', 'noBreadthOrder', 'checkOldIDs'], + boolean: ['pretty', 'debug', 'givenPortOnly', 'requestRules', 'requestPlayers', 'requestRulesRequired', 'requestPlayersRequired', 'stripColors', 'portCache', 'noBreadthOrder', 'checkOldIDs'], string: ['guildId', 'serverId', 'listenUdpPort', 'ipFamily', 'token'], default: { stripColors: true, - portCache: true + portCache: true, + requestPlayers: true } }) diff --git a/lib/QueryRunner.js b/lib/QueryRunner.js index b193704a..2cfe79d8 100644 --- a/lib/QueryRunner.js +++ b/lib/QueryRunner.js @@ -9,7 +9,8 @@ const defaultOptions = { stripColors: true, portCache: true, noBreadthOrder: false, - ipFamily: 0 + ipFamily: 0, + requestPlayers: true } export default class QueryRunner { diff --git a/protocols/valve.js b/protocols/valve.js index 2a250829..30b4fd1a 100644 --- a/protocols/valve.js +++ b/protocols/valve.js @@ -163,6 +163,10 @@ export default class valve extends Core { async queryPlayers (/** Results */ state) { state.raw.players = [] + if (!this.options.requestPlayers) { + return + } + this.logger.debug('Requesting player list ...') const b = await this.sendPacket( this.goldsrcInfo ? undefined : 0x55, From c6937c1374c389c49a03a6132a5471bd2a6b0b69 Mon Sep 17 00:00:00 2001 From: CosminPerRam Date: Sun, 1 Sep 2024 16:00:45 +0300 Subject: [PATCH 2/2] docs: alter readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aede004e..144593bb 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Confused on how this works, or you want to see more? Checkout the [examples](/ex | **ipFamily** | number | 0 | IP family/version returned when looking up hostnames via DNS, can be 0 (IPv4 and IPv6), 4 (IPv4 only) or 6 (IPv6 only). | | **debug** | boolean | false | Enables massive amounts of debug logging to stdout. | | **requestRules** | boolean | false | Valve games only. Additional 'rules' may be fetched into the `raw` key. | -| **requestPlayers** | boolean | true | Valve games only. Disable this if you don't want players data. | +| **requestPlayers** | boolean | true | Valve games only. Disable this if you don't want to fetch players data. | | **requestRulesRequired** | boolean | false | Valve games only. `requestRules` is always required to have a response or the query will timeout. | | **requestPlayersRequired** | boolean | false | Valve games only. Querying players is always required to have a response or the query will timeout. Some [games](GAMES_LIST.md) may not provide a players response. | | **stripColors** | boolean | true | Enables stripping colors for protocols: unreal2, savage2, quake3, nadeo, gamespy2, doom3, armagetron. |