Switch minecraftping type to use core TCP support, move SRV resolving into core

This commit is contained in:
Michael Morrison 2014-02-01 09:47:16 -06:00
parent 55661ae591
commit a3c14a8d42
2 changed files with 81 additions and 132 deletions

View file

@ -6,29 +6,6 @@ module.exports = require('./protocols/gamespy3').extend({
this.pretty = 'Minecraft';
this.maxAttempts = 2;
this.options.port = 25565;
},
parseDns: function(host,c) {
var self = this;
var _super = this._super;
function fallback(h) { _super.call(self,h,c); }
dns.resolve('_minecraft._tcp.'+host, 'SRV', function(err,addresses) {
if(err) return fallback(host);
if(addresses.length >= 1) {
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();
} else {
// resolve yet again
fallback(srvhost);
}
return;
}
return fallback(host);
});
this.srvRecord = '_minecraft._tcp';
}
});