mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 13:45:37 -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') {
|
} else if (options.port === 25565 && net.isIP(options.host) === 0 && options.host !== 'localhost') {
|
||||||
dns.resolveSrv('_minecraft._tcp.' + options.host, function (err, addresses) {
|
dns.resolveSrv('_minecraft._tcp.' + options.host, function (err, addresses) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log(err)
|
client.setSocket(net.connect(options.port, options.host))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (addresses && addresses.length > 0) {
|
if (addresses && addresses.length > 0) {
|
||||||
client.setSocket(net.connect(addresses[0].port, addresses[0].name))
|
client.setSocket(net.connect(addresses[0].port, addresses[0].name))
|
||||||
} else {
|
return;
|
||||||
client.setSocket(net.connect(options.port, options.host))
|
|
||||||
}
|
}
|
||||||
|
client.emit('error', 'Could not resolve server address');
|
||||||
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
client.setSocket(net.connect(options.port, options.host))
|
client.setSocket(net.connect(options.port, options.host))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user