mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-14 19:04:59 -05:00
Fix: Join specified server if SRV records could not be resolved
This commit is contained in:
parent
81b94f95ca
commit
3a4a3ee8e8
1 changed files with 5 additions and 3 deletions
|
@ -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…
Reference in a new issue