feat: Add Factorio support (#527)

* Update eco protocol to include player names and fixed problems when using eco webinterface behind a proxy

* changelog + readability

* Typo

* Typo

* Added Factorio

* wrong comment

* CHANGELOG
This commit is contained in:
Vito0912 2024-01-31 22:38:17 +01:00 committed by GitHub
parent 3416e8c21a
commit 2338b82307
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 37 additions and 1 deletions

25
protocols/factorio.js Normal file
View file

@ -0,0 +1,25 @@
import Core from './core.js'
export default class factorio extends Core {
async run (state) {
if (!this.options.port) this.options.port = 34197
// Don't use the tcp ping probing
this.usedTcp = true
const request = await this.request({
url: `https://multiplayer.factorio.com/get-game-details/${this.options.address}:${this.options.port}`,
responseType: 'json'
})
const serverInfo = request
state.name = serverInfo.name
state.password = serverInfo.has_password
state.numplayers = serverInfo.players?.length || 0 // players is undefined if there are no players
state.maxplayers = serverInfo.max_players
state.players = serverInfo.players?.map(player => ({ name: player, raw: {} })) || []
state.raw = serverInfo
}
}