From 1f0563f7d2f1f9d690d303eae4bed7846f84471f Mon Sep 17 00:00:00 2001 From: Pedro Ivo Hudson Date: Wed, 17 Jan 2024 18:14:01 -0300 Subject: [PATCH] feat: make port_query_offset accept a number or an array of numbers (#471) * feat: add port_query_offset_alt * feat: port_query_offset can now handle arrays of numbers * back to previous state * refactor gameQueryPortOffset ifs * simpler code --- lib/QueryRunner.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/QueryRunner.js b/lib/QueryRunner.js index 4e54805..c74af84 100644 --- a/lib/QueryRunner.js +++ b/lib/QueryRunner.js @@ -45,18 +45,21 @@ export default class QueryRunner { }) } + let portOffsetArray = gameQueryPortOffset + if (!Array.isArray(portOffsetArray)) { + gameQueryPortOffset ? portOffsetArray = [gameQueryPortOffset] : portOffsetArray = [0] + } + if (userOptions.port) { if (!userOptions.givenPortOnly) { - if (gameQueryPortOffset) { addAttemptWithPort(userOptions.port + gameQueryPortOffset) } - + portOffsetArray.forEach((portOffset) => { addAttemptWithPort(userOptions.port + portOffset) }) if (userOptions.port === gameOptions.port && gameQueryPort) { addAttemptWithPort(gameQueryPort) } } - attempts.push(optionsCollection) } else if (gameQueryPort) { addAttemptWithPort(gameQueryPort) } else if (gameOptions.port) { - addAttemptWithPort(gameOptions.port + (gameQueryPortOffset || 0)) + portOffsetArray.forEach((portOffset) => { addAttemptWithPort(gameOptions.port + portOffset) }) } else { // Hopefully the request doesn't need a port. If it does, it'll fail when making the request. attempts.push(optionsCollection)