filezilla-check
Advanced tools
Comparing version 0.1.2 to 0.1.3
39
cli.js
@@ -20,3 +20,4 @@ #!/usr/bin/env node | ||
ProgressBar = require('progress'), | ||
Table = require('cli-table'); | ||
Table = require('cli-table'), | ||
IP = require('ip'); | ||
@@ -47,2 +48,3 @@ var CONCURRENT_REQUESTS = 10, | ||
.option('-s, --sort <sort>', 'Sort by (' + sortByKeys.join('|') + ') default:' + defaultSort, defaultSort) | ||
.option('-i, --ip <IP ADDRESS>', 'Test a single ip address') | ||
.parse(process.argv); | ||
@@ -55,14 +57,6 @@ | ||
function getIptoNumeric (host) { | ||
var addrArray = host.split('.'), | ||
num = 0; | ||
function displayTable() { | ||
var firstKey = _.first(_.pluck(keys, 'key')), | ||
total = 'Total: ' + status.total + ', Open: ' + status.open + ', Closed: ' + status.closed; | ||
for (var i = 0; i < addrArray.length; i++) { | ||
var power = 3 - i; | ||
num += ((parseInt(addrArray[i]) % 256 * Math.pow(256, power))); | ||
} | ||
return num; | ||
} | ||
function displayTable() { | ||
_.each(keys, function (key) { | ||
@@ -72,2 +66,5 @@ key.max = _.max(serverList, function(server) { | ||
})[key.key].length + 5; | ||
if (key.key === firstKey && key.max < total.length) { | ||
key.max = total.length + 3; | ||
} | ||
}); | ||
@@ -93,4 +90,5 @@ | ||
table.push([]); | ||
var total = 'Total: ' + status.total + ', Open: ' + status.open + ', Closed: ' + status.closed; | ||
table.push([total, '', '']); | ||
var totalRule = _.fill(new Array(keys.length), ''); | ||
totalRule[0] = total; | ||
table.push(totalRule); | ||
@@ -157,3 +155,3 @@ console.log('\n' + table.toString()); | ||
host: host, | ||
ip: getIptoNumeric(host) | ||
ip: IP.toLong(host) | ||
}; | ||
@@ -179,3 +177,12 @@ }) | ||
if (program.args.length !== 1) { | ||
if (program.ip) { | ||
keys = _.filter(keys, function(key) { | ||
return ['host', 'status'].indexOf(key.key) !== -1; | ||
}); | ||
serverList.push({ | ||
host: program.ip, | ||
ip: IP.toLong(program.ip) | ||
}); | ||
getServers(); | ||
} else if (program.args.length !== 1) { | ||
console.error('no sitemanager.xml'); | ||
@@ -182,0 +189,0 @@ exit(); |
{ | ||
"name": "filezilla-check", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"npm-shrinkwrap-version": "5.4.0", | ||
@@ -31,2 +31,6 @@ "node-version": "v0.12.4", | ||
}, | ||
"ip": { | ||
"version": "1.0.0", | ||
"resolved": "https://registry.npmjs.org/ip/-/ip-1.0.0.tgz" | ||
}, | ||
"lodash": { | ||
@@ -33,0 +37,0 @@ "version": "3.10.1", |
{ | ||
"name": "filezilla-check", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Checking if the servers are up or not", | ||
@@ -13,2 +13,3 @@ "main": "cli.js", | ||
"commander": "^2.8.1", | ||
"ip": "^1.0.0", | ||
"lodash": "*", | ||
@@ -15,0 +16,0 @@ "portscanner": "*", |
10753
227
8