diff --git a/doc/api/net.markdown b/doc/api/net.markdown index 655475bdaa0349..451b5f44ab36ac 100644 --- a/doc/api/net.markdown +++ b/doc/api/net.markdown @@ -317,6 +317,7 @@ Not applicable to UNIX sockets. * `err` {Error|Null} The error object. See [`dns.lookup()`][]. * `address` {String} The IP address. * `family` {String|Null} The address type. See [`dns.lookup()`][]. +* `host` {String} The hostname. ### Event: 'timeout' diff --git a/lib/net.js b/lib/net.js index f75c9b25b86fea..338a50f03ee5e8 100644 --- a/lib/net.js +++ b/lib/net.js @@ -961,7 +961,7 @@ function lookupAndConnect(self, options) { self._host = host; var lookup = options.lookup || dns.lookup; 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. // XXX it would be great if we could cancel the promise returned by diff --git a/test/parallel/test-net-dns-lookup.js b/test/parallel/test-net-dns-lookup.js index 2bcff9143c092d..097bdf8ecae0e0 100644 --- a/test/parallel/test-net-dns-lookup.js +++ b/test/parallel/test-net-dns-lookup.js @@ -10,12 +10,14 @@ var server = net.createServer(function(client) { }); server.listen(common.PORT, '127.0.0.1', function() { - net.connect(common.PORT, 'localhost').on('lookup', function(err, ip, type) { - assert.equal(err, null); - assert.equal(ip, '127.0.0.1'); - assert.equal(type, '4'); - ok = true; - }); + net.connect(common.PORT, 'localhost') + .on('lookup', function(err, ip, type, host) { + assert.equal(err, null); + assert.equal(ip, '127.0.0.1'); + assert.equal(type, '4'); + assert.equal(host, 'localhost'); + ok = true; + }); }); process.on('exit', function() {