简体   繁体   中英

Is there any way to enumerate all the known hostnames for a server in node.js?

I have a chunk of code like:

http.Server(function(req, res) {
    res.writeHead(200);
    res.end("hello world\n");
}).listen(0, function() {
    port = server.address().port;
    console.log("server listening on: " + port);
});

This works great for getting the port, but I want to print out each possible DNS name that the server is listening on, too (so localhost:8080, foo.com:8080, etc).

I've tried some of the obvious things (like dns.reverse('0.0.0.0') ) and no luck so far. Any ideas?

服务器无法获取所有DNS名称的列表-我现在可以为www.foo.com创建一个0.0.0.0的新DNS条目(假设我拥有foo.com域,但我不会)需要拥有0.0.0.0),而0.0.0.0永远不会知道它(除非并且直到它开始接收到Host:标头设置为www.foo.com的http连接)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM