diff --git a/games.txt b/games.txt index 63abd0a..edaf57e 100644 --- a/games.txt +++ b/games.txt @@ -125,6 +125,7 @@ graw|Ghost Recon: Advanced Warfighter|gamespy2|port_query=15250 graw2|Ghost Recon: Advanced Warfighter 2|gamespy2|port_query=16250 giantscitizenkabuto|Giants: Citizen Kabuto|gamespy1|port_query=8911 globaloperations|Global Operations|gamespy1|port_query=28672 +geneshift|Geneshift|geneshift|port=11235 ges|GoldenEye: Source|valve gore|Gore|gamespy1|port=27777,port_query_offset=1 gunmanchronicles|Gunman Chronicles|valve @@ -171,7 +172,7 @@ mtavc|Multi Theft Auto: Vice City|ase|port=22003,port_query_offset=123 mtasa|Multi Theft Auto: San Andreas|ase|port=22003,port_query_offset=123 mumble|Mumble|mumble|port=64738,port_query=27800|doc_notes=mumble mumbleping|Mumble|mumbleping|port=64738|doc_notes=mumble -mutantfactions|Mutant Factions|mutantfactions|port=11235 +mutantfactions|Mutant Factions|geneshift|port=11235 nascarthunder2004|Nascar Thunder 2004|gamespy2|port_query=13333 netpanzer|netPanzer|gamespy1|3030 nmrih|No More Room in Hell|valve diff --git a/package-lock.json b/package-lock.json index dd1b011..834d7f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "gamedig", - "version": "0.2.29", + "version": "0.2.30", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/protocols/ase.js b/protocols/ase.js index b7fddcc..d3525d6 100644 --- a/protocols/ase.js +++ b/protocols/ase.js @@ -22,8 +22,7 @@ class Ase extends require('./core') { const value = this.readString(reader); state.raw[key] = value; } - - console.log(reader.rest()); + while(!reader.done()) { const flags = reader.uint(1); const player = {}; diff --git a/protocols/core.js b/protocols/core.js index 1331464..6adf05c 100644 --- a/protocols/core.js +++ b/protocols/core.js @@ -125,15 +125,19 @@ class Core extends EventEmitter { parseDns(host,c) { const resolveStandard = (host,c) => { + if(this.debug) console.log("Standard DNS Lookup: " + host); dns.lookup(host, (err,address,family) => { if(err) return this.fatal(err); + if(this.debug) console.log(address); this.options.address = address; c(); }); }; const resolveSrv = (srv,host,c) => { + if(this.debug) console.log("SRV DNS Lookup: " + srv+'.'+host); dns.resolve(srv+'.'+host, 'SRV', (err,addresses) => { + if(this.debug) console.log(err, addresses); if(err) return resolveStandard(host,c); if(addresses.length >= 1) { const line = addresses[0]; diff --git a/protocols/mutantfactions.js b/protocols/geneshift.js similarity index 56% rename from protocols/mutantfactions.js rename to protocols/geneshift.js index 4c93ef9..dba54d1 100644 --- a/protocols/mutantfactions.js +++ b/protocols/geneshift.js @@ -1,9 +1,9 @@ const request = require('request'); -class MutantFactions extends require('./core') { +class GeneShift extends require('./core') { run(state) { request({ - uri: 'http://mutantfactions.net/game/receiveLobby.php', + uri: 'http://geneshift.net/game/receiveLobby.php', timeout: 3000, }, (e,r,body) => { if(e) return this.fatal('Lobby request error'); @@ -14,7 +14,7 @@ class MutantFactions extends require('./core') { const fields = line.split('::'); const ip = fields[2]; const port = fields[3]; - if(ip === this.options.address && port === this.options.port) { + if(ip === this.options.address && parseInt(port) === this.options.port) { found = fields; break; } @@ -26,18 +26,18 @@ class MutantFactions extends require('./core') { state.raw.country = found[1]; state.name = found[4]; state.map = found[5]; - state.raw.numplayers = found[6]; - state.maxplayers = found[7]; + state.raw.numplayers = parseInt(found[6]); + state.maxplayers = parseInt(found[7]); // fields[8] is unknown? state.raw.rules = found[9]; - state.raw.gamemode = found[10]; - state.raw.gangsters = found[11]; - state.raw.cashrate = found[12]; - state.raw.missions = found[13]; - state.raw.vehicles = found[14]; - state.raw.customweapons = found[15]; - state.raw.friendlyfire = found[16]; - state.raw.mercs = found[17]; + state.raw.gamemode = parseInt(found[10]); + state.raw.gangsters = parseInt(found[11]); + state.raw.cashrate = parseInt(found[12]); + state.raw.missions = !!parseInt(found[13]); + state.raw.vehicles = !!parseInt(found[14]); + state.raw.customweapons = !!parseInt(found[15]); + state.raw.friendlyfire = !!parseInt(found[16]); + state.raw.mercs = !!parseInt(found[17]); // fields[18] is unknown? listen server? state.raw.version = found[19]; @@ -50,4 +50,4 @@ class MutantFactions extends require('./core') { } } -module.exports = MutantFactions; +module.exports = GeneShift; diff --git a/protocols/minecraftping.js b/protocols/minecraftping.js index d9a106f..9f75851 100644 --- a/protocols/minecraftping.js +++ b/protocols/minecraftping.js @@ -2,7 +2,7 @@ const varint = require('varint'), async = require('async'); function varIntBuffer(num) { - return Buffer.alloc(varint.encode(num)); + return Buffer.from(varint.encode(num)); } function buildPacket(id,data) { if(!data) data = Buffer.from([]); diff --git a/protocols/quake2.js b/protocols/quake2.js index e170a8f..b4d7663 100644 --- a/protocols/quake2.js +++ b/protocols/quake2.js @@ -15,7 +15,6 @@ class Quake2 extends require('./core') { const header = reader.string({length:4}); if(header !== '\xff\xff\xff\xff') return; - this.debugBuffer(buffer); let response; if(this.isQuake1) { response = reader.string({length:this.responseHeader.length}); diff --git a/test.sh b/test.sh index 777e552..9c17e1c 100644 --- a/test.sh +++ b/test.sh @@ -1 +1,6 @@ -bin/gamedig.js --debug --type "$1" --host "$2" --port "$3" +#!/bin/bash +PORTPARAM="" +if [[ "$#" > 2 ]]; then + PORTPARAM=$(printf -- "--port %q" "$3") +fi +bin/gamedig.js --output pretty --debug --type "$1" --host "$2" $PORTPARAM