Comparing version 0.0.1 to 1.0.0
{ | ||
"author": { | ||
"name": "Alan Hoffmeister", | ||
"email": "contato@cranic.com.br", | ||
"url": "https://github.com/cranic" | ||
}, | ||
"name": "portastic", | ||
"description": "Programmatically find open ports with Node.js", | ||
"version": "0.0.1", | ||
"homepage": "https://github.com/cranic/node-portastic", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/cranic/node-portastic.git" | ||
}, | ||
"main" : "./app.js", | ||
"bin" : { | ||
"portastic" : "./bin/portastic" | ||
}, | ||
"scripts" : { | ||
"test" : "vows --spec" | ||
}, | ||
"dependencies": { | ||
"coffee-script": "1.3.x", | ||
"async" : "0.1.x", | ||
"commander" : "1.0.x" | ||
}, | ||
"engines": { | ||
"node": ">=0.8.x" | ||
} | ||
} | ||
"name": "portastic", | ||
"version": "1.0.0", | ||
"description": "Pure javascript swiss knife for port management", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha --tdd --bail test/**/*-test.js", | ||
"travis": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- -R spec test/**/*-test.js && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls && rm -rf ./coverage" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/alanhoff/node-portastic.git" | ||
}, | ||
"keywords": [ | ||
"port", | ||
"management", | ||
"open ports", | ||
"find open", | ||
"interface" | ||
], | ||
"author": "Alan Hoffmeister <alanhoffmeister@gmail.com>", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/alanhoff/node-portastic/issues" | ||
}, | ||
"bin": { | ||
"portastic": "./bin/portastic" | ||
}, | ||
"homepage": "https://github.com/alanhoff/node-portastic#readme", | ||
"dependencies": { | ||
"bluebird": "^2.9.34", | ||
"commander": "^2.8.1", | ||
"debug": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "^3.2.0", | ||
"coveralls": "^2.11.4", | ||
"istanbul": "^0.3.17", | ||
"mocha": "^2.2.5" | ||
} | ||
} |
171
README.md
@@ -1,75 +0,148 @@ | ||
#Portastic | ||
# portastic | ||
[![Coverage Status](https://coveralls.io/repos/alanhoff/node-portastic/badge.svg?branch=master)][0] | ||
[![Travis](https://travis-ci.org/alanhoff/node-portastic.svg)][1] | ||
[![Dependencies](https://david-dm.org/alanhoff/node-portastic.svg)][2] | ||
Programmatically find open ports with Node.js | ||
Pure javascript swiss knife for port management. Find open ports, monitor ports | ||
and other port relates things. | ||
#### Installation | ||
### API | ||
To install Portastic you can simply use NPM: | ||
* `portastic.test(port, [interface , [callback]])` | ||
npm install portastic | ||
Test if a port is open. If a callback | ||
is provided it will be called with an `error` parameter and a second parameter | ||
with a `boolean` that tells if the port is open or not. If a callback is not | ||
provided the return value will be a promise that will be fullfied with the | ||
result. | ||
#### Usage | ||
```javascript | ||
var portastic = require('portastic'); | ||
Finding all opened doors within a range: | ||
portastic.test(8080) | ||
.then(function(isOpen){ | ||
console.log('Port 8080 is %s', isOpen ? 'open' : 'closed'); | ||
}); | ||
``` | ||
port = require('portastic'); | ||
* `portastic.find(options, [interface, [callback]])` | ||
options = { | ||
min : 8000, | ||
mas : 8005 | ||
} | ||
Retrieve a list of open ports between `min` and `max`, if a callback is not | ||
provided this method will resolve a promise with the results. Options can be: | ||
port.find(options, function(err, data){ | ||
if(err) | ||
throw err; | ||
console.log(data); | ||
}); | ||
* `min` The minimum port number to start with | ||
* `max` The maximum port number to scan | ||
* `retrieve` How many ports to collect | ||
If you wan't to retrieve just one or more doors you can pass it in the options: | ||
```javascript | ||
var portastic = require('portastic'); | ||
options = { | ||
min : 8000, | ||
max : 8005, | ||
retrieve : 1 | ||
} | ||
portastic.find({ | ||
min: 8000, | ||
max: 8080 | ||
}) | ||
.then(function(ports){ | ||
console.log('Ports available between 8000 and 8080 are: %s', | ||
ports.join(', ')); | ||
}); | ||
``` | ||
You can also test ports: | ||
* `portastic.filter(ports..., [interface, [callback]])` | ||
port.test(80, function(err, data){ | ||
if(err) | ||
throw err; | ||
Test a list of ports and return the open ones. If a callback is not provided | ||
this method will resolve a promise with the results | ||
if(data == false) | ||
console.log('The port isn\'t opened.'); | ||
else | ||
console.log('The port is opened!'); | ||
}); | ||
```javascript | ||
var portastic = require('portastic'); | ||
If you wan't to test an array of door, you sure can: | ||
portastic.filter([8080, 8081, 8082]) | ||
.then(function(ports){ | ||
console.log('The available ports are: %s', ports.join(', ')); | ||
}); | ||
``` | ||
port.test([80, 93, 8001, 22], function(err, data){ | ||
if(err) | ||
throw err; | ||
* `portastic.Monitor(ports...)` | ||
// 'data' will be an array with the opened doors only | ||
console.log('Opened doors:', data); | ||
}); | ||
Monitor is an `EventEmitter` that emits `open` when a monitored port is | ||
available and `close` when the port has closed. | ||
#### Command line | ||
```javascript | ||
var portastic = require('portastic'); | ||
var monitor = new portastic.Monitor([8080, 8081, 8082]); | ||
You can use Portastic in the command line too: | ||
monitor.on('open', function(port){ | ||
console.log('Port %s is open', port); | ||
}); | ||
npm install -g portastic | ||
monitor.on('close', function(port){ | ||
console.log('Port %s is closed', port); | ||
}); | ||
This will install portastic globally, now it's up to you to call it. Display the help with: | ||
setTimeout(function(){ | ||
monitor.stop(); // Stops the monitoring after 5 seconds | ||
}, 5000); | ||
``` | ||
portastic -h | ||
### Command line | ||
#### Tests | ||
It's also possible to use `portastic` as a command line utility, you just need | ||
to install it globally with `npm install -g portastic`. Here is the help command | ||
output. | ||
If you wan't to run tests on portastic locally you will need to follow this steps: | ||
``` | ||
cd /path/to/portastic/folder | ||
npm install vows | ||
npm test | ||
Usage: portastic [options] [command] | ||
Commands: | ||
test|t <port> Test if a port is closed or open | ||
find|f [options] <min> <max> Find ports that are available to use | ||
filter|i <ports...> Find ports that are open whithin a list of ports | ||
monitor|m <ports...> Monitor a list of ports and logs to the terminal when port state had changed | ||
Options: | ||
-h, --help output usage information | ||
-V, --version output the version number | ||
``` | ||
### Testing | ||
```bash | ||
git clone git@github.com:alanhoff/node-portastic.git | ||
cd node-portastic | ||
npm install && npm test | ||
``` | ||
### Debugging | ||
To see debug messages you must set your enviroment variable `DEBUG` to `*` or | ||
`portastic:*`, example: | ||
```bash | ||
DEBUG=portastic:\* npm test | ||
``` | ||
### License (ISC) | ||
``` | ||
Copyright (c) 2015, Alan Hoffmeister <alanhoffmeister@gmail.com> | ||
Permission to use, copy, modify, and distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
``` | ||
[0]: https://coveralls.io/github/alanhoff/node-portastic | ||
[1]: https://travis-ci.org/alanhoff/node-portastic | ||
[2]: https://david-dm.org/alanhoff/node-portastic |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
190
1
0
149
0
0
11682
4
7
3
+ Addedbluebird@^2.9.34
+ Addeddebug@^2.2.0
+ Addedbluebird@2.11.0(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedms@2.0.0(transitive)
- Removedasync@0.1.x
- Removedcoffee-script@1.3.x
- Removedasync@0.1.22(transitive)
- Removedcoffee-script@1.3.3(transitive)
- Removedcommander@1.0.5(transitive)
- Removedkeypress@0.1.0(transitive)
Updatedcommander@^2.8.1