Skip to content

Commit

Permalink
feat: make port_query_offset accept a number or an array of numbers (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
podrivo authored Jan 17, 2024
1 parent e01190a commit 1f0563f
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/QueryRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1f0563f

Please sign in to comment.