dnc

CLI tool to check domain names configuration and statistics
Log | Files | Refs | README | LICENSE

commit 85ba7fcee01ee7832c7d9bf1e95e4ef8a865ca63
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Fri, 21 Feb 2014 00:32:29 +0100

Initial Commit

Diffstat:
ALICENSE | 24++++++++++++++++++++++++
AREADME.md | 46++++++++++++++++++++++++++++++++++++++++++++++
Abin/dnc | 32++++++++++++++++++++++++++++++++
Aconfig.json | 6++++++
Aindex.js | 1+
Alib/dnc.js | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apackage.json | 40++++++++++++++++++++++++++++++++++++++++
7 files changed, 273 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,24 @@ +Copyright (c) 2014, Frederic Cambus +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md @@ -0,0 +1,46 @@ +# dnc + +## Description + +dnc (Domain Name Checker), is a CLI tool to check domain names configuration and statistics. + + +## Installation + +Install the program : + + npm install -g dnc + +## Usage + +Start dnc by invoking `dnc`. + +## Configuration + +Configuration options are set in the `~/.dnc` file. If dnc cannot find an user defined configuration file in the home directory, the bundled `config.json` if used instead. + +Example configuration with two domains : + + { + "domains": [ + "cambus.net", + "echojs.com" + ] + } + +## Example + +Here is the output of running dnc with the default configuration file : + +![dnc Screenshot](http://www.cambus.net/content/2014/02/dnc.png) + +## License + +dnc is released under the BSD 2-Clause license. See `LICENSE` file for details. + +## Author + +dnc is developed by Frederic Cambus + +- Site : http://www.cambus.net +- Twitter: http://twitter.com/fcambus diff --git a/bin/dnc b/bin/dnc @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +/*****************************************************************************/ +/* */ +/* dnc 0.1.0 (c) by Frederic Cambus 2014 */ +/* https://github.com/fcambus/dnc */ +/* */ +/* Created: 2014/02/11 */ +/* Last Updated: 2014/02/21 */ +/* */ +/* dnc is released under the BSD 2-Clause license. */ +/* See LICENSE file for details. */ +/* */ +/*****************************************************************************/ + +var fs = require('fs'); +var log = require('npmlog'); +var dnc = require('../lib/dnc'); + +var config = require("../config.json"); + +log.info("", "dnc is running. Press Ctrl+C to stop"); + +fs.readFile(process.env.HOME + '/.dnc', function(error, data) { + if (!error) { + config = JSON.parse(data); + } else { + log.warn("", "Can't read ~/.dnc file, using default configuration"); + } + + dnc(config); +}); diff --git a/config.json b/config.json @@ -0,0 +1,6 @@ +{ + "domains": [ + "cambus.net", + "echojs.com" + ] +} diff --git a/index.js b/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/dnc'); diff --git a/lib/dnc.js b/lib/dnc.js @@ -0,0 +1,124 @@ +/*****************************************************************************/ +/* */ +/* dnc 0.1.0 (c) by Frederic Cambus 2014 */ +/* https://github.com/fcambus/dnc */ +/* */ +/* Created: 2014/02/11 */ +/* Last Updated: 2014/02/21 */ +/* */ +/* dnc is released under the BSD 2-Clause license. */ +/* See LICENSE file for details. */ +/* */ +/*****************************************************************************/ + +var dns = require('dns'); + + + +/**[ NPM Modules ]************************************************************/ + +var async = require('async'); +var alexa = require('alexarank'); +var request = require('request'); + +var Intl = require('intl'); +var Table = require('cli-table'); + + + +/**[ dnc ]********************************************************************/ + +module.exports = function(config) { + + var table = new Table({ + head: ['Domain', 'NS', 'IPv4', 'IPv6', 'Alexa'] + }); + + async.forEach(config.domains, function(domain, callback) { + + var site = { + ns: '', + ipv4: '', + ipv6: '', + alexa: '' + }; + + async.series([ + + /**[ Get Alexa Traffic Rank ]*************************************/ + + function(callback) { + alexa(domain, function(error, result) { + if (!error && result.rank) { + site.alexa = new Intl.NumberFormat().format(result.rank); + } + + callback(); + }); + }, + + /**[ Get Name Servers ]*******************************************/ + + function(callback) { + dns.resolveNs(domain, function(error, addresses) { + if (!error) { + for (var item in addresses) { + site.ns += addresses[item] + "\n"; + } + } + + callback(); + }); + }, + + /**[ Get A records ]**********************************************/ + + function(callback) { + dns.resolve4(domain, function(error, addresses) { + if (!error) { + for (var item in addresses) { + site.ipv4 += addresses[item] + "\n"; + } + } + + callback(); + }); + }, + + /**[ Get AAAA records ]*******************************************/ + + function(callback) { + dns.resolve6(domain, function(error, addresses) { + if (!error) { + for (var item in addresses) { + site.ipv6 += addresses[item] + "\n"; + } + } + + callback(); + }); + } + ], function(error) { + + /**[ Populate table ]*********************************************/ + + table.push( + [domain, site.ns.trim(), site.ipv4.trim(), site.ipv6.trim(), site.alexa] + ); + + callback(); + }); + + }, function(error) { + + /**[ Sort and display table ]*****************************************/ + + table.sort(function(a, b) { + if (a[0] < b[0]) return -1; + if (a[0] > b[0]) return 1; + return 0; + }); + + console.log(table.toString()); + }); +}; diff --git a/package.json b/package.json @@ -0,0 +1,40 @@ +{ + "name": "dnc", + "version": "0.1.0", + "description": "A tool to check domain names configuration and statistics", + "main": "index.js", + "preferGlobal": "true", + "bin": { + "dnc": "./bin/dnc" + }, + "repository": { + "type": "git", + "url": "https://github.com/fcambus/dnc" + }, + "keywords": [ + "alexa", + "dns", + "domain", + "name", + "check", + "monitor" + ], + "author": { + "name": "Frederic Cambus", + "url": "http://www.cambus.net" + }, + "licenses": [{ + "type": "BSD", + "url": "https://github.com/fcambus/dnc/blob/master/LICENSE" + }], + "bugs": { + "url": "https://github.com/fcambus/dnc/issues" + }, + "dependencies": { + "alexarank": "~0.1.0", + "async": "~0.2.10", + "cli-table": "~0.3.0", + "npmlog": "0.0.6", + "intl": "~0.1.2" + } +}