- Version: v8.3.0
- Platform: Windows 10 Pro 1703 x64
- Subsystem: dns
Hey! I am testing out the resolver.cancel method, and I am getting back ENOTFOUND instead of ECANCELLED.
Here's my script:
const{ Resolver }=require('dns');constresolver=newResolver();resolver.setServers(['123.45.67.89'// Not a real DNS Server]);functionreverseLookup(ip){// Variable to test if we got our answer back in timevarmatchfound=false;resolver.reverse(ip,function(err,domains){if(err){// View our errorconsole.error(err);}else{varmatchfound=true;// Found a match, or two.domains.forEach(function(domain){console.log(domain);});}});setTimeout(function(){if(matchfound===false){console.error("Took too long to reverse IP. Cancelling lookup.")resolver.cancel();}},1);// Set to 1 for testing}reverseLookup('8.8.8.8');// google-public-dns-a.google.comOutput:
PS C:\Users\Jorgen\Documents\app_backend\tools> node .\dns-reverse-lookup.js
Took too long to reverse IP. Cancelling lookup.
{ Error: getHostByAddr ENOTFOUND 8.8.8.8
at errnoException (dns.js:53:10)
at QueryReqWrap.onresolve [as oncomplete] (dns.js:239:19)
code: 'ENOTFOUND',
errno: 'ENOTFOUND',
syscall: 'getHostByAddr',
hostname: '8.8.8.8' }
Hey! I am testing out the resolver.cancel method, and I am getting back
ENOTFOUNDinstead ofECANCELLED.Here's my script:
Output: