mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-06 07:07:33 +00:00
fix(protocols/beammp): not matching on given port (#730)
* fix(protocols/beammp): not matching on port * chore: eslint * docs: update CHANGELOG.md * fix: some other cases * fix: sorting on array contaning numbers and other forms of none
This commit is contained in:
parent
5d5273dce3
commit
27709572c9
2 changed files with 15 additions and 1 deletions
|
|
@ -4,6 +4,7 @@
|
|||
* Fix: detect BFBC2 Vietnam DLC as BFBC2 (By @cetteup #713)
|
||||
* Feat: SCP: Secret Laboratory (2020) - Added support (#715, thanks @Draakoor)
|
||||
* Fix: Farming Simulator handle possible missing mod attribute (By @yellowfromseegg #723)
|
||||
* Fix: BeamMP would not match on given port (#730)
|
||||
|
||||
## 5.3.1
|
||||
* Fix: HTTP requests would end up making more retries than needed due to got's internal retry mechanism (#690, thanks @RattleSN4K3)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@ export default class beammp extends Core {
|
|||
master.options = this.options
|
||||
const masterState = await master.runOnceSafe()
|
||||
const servers = masterState.raw.servers
|
||||
const server = servers.find(s => s.ip === this.options.address)
|
||||
const sameIpServers = servers.filter(s => s.ip === this.options.address)
|
||||
const sortedServers = sameIpServers.sort(s => parseInt(s.port))
|
||||
// Cause some don't have ports specified, so we prioritize those who do
|
||||
const server = sortedServers.find(s => s.ip === this.options.address && this.matchPort(s.port))
|
||||
|
||||
if (!server) {
|
||||
throw new Error('Server not found in the master list')
|
||||
|
|
@ -30,4 +33,14 @@ export default class beammp extends Core {
|
|||
state.raw = server
|
||||
if ('version' in state.raw) state.version = state.raw.version
|
||||
}
|
||||
|
||||
matchPort (givenPort) {
|
||||
const parsedPort = parseInt(givenPort)
|
||||
const port = this.options.port
|
||||
if (!port || isNaN(parsedPort)) {
|
||||
return true
|
||||
}
|
||||
|
||||
return port === parsedPort
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue