2013-07-10 16:52:47 +02:00
|
|
|
var dns = require('dns');
|
|
|
|
|
2013-07-10 12:02:48 +02:00
|
|
|
module.exports = require('./gamespy3').extend({
|
|
|
|
init: function() {
|
|
|
|
this._super();
|
2013-07-12 11:12:02 +02:00
|
|
|
this.pretty = 'Minecraft';
|
2013-07-10 12:02:48 +02:00
|
|
|
this.maxAttempts = 2;
|
2013-07-10 12:40:41 +02:00
|
|
|
this.options.port = 25565;
|
2013-07-10 16:52:47 +02:00
|
|
|
},
|
|
|
|
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;
|
|
|
|
|
2013-07-10 16:56:07 +02:00
|
|
|
if(srvhost.match(/\d+\.\d+\.\d+\.\d+/)) {
|
|
|
|
self.options.address = srvhost;
|
2013-07-10 16:52:47 +02:00
|
|
|
c();
|
|
|
|
} else {
|
|
|
|
// resolve yet again
|
|
|
|
fallback(srvhost);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return fallback(host);
|
|
|
|
});
|
2013-07-10 12:02:48 +02:00
|
|
|
}
|
|
|
|
});
|