diff --git a/README.md b/README.md index 576204c..7ef52c1 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,7 @@ Games List * Killing Floor 2 (killingfloor2) [[Separate Query Port](#separate-query-port)] * Kingpin: Life of Crime (kingpin) [[Separate Query Port](#separate-query-port)] * KISS Psycho Circus (kisspc) [[Separate Query Port](#separate-query-port)] +* DMP - KSP Multiplayer (kspdmp) [[Separate Query Port](#separate-query-port)] * KzMod (kzmod) * Left 4 Dead (left4dead) * Left 4 Dead 2 (left4dead2) diff --git a/games.txt b/games.txt index 687b12e..97a880e 100644 --- a/games.txt +++ b/games.txt @@ -152,6 +152,7 @@ killingfloor|Killing Floor|killingfloor|port=7707,port_query_offset=1 killingfloor2|Killing Floor 2|valve|port=7777,port_query=27015 kingpin|Kingpin: Life of Crime|gamespy1|port=31510,port_query_offset=-10 kisspc|KISS Psycho Circus|gamespy1|port=7777,port_query_offset=1 +kspdmp|DMP - KSP Multiplayer|kspdmp|port=6702,port_query_offset=1 kzmod|KzMod|valve left4dead|Left 4 Dead|valve left4dead2|Left 4 Dead 2|valve diff --git a/protocols/kspdmp.js b/protocols/kspdmp.js new file mode 100644 index 0000000..328f988 --- /dev/null +++ b/protocols/kspdmp.js @@ -0,0 +1,38 @@ +const request = require('request'); + +class Kspdmp extends require('./core') { + run(state) { + request({ + uri: 'http://'+this.options.address+':'+this.options.port_query, + timeout: this.options.socketTimeout + }, (e,r,body) => { + if(e) return this.fatal('HTTP error'); + let json; + try { + json = JSON.parse(body); + } catch(e) { + return this.fatal('Invalid JSON'); + } + + for (const one of json.players) { + state.players.push({name:one.nickname,team:one.team}); + } + + for (const key of Object.keys(json)) { + state.raw[key] = json[key]; + } + state.name = json.server_name; + state.maxplayers = json.max_players; + if (json.players) { + const split = json.players.split(', '); + for (const name of split) { + state.players.push({name:name}); + } + } + + this.finish(state); + }); + } +} + +module.exports = Kspdmp; diff --git a/protocols/terraria.js b/protocols/terraria.js index 36fb345..451fa4d 100644 --- a/protocols/terraria.js +++ b/protocols/terraria.js @@ -4,7 +4,7 @@ class Terraria extends require('./core') { run(state) { request({ uri: 'http://'+this.options.address+':'+this.options.port_query+'/v2/server/status', - timeout: 3000, + timeout: this.options.socketTimeout, qs: { players: 'true', token: this.options.token