fix: ignore cached ports when givenPortOnly is set (#710)

closes #709
This commit is contained in:
cetteup 2025-06-09 15:53:45 +02:00 committed by GitHub
parent da78c84c03
commit a2835108d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 4 additions and 2 deletions

View file

@ -7,6 +7,7 @@
* Feat: Update OpenTTD (By @mwkaicz #695) * Feat: Update OpenTTD (By @mwkaicz #695)
* Fix: Skip non-response packets in protocol-battlefield (By @cetteup #704) * Fix: Skip non-response packets in protocol-battlefield (By @cetteup #704)
* Fix: throwing in tcpSend onData callback would crash gamedig (#705, thanks @cetteup) * Fix: throwing in tcpSend onData callback would crash gamedig (#705, thanks @cetteup)
* Fix: ignore cached ports when givenPortOnly is set (By @cetteup #710)
## 5.3.0 ## 5.3.0
* Docs: Arma Reforger query setup note (#670, thanks @xCausxn) * Docs: Arma Reforger query setup note (#670, thanks @xCausxn)

View file

@ -54,7 +54,7 @@ Note that some games might require additional values to be specified.
| **maxRetries** | number | `1` | Number of retries to query server in case of failure. Note that this amount multiplies with the number of attempts. | | **maxRetries** | number | `1` | Number of retries to query server in case of failure. Note that this amount multiplies with the number of attempts. |
| **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. | | **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 (including `socketTimeout`, beware that if this value is smaller (or even equal) to the socket one, the query will always fail). | | **attemptTimeout** | number | `10000` | Milliseconds allowed for an entire query attempt (including `socketTimeout`, beware that if this value is smaller (or even equal) to the socket one, the query will always fail). |
| **givenPortOnly** | boolean | `false` | Only attempt to query server on given port. It will ignore the game's default port. | | **givenPortOnly** | boolean | `false` | Only attempt to query server on given port. Causes any default ports, port offsets or cached ports to be ignored. |
| **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). | | **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. | | **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. | | **requestRules** | boolean | `false` | Valve games only. Additional 'rules' may be fetched into the `raw` key. |

View file

@ -56,7 +56,8 @@ export default class QueryRunner {
const cachedPort = this.portCache[`${userOptions.address}:${userOptions.port}`] const cachedPort = this.portCache[`${userOptions.address}:${userOptions.port}`]
if (cachedPort && optionsCollection.portCache) { // Use any cached port if port caching is enabled and user is not explicitly enforcing their given port
if (cachedPort && optionsCollection.portCache && !userOptions.givenPortOnly) {
addAttemptWithPort(cachedPort) addAttemptWithPort(cachedPort)
} }