Skip to content

Commit d1483f0

Browse files
entertainyouevanlucas
authored andcommitted
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: #5598 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Evan Lucas <[email protected]>
1 parent 6ea6b64 commit d1483f0

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

doc/api/net.markdown

+1
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ Not applicable to UNIX sockets.
317317
* `err` {Error|Null} The error object. See [`dns.lookup()`][].
318318
* `address` {String} The IP address.
319319
* `family` {String|Null} The address type. See [`dns.lookup()`][].
320+
* `host` {String} The hostname.
320321

321322
### Event: 'timeout'
322323

lib/net.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ function lookupAndConnect(self, options) {
963963
self._host = host;
964964
var lookup = options.lookup || dns.lookup;
965965
lookup(host, dnsopts, function(err, ip, addressType) {
966-
self.emit('lookup', err, ip, addressType);
966+
self.emit('lookup', err, ip, addressType, host);
967967

968968
// It's possible we were destroyed while looking this up.
969969
// XXX it would be great if we could cancel the promise returned by

test/parallel/test-net-dns-lookup.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ var server = net.createServer(function(client) {
1010
});
1111

1212
server.listen(common.PORT, '127.0.0.1', function() {
13-
net.connect(common.PORT, 'localhost').on('lookup', function(err, ip, type) {
14-
assert.equal(err, null);
15-
assert.equal(ip, '127.0.0.1');
16-
assert.equal(type, '4');
17-
ok = true;
18-
});
13+
net.connect(common.PORT, 'localhost')
14+
.on('lookup', function(err, ip, type, host) {
15+
assert.equal(err, null);
16+
assert.equal(ip, '127.0.0.1');
17+
assert.equal(type, '4');
18+
assert.equal(host, 'localhost');
19+
ok = true;
20+
});
1921
});
2022

2123
process.on('exit', function() {

0 commit comments

Comments
 (0)