From 4d31e29e709615e92c491cf9e6801f2602146493 Mon Sep 17 00:00:00 2001 From: xCausxn Date: Sat, 21 Feb 2015 17:21:56 +0000 Subject: [PATCH 01/11] Added onlineplayers Added onlineplayers which utilizes the length of the players array to make it always available. Possible to add bots to this count but i think just players would be best. Updated readme to include this change. --- README.md | 1 + protocols/core.js | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index c7eda54..2ca8c12 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Otherwise, the returned object is guaranteed to contain the following keys: * **name** * **map** * **password**: Boolean +* **onlineplayers** * **maxplayers** * **players**: (array of objects) Each object **may** contain name, ping, score, team, address * **bots**: Same schema as players diff --git a/protocols/core.js b/protocols/core.js index 49cbab7..2f16071 100644 --- a/protocols/core.js +++ b/protocols/core.js @@ -39,9 +39,10 @@ module.exports = Class.extend(EventEmitter,{ name: '', map: '', password: false, - + raw: {}, + onlineplayers: 0, maxplayers: 0, players: [], bots: [] @@ -61,6 +62,9 @@ module.exports = Class.extend(EventEmitter,{ if(this.options.notes) state.notes = this.options.notes; + //Additional Conditionals + if('players' in state) state.onlineplayers = state.players.length; + state.query = {}; if('host' in this.options) state.query.host = this.options.host; if('address' in this.options) state.query.address = this.options.address; @@ -82,7 +86,7 @@ module.exports = Class.extend(EventEmitter,{ }); } this.timers = []; - + if(this.tcpSocket) { this.tcpSocket.destroy(); delete this.tcpSocket; @@ -124,7 +128,7 @@ module.exports = Class.extend(EventEmitter,{ }, parseDns: function(host,c) { var self = this; - + function resolveStandard(host,c) { dns.lookup(host, function(err,address,family) { if(err) return self.fatal(err); @@ -139,7 +143,7 @@ module.exports = Class.extend(EventEmitter,{ var line = addresses[0]; self.options.port = line.port; var srvhost = line.name; - + if(srvhost.match(/\d+\.\d+\.\d+\.\d+/)) { self.options.address = srvhost; c(); @@ -177,8 +181,8 @@ module.exports = Class.extend(EventEmitter,{ return id; }, - - + + trueTest: function(str) { if(typeof str == 'boolean') return str; if(typeof str == 'number') return str != 0; @@ -228,7 +232,7 @@ module.exports = Class.extend(EventEmitter,{ socket.setTimeout(10000); socket.setNoDelay(true); if(this.debug) console.log(address+':'+port+" TCPCONNECT"); - + var writeHook = socket.write; socket.write = function(data) { if(self.debug) console.log(address+':'+port+" TCP--> "+data.toString('hex')); @@ -292,7 +296,7 @@ module.exports = Class.extend(EventEmitter,{ if(!('address' in this.options)) return this.fatal('Attempted to send without setting an address'); if(typeof buffer == 'string') buffer = new Buffer(buffer,'binary'); - + if(this.debug) console.log(this.options.address+':'+this.options.port_query+" UDP--> "+buffer.toString('hex')); this.udpSocket.send(buffer,0,buffer.length,this.options.port_query,this.options.address); }, From 0b55b8ceb48e9b6dd1ba23fd63a187420af6a1d5 Mon Sep 17 00:00:00 2001 From: James Causon Date: Sun, 28 Jun 2015 10:59:07 +0100 Subject: [PATCH 02/11] Added ARK Survival Evolved --- games.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/games.txt b/games.txt index 15da991..343edb5 100644 --- a/games.txt +++ b/games.txt @@ -33,6 +33,7 @@ ageofchivalry|Age of Chivalry|valve aoe2|Age of Empires 2|ase|port_query=27224 alienarena|Alien Arena|quake2|port_query=27910 alienswarm|Alien Swarm|valve +arkse|ARK: Survival Evolved|valve|port=7777,port_query=27015 avp2|Aliens vs Predator 2|gamespy1|port=27888 # avp2010 doesn't really... have a default port or query port # both port and port_query should be specified when used From 6e4688a4c89a4ba964c8662c15f7af3f2c4ffdac Mon Sep 17 00:00:00 2001 From: James Causon Date: Sun, 28 Jun 2015 11:01:09 +0100 Subject: [PATCH 03/11] Removed previous addition (onlineplayers) --- README.md | 1 - protocols/core.js | 4 ---- 2 files changed, 5 deletions(-) diff --git a/README.md b/README.md index 2ca8c12..c7eda54 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,6 @@ Otherwise, the returned object is guaranteed to contain the following keys: * **name** * **map** * **password**: Boolean -* **onlineplayers** * **maxplayers** * **players**: (array of objects) Each object **may** contain name, ping, score, team, address * **bots**: Same schema as players diff --git a/protocols/core.js b/protocols/core.js index 2f16071..1ed7d4d 100644 --- a/protocols/core.js +++ b/protocols/core.js @@ -42,7 +42,6 @@ module.exports = Class.extend(EventEmitter,{ raw: {}, - onlineplayers: 0, maxplayers: 0, players: [], bots: [] @@ -62,9 +61,6 @@ module.exports = Class.extend(EventEmitter,{ if(this.options.notes) state.notes = this.options.notes; - //Additional Conditionals - if('players' in state) state.onlineplayers = state.players.length; - state.query = {}; if('host' in this.options) state.query.host = this.options.host; if('address' in this.options) state.query.address = this.options.address; From 869ca4a4d898521b187bbbb513cda5a5d83778a9 Mon Sep 17 00:00:00 2001 From: xCausxn Date: Sat, 18 Jul 2015 23:09:36 +0100 Subject: [PATCH 04/11] Fix for maxclients on Quake2 --- protocols/quake2.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/protocols/quake2.js b/protocols/quake2.js index 802ad87..e4631e8 100644 --- a/protocols/quake2.js +++ b/protocols/quake2.js @@ -12,7 +12,7 @@ module.exports = require('./core').extend({ this.udpSend('\xff\xff\xff\xff'+this.sendHeader+'\x00',function(buffer) { var reader = self.reader(buffer); - + var header = reader.string({length:4}); if(header != '\xff\xff\xff\xff') return; @@ -76,6 +76,7 @@ module.exports = require('./core').extend({ if('g_needpass' in state.raw) state.password = state.raw.g_needpass; if('mapname' in state.raw) state.map = state.raw.mapname; if('sv_maxclients' in state.raw) state.maxplayers = state.raw.sv_maxclients; + if('maxclients' in state.raw) state.maxplayers = state.raw.maxclients; if('sv_hostname' in state.raw) state.name = state.raw.sv_hostname; self.finish(state); From ae8c13ba694444b39256456def78725955dec1e3 Mon Sep 17 00:00:00 2001 From: xCausxn Date: Sat, 18 Jul 2015 23:13:58 +0100 Subject: [PATCH 05/11] Added quickfix for quake2 hostname Left other ones in there just incase of unforseen compatibility issues. --- protocols/quake2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/protocols/quake2.js b/protocols/quake2.js index e4631e8..5f1f584 100644 --- a/protocols/quake2.js +++ b/protocols/quake2.js @@ -78,6 +78,7 @@ module.exports = require('./core').extend({ if('sv_maxclients' in state.raw) state.maxplayers = state.raw.sv_maxclients; if('maxclients' in state.raw) state.maxplayers = state.raw.maxclients; if('sv_hostname' in state.raw) state.name = state.raw.sv_hostname; + if('hostname' in state.raw) state.name = state.raw.hostname; self.finish(state); return true; From 618e19192cb7085d8eed5b5acdb5b17e11e95bff Mon Sep 17 00:00:00 2001 From: Kristjan Kirpu Date: Mon, 3 Aug 2015 17:05:30 +0300 Subject: [PATCH 06/11] Added gameserver latency to returning data --- package.json | 3 ++- protocols/core.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e472ceb..34938e7 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,8 @@ "request": "~2.51.0", "minimist": "~1.1.0", "varint": "~4.0.0", - "moment": "~2.9.0" + "moment": "~2.9.0", + "jjg-ping": "~1.0.1" }, "bin": { "gamedig": "bin/gamedig.js" diff --git a/protocols/core.js b/protocols/core.js index 1ed7d4d..5d064ac 100644 --- a/protocols/core.js +++ b/protocols/core.js @@ -3,7 +3,8 @@ var EventEmitter = require('events').EventEmitter, net = require('net'), async = require('async'), Class = require('../lib/Class'), - Reader = require('../lib/reader'); + Reader = require('../lib/reader'), + ping = require('jjg-ping'); module.exports = Class.extend(EventEmitter,{ init: function() { @@ -18,6 +19,7 @@ module.exports = Class.extend(EventEmitter,{ this.encoding = 'utf8'; this.byteorder = 'le'; this.delimiter = '\0'; + this.ping = 0; var self = this; this.globalTimeoutTimer = setTimeout(function() { @@ -68,6 +70,7 @@ module.exports = Class.extend(EventEmitter,{ if('port_query' in this.options) state.query.port_query = this.options.port_query; state.query.type = this.type; if('pretty' in this) state.query.pretty = this.pretty; + state.query.server_ping = this.ping; this.reset(); this.finished = true; @@ -107,6 +110,13 @@ module.exports = Class.extend(EventEmitter,{ self.parseDns(options.host,c); } }, + function(c) { + // not sure if this is the best way to ping a host + ping.system.ping(options.host, function(latency, status) { + if(status) self.ping = latency; + }); + c(); + }, function(c) { // calculate query port if needed if(!('port_query' in options) && 'port' in options) { From 01f2115121f0f9510442cb82188550ce5a10b987 Mon Sep 17 00:00:00 2001 From: Kristjan Kirpu Date: Mon, 3 Aug 2015 23:52:32 +0300 Subject: [PATCH 07/11] Added Killing Floor 2 and Battlefield Hardline - not tested --- README.md | 3 +++ games.txt | 2 ++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index c7eda54..f57df42 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ Games List * Age of Empires 2 (aoe2) [[Separate Query Port](#separate-query-port)] * Alien Arena (alienarena) [[Separate Query Port](#separate-query-port)] * Alien Swarm (alienswarm) +* ARK: Survival Evolved (arkse) [[Separate Query Port](#separate-query-port)] * Aliens vs Predator 2 (avp2) * Aliens vs Predator 2010 (avp2010) * America's Army (americasarmy) [[Separate Query Port](#separate-query-port)] @@ -95,6 +96,7 @@ Games List * Battlefield: Bad Company 2 (bfbc2) [[Separate Query Port](#separate-query-port)] * Battlefield 3 (bf3) [[Separate Query Port](#separate-query-port)] * Battlefield 4 (bf4) [[Separate Query Port](#separate-query-port)] +* Battlefield Hardline (bfh) [[Separate Query Port](#separate-query-port)] * Breach (breach) * Breed (breed) * Brink (brink) [[Separate Query Port](#separate-query-port)] @@ -172,6 +174,7 @@ Games List * James Bond: Nightfire (jamesbondnightfire) [[Separate Query Port](#separate-query-port)] * Just Cause 2 Multiplayer (jc2mp) * Killing Floor (killingfloor) [[Separate Query Port](#separate-query-port)] +* Killing Floor 2 (killingfloor2) * Kingpin: Life of Crime (kingpin) [[Separate Query Port](#separate-query-port)] * KISS Psycho Circus (kisspc) [[Separate Query Port](#separate-query-port)] * KzMod (kzmod) diff --git a/games.txt b/games.txt index 343edb5..b528bd1 100644 --- a/games.txt +++ b/games.txt @@ -58,6 +58,7 @@ bf2142|Battlefield 2142|gamespy3|port=16567,port_query=29900 bfbc2|Battlefield: Bad Company 2|battlefield|port=19567,port_query=48888|isBadCompany2 bf3|Battlefield 3|battlefield|port=25200,port_query_offset=22000 bf4|Battlefield 4|battlefield|port=25200,port_query_offset=22000 +bfh|Battlefield Hardline|battlefield|port=25200,port_query_offset=22000 breach|Breach|valve|port=27016 breed|Breed|gamespy2|port=7649 @@ -142,6 +143,7 @@ ironstorm|Iron Storm|gamespy1|port_query=3505 jamesbondnightfire|James Bond: Nightfire|gamespy1|port_query=6550 jc2mp|Just Cause 2 Multiplayer|jc2mp|port=7777|isJc2mp killingfloor|Killing Floor|killingfloor|port=7707,port_query_offset=1 +killingfloor2|Killing Floor 2|valve|port=7777 kingpin|Kingpin: Life of Crime|gamespy1|port=31510,port_query_offset=-10 kisspc|KISS Psycho Circus|gamespy1|port=7777,port_query_offset=1 kzmod|KzMod|valve From c925c7a2494b972cbbdff333c2d202eeb9b5937f Mon Sep 17 00:00:00 2001 From: Kristjan Kirpu Date: Tue, 4 Aug 2015 00:03:07 +0300 Subject: [PATCH 08/11] Added query port to Killing Floor 2 - BF & KF tested now --- games.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/games.txt b/games.txt index b528bd1..df15a50 100644 --- a/games.txt +++ b/games.txt @@ -143,7 +143,7 @@ ironstorm|Iron Storm|gamespy1|port_query=3505 jamesbondnightfire|James Bond: Nightfire|gamespy1|port_query=6550 jc2mp|Just Cause 2 Multiplayer|jc2mp|port=7777|isJc2mp killingfloor|Killing Floor|killingfloor|port=7707,port_query_offset=1 -killingfloor2|Killing Floor 2|valve|port=7777 +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 kzmod|KzMod|valve From 130c2e72d837aa68fe9a2dca4ee044f4d9b1c665 Mon Sep 17 00:00:00 2001 From: Kristjan Kirpu Date: Tue, 4 Aug 2015 00:51:35 +0300 Subject: [PATCH 09/11] Added 7 Days to Die --- games.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/games.txt b/games.txt index df15a50..91d8568 100644 --- a/games.txt +++ b/games.txt @@ -28,7 +28,7 @@ # worldinconflict|World in Conflict|worldinconflict - +7d2d|7 Days to Die|valve|port_quer_offset=1 ageofchivalry|Age of Chivalry|valve aoe2|Age of Empires 2|ase|port_query=27224 alienarena|Alien Arena|quake2|port_query=27910 From 5f345828049cb221dd5ab9fbb6ab27aa3af0f454 Mon Sep 17 00:00:00 2001 From: Kristjan Kirpu Date: Fri, 7 Aug 2015 00:12:37 +0300 Subject: [PATCH 10/11] Removed ping --- package.json | 3 +-- protocols/core.js | 12 +----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 34938e7..e472ceb 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,7 @@ "request": "~2.51.0", "minimist": "~1.1.0", "varint": "~4.0.0", - "moment": "~2.9.0", - "jjg-ping": "~1.0.1" + "moment": "~2.9.0" }, "bin": { "gamedig": "bin/gamedig.js" diff --git a/protocols/core.js b/protocols/core.js index 5d064ac..1ed7d4d 100644 --- a/protocols/core.js +++ b/protocols/core.js @@ -3,8 +3,7 @@ var EventEmitter = require('events').EventEmitter, net = require('net'), async = require('async'), Class = require('../lib/Class'), - Reader = require('../lib/reader'), - ping = require('jjg-ping'); + Reader = require('../lib/reader'); module.exports = Class.extend(EventEmitter,{ init: function() { @@ -19,7 +18,6 @@ module.exports = Class.extend(EventEmitter,{ this.encoding = 'utf8'; this.byteorder = 'le'; this.delimiter = '\0'; - this.ping = 0; var self = this; this.globalTimeoutTimer = setTimeout(function() { @@ -70,7 +68,6 @@ module.exports = Class.extend(EventEmitter,{ if('port_query' in this.options) state.query.port_query = this.options.port_query; state.query.type = this.type; if('pretty' in this) state.query.pretty = this.pretty; - state.query.server_ping = this.ping; this.reset(); this.finished = true; @@ -110,13 +107,6 @@ module.exports = Class.extend(EventEmitter,{ self.parseDns(options.host,c); } }, - function(c) { - // not sure if this is the best way to ping a host - ping.system.ping(options.host, function(latency, status) { - if(status) self.ping = latency; - }); - c(); - }, function(c) { // calculate query port if needed if(!('port_query' in options) && 'port' in options) { From 2ced1ab45bbc470a82ab75c47cac068c8f58ebe7 Mon Sep 17 00:00:00 2001 From: Kristjan Kirpu Date: Sat, 8 Aug 2015 23:20:30 +0300 Subject: [PATCH 11/11] Added game - Unturned --- README.md | 4 +++- games.txt | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f57df42..383d043 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ Games List ###Supported +* 7 Days to Die (7d2d) * Age of Chivalry (ageofchivalry) * Age of Empires 2 (aoe2) [[Separate Query Port](#separate-query-port)] * Alien Arena (alienarena) [[Separate Query Port](#separate-query-port)] @@ -174,7 +175,7 @@ Games List * James Bond: Nightfire (jamesbondnightfire) [[Separate Query Port](#separate-query-port)] * Just Cause 2 Multiplayer (jc2mp) * Killing Floor (killingfloor) [[Separate Query Port](#separate-query-port)] -* Killing Floor 2 (killingfloor2) +* 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)] * KzMod (kzmod) @@ -281,6 +282,7 @@ Games List * Turok 2 (turok2) [[Separate Query Port](#separate-query-port)] * Universal Combat (universalcombat) [[Separate Query Port](#separate-query-port)] * Unreal (unreal) [[Separate Query Port](#separate-query-port)] +* unturned (unturned) [[Separate Query Port](#separate-query-port)] * Unreal Tournament (ut) [[Separate Query Port](#separate-query-port)] * Unreal Tournament 2003 (ut2003) [[Separate Query Port](#separate-query-port)] * Unreal Tournament 2004 (ut2004) [[Separate Query Port](#separate-query-port)] diff --git a/games.txt b/games.txt index 91d8568..4e07d2c 100644 --- a/games.txt +++ b/games.txt @@ -260,6 +260,7 @@ turok2|Turok 2|gamespy1|port_query=12880 universalcombat|Universal Combat|ase|port=1135,port_query_offset=123 unreal|Unreal|gamespy1|port=7777,port_query_offset=1 +unturned|unturned|valve|port=27015,port_query=27016 ut|Unreal Tournament|gamespy1|port=7777,port_query_offset=1 ut2003|Unreal Tournament 2003|unreal2|port=7757,port_query_offset=1 ut2004|Unreal Tournament 2004|ut2004|port=7777,port_query_offset=1