GeezerVison is showing github.com — net: emit host in lookup event · nodejs/node@b07bc5d
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file 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 number | Diff line number | Diff line change |
|---|
@@ -317,6 +317,7 @@ Not applicable to UNIX sockets. | 317 | 317 | * `err` {Error|Null} The error object. See [`dns.lookup()`][]. | 318 | 318 | * `address` {String} The IP address. | 319 | 319 | * `family` {String|Null} The address type. See [`dns.lookup()`][]. | | 320 | +* `host` {String} The hostname. | 320 | 321 |
| 321 | 322 | ### Event: 'timeout' | 322 | 323 |
| |
Collapse file Copy file name to clipboardExpand all lines: lib/net.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -963,7 +963,7 @@ function lookupAndConnect(self, options) { | 963 | 963 | self._host = host; | 964 | 964 | var lookup = options.lookup || dns.lookup; | 965 | 965 | lookup(host, dnsopts, function(err, ip, addressType) { | 966 | | - self.emit('lookup', err, ip, addressType); | | 966 | + self.emit('lookup', err, ip, addressType, host); | 967 | 967 |
| 968 | 968 | // It's possible we were destroyed while looking this up. | 969 | 969 | // XXX it would be great if we could cancel the promise returned by | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-net-dns-lookup.js +8-6Lines changed: 8 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -10,12 +10,14 @@ var server = net.createServer(function(client) { | 10 | 10 | }); | 11 | 11 |
| 12 | 12 | 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 | + }); | 19 | 21 | }); | 20 | 22 |
| 21 | 23 | process.on('exit', function() { | |
|