diff --git a/CHANGELOG.md b/CHANGELOG.md index 111c286..266e1e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ * Minimum Supported Deno Version: `1.39.2`. * `deno run --allow-net bin/gamedig.js --type tf2 127.0.0.1` * Added code examples. +* New stable field: `queryPort` - this number indicates what was the port that the query was done on, 0 indicates none if not applicable. * New option: `stripColors` (defaults to `true`) for protocols that strips colors: unreal2, savage2, quake3, nadeo, gamespy2, doom3, armagetron. * New option: `requestRulesRequired` (defaults to `false`) Valve games only. `requestRules` is always required to have a response or the query will timeout. * New option: `requestPlayersRequired` (defaults to `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. diff --git a/README.md b/README.md index 3eaa5ac..7b2b2a9 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ The returned state object will contain the following keys: | **bots** | array of objects | Same schema as `players`. | | **connect** | string | This will typically include the game's `IP:PORT`. The port will reflect the server's game port, even if your request specified the game's query port in the request. For some games, this may be a server ID or connection URL if an IP:PORT is not appropriate for end-users. | | **ping** | number | Round trip time to the server (in milliseconds). Note that this is not the RTT of an ICMP echo, as ICMP packets are often blocked by NATs and node has poor support for raw sockets. This value is derived from the RTT of one of the query packets, which is usually quite accurate, but may add a bit due to server lag. | +| **queryPort** | number | Indicates on which port the query was done on, 0 if this is not applicable. | | **raw** | object | Contains all information received from the server in a disorganized format. | Note that `raw` (or **unstable**) objects contents MAY change on a per-protocol basis between GameDig patch releases (although not typical). diff --git a/lib/Results.js b/lib/Results.js index 205689c..f6016e1 100644 --- a/lib/Results.js +++ b/lib/Results.js @@ -29,4 +29,6 @@ export class Results { maxplayers = 0 players = new Players() bots = new Players() + + queryPort = 0 } diff --git a/protocols/core.js b/protocols/core.js index 51730b3..e717dee 100644 --- a/protocols/core.js +++ b/protocols/core.js @@ -78,6 +78,7 @@ export default class Core extends EventEmitter { const state = new Results() await this.run(state) + state.queryPort = options.port // because lots of servers prefix with spaces to try to appear first state.name = (state.name || '').trim()