Fix: Join specified server if SRV records could not be resolved

This commit is contained in:
lluiscab 2018-08-23 17:36:03 +02:00 committed by GitHub
parent 81b94f95ca
commit 3a4a3ee8e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,13 +13,15 @@ module.exports = function (client, options) {
} else if (options.port === 25565 && net.isIP(options.host) === 0 && options.host !== 'localhost') {
dns.resolveSrv('_minecraft._tcp.' + options.host, function (err, addresses) {
if (err) {
console.log(err)
client.setSocket(net.connect(options.port, options.host))
return;
}
if (addresses && addresses.length > 0) {
client.setSocket(net.connect(addresses[0].port, addresses[0].name))
} else {
client.setSocket(net.connect(options.port, options.host))
return;
}
client.emit('error', 'Could not resolve server address');
})
} else {
client.setSocket(net.connect(options.port, options.host))