Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b07bc5d

Browse filesBrowse 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 <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
1 parent a2ad216 commit b07bc5d
Copy full SHA for b07bc5d

File tree

Expand file treeCollapse file tree

3 files changed

+10
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+10
-7
lines changed
Open diff view settings
Collapse file

‎doc/api/net.markdown‎

Copy file name to clipboardExpand all lines: doc/api/net.markdown
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
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

Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+1-1Lines changed: 1 addition & 1 deletion
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
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-net-dns-lookup.js
+8-6Lines changed: 8 additions & 6 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.