mirror of
https://github.com/unmojang/node-minecraft-protocol.git
synced 2025-09-28 05:35:56 -04:00
Connect to a server's SRV record if they specify one
This commit is contained in:
parent
8760ff55bc
commit
d0664f37b4
@ -2,6 +2,7 @@ var net = require('net')
|
||||
, EventEmitter = require('events').EventEmitter
|
||||
, util = require('util')
|
||||
, protocol = require('./protocol')
|
||||
, dns = require('dns')
|
||||
, createPacketBuffer = protocol.createPacketBuffer
|
||||
, parsePacket = protocol.parsePacket
|
||||
, debug = protocol.debug
|
||||
@ -69,7 +70,13 @@ Client.prototype.setSocket = function(socket) {
|
||||
|
||||
Client.prototype.connect = function(port, host) {
|
||||
var self = this;
|
||||
self.setSocket(net.connect(port, host));
|
||||
dns.resolveSrv("_minecraft._tcp." + host, function(err, addresses) {
|
||||
if (addresses) {
|
||||
self.setSocket(net.connect(addresses[0].port, addresses[0].name));
|
||||
} else {
|
||||
self.setSocket(net.connect(port, host));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.end = function(reason) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user