diff options
author | Vsevolod Strukchinsky <floatdrop@yandex-team.ru> | 2013-08-20 18:31:40 +0600 |
---|---|---|
committer | Fedor Indutny <fedor.indutny@gmail.com> | 2013-08-20 21:03:52 +0400 |
commit | edd2fcccf022c7014b374674012283422faa1bed (patch) | |
tree | 745a9da1c962dfeac5c7aacd3fb7794f96fdcfbc /lib/net.js | |
parent | 85d6b783432e1c58084c3bdebf15cf45384f6572 (diff) | |
download | node-new-edd2fcccf022c7014b374674012283422faa1bed.tar.gz |
net: family option in net.connect
`dns.lookup` defaults to selecting IPv4 record even if IPv6 is available
for the desired zone. Generally, this approach works, but if IPv4
address is unavailable - there'll be no other way to opt-out and connect using
IPv6 address than calling `dns.lookup` and passing it to `.connect()`
directly.
This commit adds `family` option to `net.connect` method to figure out
this issue.
Diffstat (limited to 'lib/net.js')
-rw-r--r-- | lib/net.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/net.js b/lib/net.js index 2a80100bb1..52f171b5a6 100644 --- a/lib/net.js +++ b/lib/net.js @@ -857,8 +857,9 @@ Socket.prototype.connect = function(options, cb) { } else { var host = options.host; + var family = options.family || 4; debug('connect: find host ' + host); - require('dns').lookup(host, function(err, ip, addressType) { + require('dns').lookup(host, family, function(err, ip, addressType) { self.emit('lookup', err, ip, addressType); // It's possible we were destroyed while looking this up. |