GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — net: emit host in lookup event · nodejs/node@b07bc5d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • net.markdown
  • lib
    • net.js
  • test/parallel
    • test-net-dns-lookup.js
Expand file treeCollapse file tree
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)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.