mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-09-28 13:21:30 +02:00
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
This commit is contained in:
parent
e01190a458
commit
1f0563f7d2
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user