net: emit host in lookup event
Previously, we emitted ip and addressType. This change includes the host as the last argument to the lookup event. PR-URL: https://github.com/nodejs/node/pull/5598 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
This commit is contained in:
parent
08085c49b6
commit
545b8fd8d8
@ -317,6 +317,7 @@ Not applicable to UNIX sockets.
|
|||||||
* `err` {Error|Null} The error object. See [`dns.lookup()`][].
|
* `err` {Error|Null} The error object. See [`dns.lookup()`][].
|
||||||
* `address` {String} The IP address.
|
* `address` {String} The IP address.
|
||||||
* `family` {String|Null} The address type. See [`dns.lookup()`][].
|
* `family` {String|Null} The address type. See [`dns.lookup()`][].
|
||||||
|
* `host` {String} The hostname.
|
||||||
|
|
||||||
### Event: 'timeout'
|
### Event: 'timeout'
|
||||||
|
|
||||||
|
@ -969,7 +969,7 @@ function lookupAndConnect(self, options) {
|
|||||||
self._host = host;
|
self._host = host;
|
||||||
var lookup = options.lookup || dns.lookup;
|
var lookup = options.lookup || dns.lookup;
|
||||||
lookup(host, dnsopts, function(err, ip, addressType) {
|
lookup(host, dnsopts, function(err, ip, addressType) {
|
||||||
self.emit('lookup', err, ip, addressType);
|
self.emit('lookup', err, ip, addressType, host);
|
||||||
|
|
||||||
// It's possible we were destroyed while looking this up.
|
// It's possible we were destroyed while looking this up.
|
||||||
// XXX it would be great if we could cancel the promise returned by
|
// XXX it would be great if we could cancel the promise returned by
|
||||||
|
@ -10,10 +10,12 @@ var server = net.createServer(function(client) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.listen(common.PORT, '127.0.0.1', function() {
|
server.listen(common.PORT, '127.0.0.1', function() {
|
||||||
net.connect(common.PORT, 'localhost').on('lookup', function(err, ip, type) {
|
net.connect(common.PORT, 'localhost')
|
||||||
|
.on('lookup', function(err, ip, type, host) {
|
||||||
assert.equal(err, null);
|
assert.equal(err, null);
|
||||||
assert.equal(ip, '127.0.0.1');
|
assert.equal(ip, '127.0.0.1');
|
||||||
assert.equal(type, '4');
|
assert.equal(type, '4');
|
||||||
|
assert.equal(host, 'localhost');
|
||||||
ok = true;
|
ok = true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user