Is it possible to get client's hostname in Node / Express?
Something similiar to req.connection.remoteAddress
which is used to obtain client's IP.
Here's a example:
var http = require('http'),
dns = require('dns');
http.createServer(function (req, res) {
var ip = req.connection.remoteAddress;
res.writeHead(200, {'Content-Type': 'text/html'});
dns.reverse(ip, function(err, hostnames) {
res.write("Ip: " + ip + "<br />");
res.end("Your hostname(s) are " + hostnames.join("; "));
});
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
Read more on the official Node.js documentation website: http://nodejs.org/docs/v0.6.18/api/dns.html#dns_dns_reverse_ip_callback
Have you tried searching the Node.js documentation?