mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-17 17:25:19 +01:00
Merge pull request #191 from cetteup/feature/no-default-port-attempts
Add givenPortOnly user option
This commit is contained in:
commit
b7c277f042
3 changed files with 9 additions and 3 deletions
|
@ -43,6 +43,7 @@ this query port may work instead. (defaults to protocol default port)
|
|||
will cause many queries to take longer even if the server is online. (default 2000)
|
||||
* **attemptTimeout**: number - Milliseconds allowed for an entire query attempt. This timeout is not commonly hit,
|
||||
as the socketTimeout typically fires first. (default 10000)
|
||||
* **givenPortOnly**: boolean - Only attempt to query server on given port. (default false)
|
||||
* **debug**: boolean - Enables massive amounts of debug logging to stdout. (default false)
|
||||
|
||||
### Return Value
|
||||
|
|
7
bin/gamedig.js
Normal file → Executable file
7
bin/gamedig.js
Normal file → Executable file
|
@ -4,13 +4,15 @@ const Minimist = require('minimist'),
|
|||
Gamedig = require('..');
|
||||
|
||||
const argv = Minimist(process.argv.slice(2), {
|
||||
boolean: ['pretty','debug']
|
||||
boolean: ['pretty','debug','givenPortOnly']
|
||||
});
|
||||
|
||||
const debug = argv.debug;
|
||||
delete argv.debug;
|
||||
const pretty = !!argv.pretty || debug;
|
||||
delete argv.pretty;
|
||||
const givenPortOnly = argv.givenPortOnly;
|
||||
delete argv.givenPortOnly;
|
||||
|
||||
const options = {};
|
||||
for(const key of Object.keys(argv)) {
|
||||
|
@ -34,6 +36,9 @@ if (argv._.length >= 1) {
|
|||
if (debug) {
|
||||
options.debug = true;
|
||||
}
|
||||
if (givenPortOnly) {
|
||||
options.givenPortOnly = true;
|
||||
}
|
||||
|
||||
Gamedig.query(options)
|
||||
.then((state) => {
|
||||
|
|
|
@ -30,7 +30,7 @@ class QueryRunner {
|
|||
const attempts = [];
|
||||
|
||||
if (userOptions.port) {
|
||||
if (gameQueryPortOffset) {
|
||||
if (gameQueryPortOffset && !userOptions.givenPortOnly) {
|
||||
attempts.push({
|
||||
...defaultOptions,
|
||||
...gameOptions,
|
||||
|
@ -38,7 +38,7 @@ class QueryRunner {
|
|||
port: userOptions.port + gameQueryPortOffset
|
||||
});
|
||||
}
|
||||
if (userOptions.port === gameOptions.port && gameQueryPort) {
|
||||
if (userOptions.port === gameOptions.port && gameQueryPort && !userOptions.givenPortOnly) {
|
||||
attempts.push({
|
||||
...defaultOptions,
|
||||
...gameOptions,
|
||||
|
|
Loading…
Reference in a new issue