Socket
Socket
Sign inDemoInstall

distributed-dig

Package Overview
Dependencies
52
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.1.3

.jshintrc

60

ddig-core.js

@@ -174,2 +174,62 @@ // Exports a public function, resolve(), which accepts multiple domains and multiple resolvers.

}
},
formatBytes(bytes, decimals = 2) {
if (bytes === 0) {
return '0 Bytes';
}
try {
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
} catch (error) {
debug('formatBytes() caught an exception: %O', error);
return('%d Bytes', bytes);
}
},
secondsToHms(seconds) {
if (seconds) {
try {
seconds = Number(seconds);
var h = Math.floor(seconds / 3600);
var m = Math.floor(seconds % 3600 / 60);
var s = Math.floor(seconds % 3600 % 60);
return ('0' + h).slice(-2) + ' hours, ' + ('0' + m).slice(-2) + ' minutes, ' + ('0' + s).slice(-2) + ' seconds';
} catch (error) {
debug('secondsToHms() caught an exception: %O', error);
// an unexpected error occurred; return the original value
return('%d seconds', seconds);
}
} else {
return('<invalid>');
}
},
getColourLevelDesc(level) {
const colourLevel = ['Colours Disabled', '16 Colours (Basic)', '256 Colours', '16 Million Colours (True Colour)'];
try {
if ((level > 3 || level < 0) || (level == undefined)) {
//The level passed isn't in our range so detect it
const chalk = require('chalk');
level = chalk.supportsColor.level;
if (level == undefined) {
level = 0;
}
}
return (colourLevel[level]);
} catch (error) {
debug('getColourLevelDesc() caught an exception: %O', error);
return('Unknown');
}
}

@@ -176,0 +236,0 @@ };

6

distributed-dig.js

@@ -123,3 +123,3 @@ #!/usr/bin/env node

// Check for the config file in the "home" directory
if (fs.existsSync(homedir + '//' + configFileName)) {
if (fs.existsSync(homedir + '/' + configFileName)) {
debug('[%s] found in [%s]', configFileName, homedir);

@@ -130,3 +130,3 @@ // Config file found in homedir so remember the path

// Check for the config file in the application's root directory
if (fs.existsSync(configFilePath + '//' + configFileName)) {
if (fs.existsSync(configFilePath + '/' + configFileName)) {
// Config file found in application root directory

@@ -223,3 +223,3 @@ debug('[%s] found in [%s]', configFileName, configFilePath);

const help = require('./help');
help.helpScreen();
help.helpScreen(argv.verbose);
} else if (argv.listResolvers) {

@@ -226,0 +226,0 @@ printUsingConfigFile();

module.exports = {
helpScreen: function () {
helpScreen: function (verbose) {
// Platform independent end-of-line character
var endOfLine = require('os').EOL;
const endOfLine = require('os').EOL;
// console colours
// eslint-disable-next-line no-unused-vars
const colours = require('colors');
const chalk = require('chalk');
// parse package.json for the version number

@@ -12,34 +11,57 @@ const package = require('./package.json');

// Display help screen
console.log('%s [a.k.a %s]'.cyan, package.name, Object.keys(package.bin)[0]);
console.log('Read the docs: '.green + package.homepage);
console.log('Support & bugs: '.magenta + package.bugs.url);
console.log(chalk.blue('%s [a.k.a %s]'), package.name, Object.keys(package.bin)[0]);
console.log(chalk.green('Read the docs: ') + package.homepage);
console.log(chalk.magenta('Support & bugs: ') + package.bugs.url);
console.log(endOfLine);
console.log('%s'.italic, package.description);
//console.log(endOfLine);
console.log('VERSION:'.grey);
console.log(chalk.grey('DESCRIPTION:'));
console.log(chalk.italic(' %s'), package.description);
console.log(endOfLine);
console.log(chalk.grey('VERSION:'));
console.log(' ' + package.version);
console.log(endOfLine);
console.log('USAGE:'.grey);
console.log(chalk.grey('USAGE:'));
console.log(' ' + 'ddig domain [domain [domain] ...] [options]');
console.log(endOfLine);
console.log('OPTIONS:'.grey);
console.log(' ' + 'domain [domain [domain] ...] ' + 'Perform DNS lookups on one or more domains'.grey);
console.log(' ' + '--port <number> ' + 'Specify the DNS port [53]'.grey);
console.log(' ' + '--protocol <upd|tcp> ' + 'Specify the DNS protocol [udp]'.grey);
console.log(' ' + '--timeout <number> ' + 'Specify the DNS timeout in milliseconds [2500]'.grey);
console.log(' ' + '--edns <true|false> ' + 'Enable or disable EDNS(0) [false]'.grey);
console.log(' ' + '--config <filename> ' + 'Specify an alternative configuration file'.grey);
console.log(' ' + '--list-resolvers ' + 'List resolvers configured in config file'.grey);
console.log(' ' + '--list-options ' + 'List DNS request options configured in config file'.grey);
console.log(' ' + '--list-defaults ' + 'Print json of default config file settings'.grey);
console.log(' ' + '--verbose ' + 'Outputs more information'.grey);
console.log(' ' + '--no-color ' + 'Switches off colour output'.grey);
console.log(' ' + '--version ' + 'Display version number'.grey);
console.log(' ' + '--help ' + 'Display this help'.grey);
console.log(chalk.grey('OPTIONS:'));
console.log(' ' + 'domain [domain [domain] ...] ' + chalk.grey('Perform DNS lookups on one or more domains'));
console.log(' ' + '--port <number> ' + chalk.grey('Specify the DNS port [53]'));
console.log(' ' + '--protocol <upd|tcp> ' + chalk.grey('Specify the DNS protocol [udp]'));
console.log(' ' + '--timeout <number> ' + chalk.grey('Specify the DNS timeout in milliseconds [2500]'));
console.log(' ' + '--edns <true|false> ' + chalk.grey('Enable or disable EDNS(0) [false]'));
console.log(' ' + '--config <filename> ' + chalk.grey('Specify an alternative configuration file'));
console.log(' ' + '--list-resolvers ' + chalk.grey('List resolvers configured in config file'));
console.log(' ' + '--list-options ' + chalk.grey('List DNS request options configured in config file'));
console.log(' ' + '--list-defaults ' + chalk.grey('Print json of default config file settings'));
console.log(' ' + '--verbose ' + chalk.grey('Outputs more information'));
console.log(' ' + '--no-color ' + chalk.grey('Switches off colour output'));
console.log(' ' + '--version ' + chalk.grey('Display version number'));
console.log(' ' + '--help ' + chalk.grey('Display this help'));
console.log(endOfLine);
console.log('EXAMPLES:'.grey);
console.log(chalk.grey('EXAMPLES:'));
console.log(' ddig www.example.com');
console.log(' ddig www.example.com --verbose');
console.log(' ddig example.com www.example.com --timeout 5000');
// Display more information if `verbose` is enabled
if (verbose) {
const os = require('os');
const ddig = require('./ddig-core');
console.log(endOfLine);
console.log(chalk.grey('SYSTEM:'));
console.log(' Hostname ' + chalk.blue(os.hostname()));
console.log(' Uptime ' + chalk.blue(ddig.secondsToHms(os.uptime())));
console.log(' Platform ' + chalk.blue(os.platform()));
console.log(' O/S ' + chalk.blue(os.type()));
console.log(' O/S release ' + chalk.blue(os.release()));
console.log(' CPU architecture ' + chalk.blue(os.arch()));
console.log(' CPU cores ' + chalk.blue(os.cpus().length));
console.log(' CPU model ' + chalk.blue(os.cpus()[0].model));
console.log(' Free memory ' + chalk.blue(ddig.formatBytes(os.freemem())));
console.log(' Total memory ' + chalk.blue(ddig.formatBytes(os.totalmem())));
console.log(' Home directory ' + chalk.blue(os.homedir()));
console.log(' Temp directory ' + chalk.blue(os.tmpdir()));
console.log(' Console width ' + chalk.blue(process.stdout.columns));
console.log(' Console height ' + chalk.blue(process.stdout.rows));
console.log(' Colour support ' + chalk.blue(ddig.getColourLevelDesc()));
}
}
};
};
{
"name": "distributed-dig",
"version": "1.1.2",
"version": "1.1.3",
"description": "A utility which makes DNS lookup requests across multiple DNS resolvers and collates the results.",

@@ -40,2 +40,3 @@ "main": "distributed-dig.js",

"dependencies": {
"chalk": "^3.0.0",
"colors": "^1.4.0",

@@ -49,7 +50,7 @@ "columnify": "^1.5.4",

"prettyjson": "^1.2.1",
"yargs": "^14.0.0"
"yargs": "^14.2.0"
},
"devDependencies": {
"eslint": "^6.4.0"
"eslint": "^6.6.0"
}
}

@@ -270,2 +270,13 @@ # distributed-dig

### [1.1.3] - November 13<sup>th</sup> 2019
#### Changed
* Added `--verbose` support tp `--help` to display more information.
* Dabbled with using `chalk` instead of `colors` (on `--help` output).
* Updated dependency `yargs` to version 14.2.0
* Fixed a cross-platform file path separator bug.
---
### [1.1.2] - September 25<sup>th</sup> 2019

@@ -272,0 +283,0 @@

# To Do
* Better handle domains which have multiple `A` records [moteefe.com].
* Better handle domains which have multiple `A` records [moteefe.com] or [fuse.fuseuniversal.com].
* `ddig fuse.fuseuniversal.com --verbose` the IP address picked for the leftmost column appears to be the last one in the rightmost column's list.
```text
• fuse.fuseuniversal.com 52.30.90.176 Verisign DNS (Primary) 49ms fuse.fuseuniversal.com --> 34.247.233.174
64.6.64.6 fuse.fuseuniversal.com --> 52.30.90.176
• fuse.fuseuniversal.com 34.247.233.174 Comodo Secure DNS (Secondary) 68ms fuse.fuseuniversal.com --> 52.30.90.176
8.20.247.20 fuse.fuseuniversal.com --> 34.247.233.174
```
* Include TTL in `--verbose` output (*increase recommended console width accordingly*).
* Look into **whois** and **geo-location** support (`node-whois` `node-xwhois`).
* Look into **whois** and **geo-location** support | (`node-whois`, `node-xwhois`, [`ip-geolocate`](https://www.npmjs.com/package/ip-geolocate) [ipstack.com](https://ipstack.com/)).
* Look into short command-line switches.

@@ -7,0 +17,0 @@ * Use `findup-sync` to find config file if not in current directory.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc