From 1cafb4eb86b221f927b35fe54ebce834ab859387 Mon Sep 17 00:00:00 2001 From: Michael Morrison Date: Mon, 3 Feb 2014 16:38:10 -0600 Subject: [PATCH] Add warning when connection port is unknown. --- bin/gamedig.js | 1 + lib/index.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/bin/gamedig.js b/bin/gamedig.js index b6ea33d..37d9a1d 100644 --- a/bin/gamedig.js +++ b/bin/gamedig.js @@ -21,6 +21,7 @@ for(var key in argv) { var Gamedig = require('../lib/index'); if(debug) Gamedig.debug = true; +Gamedig.isCommandLine = true; Gamedig.query( options, function(state) { diff --git a/lib/index.js b/lib/index.js index b59e0b9..66c6846 100644 --- a/lib/index.js +++ b/lib/index.js @@ -44,6 +44,20 @@ Gamedig = { query.udpSocket = udpSocket; query.type = options.type; + if(!('port' in query.options) && ('port_query' in query.options)) { + if(Gamedig.isCommandLine) { + process.stderr.write( + "Warning! This game is so old, that we don't know" + +" what the server's connection port is. We've guessed that" + +" the query port for "+query.type+" is "+query.options.port_query+"." + +" If you know the connection port for this type of server, please let" + +" us know on the GameDig issue tracker, thanks!\n" + ); + } + query.options.port = query.options.port_query; + delete query.options.port_query; + } + // copy over options for(var i in options) query.options[i] = options[i];