diff options
author | Evan Lucas <evanlucas@me.com> | 2015-04-22 17:05:29 -0500 |
---|---|---|
committer | Evan Lucas <evanlucas@me.com> | 2015-04-24 07:53:16 -0500 |
commit | 4abe2fa1cfcc434952570c1c979dd4ce150fba67 (patch) | |
tree | 38ff3f63ca1e507928d85c6f1be296f363a46b05 /lib | |
parent | 1bef71747678c19c7214048de5b9e3848889248d (diff) | |
download | node-new-4abe2fa1cfcc434952570c1c979dd4ce150fba67.tar.gz |
net: add lookup option to Socket.prototype.connect
Allows customization of the lookup function used when
Socket.prototype.connect is called using a hostname.
PR-URL: https://github.com/iojs/io.js/pull/1505
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/net.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/net.js b/lib/net.js index ce2033f9da..867e1df7cc 100644 --- a/lib/net.js +++ b/lib/net.js @@ -916,6 +916,9 @@ function lookupAndConnect(self, options) { return; } + if (options.lookup && typeof options.lookup !== 'function') + throw new TypeError('options.lookup should be a function.'); + var dnsopts = { family: options.family, hints: 0 @@ -927,7 +930,8 @@ function lookupAndConnect(self, options) { debug('connect: find host ' + host); debug('connect: dns options ' + dnsopts); self._host = host; - dns.lookup(host, dnsopts, function(err, ip, addressType) { + var lookup = options.lookup || dns.lookup; + lookup(host, dnsopts, function(err, ip, addressType) { self.emit('lookup', err, ip, addressType); // It's possible we were destroyed while looking this up. |