mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 07:07:33 +00:00
feat: strip Colors (#469)
This commit is contained in:
parent
0a3338320e
commit
5ae12dd494
11 changed files with 47 additions and 38 deletions
59
README.md
59
README.md
|
|
@ -30,44 +30,45 @@ Confused on how this works, or you want to see more? Checkout the [examples](/ex
|
|||
|
||||
## Required Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|:---|:---|:---|
|
||||
| Field | Type | Description |
|
||||
|:---------|:-------|:---------------------------------------------------------------|
|
||||
| **type** | string | One of the game IDs listed in the [games list](GAMES_LIST.md). |
|
||||
| **host** | string | Hostname or IP of the game server. |
|
||||
| **host** | string | Hostname or IP of the game server. |
|
||||
|
||||
## Optional Fields
|
||||
|
||||
| Field | Type | Default | Description |
|
||||
|:---|:---|:---|:---|
|
||||
| **port** | number | Game port | Connection port or query port for the game server. Some games utilize a separate "query" port. If specifying the game port does not seem to work as expected, passing in this query port may work instead. |
|
||||
| **maxAttempts** | number | 1 | Number of attempts to query server in case of failure. |
|
||||
| **socketTimeout** | number | 2000 | Milliseconds to wait for a single packet. Beware that increasing this will cause many queries to take longer even if the server is online. |
|
||||
| **attemptTimeout** | number | 10000 | Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first. |
|
||||
| **givenPortOnly** | boolean | false | Only attempt to query server on given port. It will ignore the game's default port. |
|
||||
| **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. |
|
||||
| **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. |
|
||||
| Field | Type | Default | Description |
|
||||
|:---------------------------|:--------|:----------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **port** | number | Game port | Connection port or query port for the game server. Some games utilize a separate "query" port. If specifying the game port does not seem to work as expected, passing in this query port may work instead. |
|
||||
| **maxAttempts** | number | 1 | Number of attempts to query server in case of failure. |
|
||||
| **socketTimeout** | number | 2000 | Milliseconds to wait for a single packet. Beware that increasing this will cause many queries to take longer even if the server is online. |
|
||||
| **attemptTimeout** | number | 10000 | Milliseconds allowed for an entire query attempt. This timeout is not commonly hit, as the socketTimeout typically fires first. |
|
||||
| **givenPortOnly** | boolean | false | Only attempt to query server on given port. It will ignore the game's default port. |
|
||||
| **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. |
|
||||
| **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. |
|
||||
|
||||
## Query Response
|
||||
|
||||
The returned state object will contain the following keys:
|
||||
|
||||
| Key | Type | Description |
|
||||
|:---|:---|:---|
|
||||
| **name** | string | Server name. |
|
||||
| **map** | string | Server map. |
|
||||
| **password** | boolean | If a password is required. |
|
||||
| **numplayers** | number | Number of players connected. Data via [A2S_INFO](https://developer.valvesoftware.com/wiki/Server_queries#A2S_INFO). |
|
||||
| **maxplayers** | number | Maximum number of connected players. |
|
||||
| **players** | array of objects | Note that this could be of a different length compared to **numplayers**. Data via [A2S_PLAYER](https://developer.valvesoftware.com/wiki/Server_queries#A2S_PLAYER). |
|
||||
| **players.name** | string | If the player's name is unknown, the string will be empty. |
|
||||
| **players.raw** | object | Additional information about the player if available. |
|
||||
| **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. |
|
||||
| **raw** | object | Contains all information received from the server in a disorganized format. |
|
||||
| Key | Type | Description |
|
||||
|:-----------------|:-----------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **name** | string | Server name. |
|
||||
| **map** | string | Server map. |
|
||||
| **password** | boolean | If a password is required. |
|
||||
| **numplayers** | number | Number of players connected. Data via [A2S_INFO](https://developer.valvesoftware.com/wiki/Server_queries#A2S_INFO). |
|
||||
| **maxplayers** | number | Maximum number of connected players. |
|
||||
| **players** | array of objects | Note that this could be of a different length compared to **numplayers**. Data via [A2S_PLAYER](https://developer.valvesoftware.com/wiki/Server_queries#A2S_PLAYER). |
|
||||
| **players.name** | string | If the player's name is unknown, the string will be empty. |
|
||||
| **players.raw** | object | Additional information about the player if available. |
|
||||
| **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. |
|
||||
| **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).
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue