简体   繁体   中英

Node.js built-in dns module functions are basic

I'm trying to do simple reverse DNS lookups with the dns module built into Node js (I am using v12.18.0) in my React application, but I can't seem to get past the first step in testing the reverse function. Running the following code I noticed I was always getting 0.0.0.0 as the response. The following IP should resolve to something, not found even, but instead it just gives me 0.0.0.0 (not a hostname).

var dns = require('dns');
dns.reverse('192.229.133.221', (err, hosts) => console.log('hosts:', hosts));

Using the chrome developer tools it seems the implementation of reverse and all other functions (some are not even available, like getServers ) is this:

ƒ () {
  if (!arguments.length) return;
  var callback = arguments[arguments.length - 1];

  if (callback && typeof callback === 'function') {
    callback(null, '0.0.0.0');
  }
}

Am I missing something here?

After much googling, I've found that it is not possible to run this code is in a browser, hence why the functions appear to have hard-coded implementations. I thought I should update this post just in case.

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