mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-27 13:14:41 -04:00
Fix: Join specified server if SRV records could not be resolved
This commit is contained in:
parent
81b94f95ca
commit
3a4a3ee8e8
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user