jsdns
v0.0.4
Published
A simple DNS module for looking up hostnames + the total time taking to lookup the address in ms.
Downloads
5
Maintainers
Readme
JSdns
What?
JSdns is a simple client-side DNS resolver. Supply it with a hostname and it will resolve it to its IPv4 address and FQDN along with the amount of time it took in milliseconds (ms).
Why?
I'm new to the world of JavaScript, learning more and more each day. I'm currently a Jnr DevOps Engineer and this is a way for me to learn and also provide a practical module to use.
How?
- Install JSdns by running:
npm install jsdns --save
- Whatever host you want to lookup (google.co.uk for example), change the 'host' variable inside of the ' ' quotes.
...
var host = 'www.google.co.uk'; //This is the host you want to look up.
...
- The output should be pretty readable. IP addresses and hostnames are clearly indicated as seen below:
1 Jan 00:01:01 - IPv4 Address: 216.58.214.3
1 Jan 00:01:01 - Reverse Lookup for 216.58.214.3: ["lhr26s05-in-f3.1e100.net","lhr26s05-in-f3.1e100.net"]
1 Jan 00:01:01 - DNS Lookup of www.google.co.uk took 24ms
- JSdns now uses dnscache to wrap the dns module methods and provide a caching layer in between. The settings can be adjusted to suit your needs:
var dns = require('dns');
var util = require('util');
dnscache = require('dnscache')({
"enable": true,
"ttl": 300,
"cachesize": 1000
});
...