jsdns

0.0.4 • Public • Published

JSdns

npm version

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?

  1. Install JSdns by running:
npm install jsdns --save
  1. 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.
...
  1. 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 
  1. 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
});
...

Package Sidebar

Install

npm i jsdns

Weekly Downloads

0

Version

0.0.4

License

MIT

Last publish

Collaborators

  • iamliam