This commit is contained in:
arnaucode
2017-02-03 08:56:51 +01:00
parent c4b7414770
commit 112745d6fa
1585 changed files with 450241 additions and 0 deletions

2
www/node_modules/portfinder/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules
npm-debug.log

21
www/node_modules/portfinder/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,21 @@
language: node_js
node_js:
- "0.8"
- "0.10"
- "0.11"
before_install:
- travis_retry npm install -g npm
- travis_retry npm install
script:
- npm test
matrix:
allow_failures:
- node_js: "0.11"
notifications:
email:
- travis@nodejitsu.com
irc: "irc.freenode.org#nodejitsu"

22
www/node_modules/portfinder/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,22 @@
node-portfinder
Copyright (c) 2012 Charlie Robbins
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

38
www/node_modules/portfinder/README.md generated vendored Normal file
View File

@@ -0,0 +1,38 @@
# node-portfinder [![Build Status](https://api.travis-ci.org/indexzero/node-portfinder.svg)](https://travis-ci.org/indexzero/node-portfinder)
## Installation
### Installing npm (node package manager)
``` bash
curl http://npmjs.org/install.sh | sh
```
### Installing node-portfinder
``` bash
$ [sudo] npm install portfinder
```
## Usage
The `portfinder` module has a simple interface:
``` js
var portfinder = require('portfinder');
portfinder.getPort(function (err, port) {
//
// `port` is guaranteed to be a free port
// in this scope.
//
});
```
By default `portfinder` will start searching from `8000`. To change this simply set `portfinder.basePort`.
## Run Tests
``` bash
$ npm test
```
#### Author: [Charlie Robbins][0]
#### License: MIT/X11
[0]: http://nodejitsu.com

218
www/node_modules/portfinder/lib/portfinder.js generated vendored Normal file
View File

@@ -0,0 +1,218 @@
/*
* portfinder.js: A simple tool to find an open port on the current machine.
*
* (C) 2011, Charlie Robbins
*
*/
var fs = require('fs'),
net = require('net'),
path = require('path'),
async = require('async'),
mkdirp = require('mkdirp').mkdirp;
//
// ### @basePort {Number}
// The lowest port to begin any port search from
//
exports.basePort = 8000;
//
// ### @basePath {string}
// Default path to begin any socket search from
//
exports.basePath = '/tmp/portfinder'
//
// ### function getPort (options, callback)
// #### @options {Object} Settings to use when finding the necessary port
// #### @callback {function} Continuation to respond to when complete.
// Responds with a unbound port on the current machine.
//
exports.getPort = function (options, callback) {
if (!callback) {
callback = options;
options = {};
}
options.port = options.port || exports.basePort;
options.host = options.host || null;
options.server = options.server || net.createServer(function () {
//
// Create an empty listener for the port testing server.
//
});
function onListen () {
options.server.removeListener('error', onError);
options.server.close();
callback(null, options.port)
}
function onError (err) {
options.server.removeListener('listening', onListen);
if (err.code !== 'EADDRINUSE' && err.code !== 'EACCES') {
return callback(err);
}
exports.getPort({
port: exports.nextPort(options.port),
host: options.host,
server: options.server
}, callback);
}
options.server.once('error', onError);
options.server.once('listening', onListen);
options.server.listen(options.port, options.host);
};
//
// ### function getPorts (count, options, callback)
// #### @count {Number} The number of ports to find
// #### @options {Object} Settings to use when finding the necessary port
// #### @callback {function} Continuation to respond to when complete.
// Responds with an array of unbound ports on the current machine.
//
exports.getPorts = function (count, options, callback) {
if (!callback) {
callback = options;
options = {};
}
var lastPort = null;
async.timesSeries(count, function(index, asyncCallback) {
if (lastPort) {
options.port = exports.nextPort(lastPort);
}
exports.getPort(options, function (err, port) {
if (err) {
asyncCallback(err);
} else {
lastPort = port;
asyncCallback(null, port);
}
});
}, callback);
};
//
// ### function getSocket (options, callback)
// #### @options {Object} Settings to use when finding the necessary port
// #### @callback {function} Continuation to respond to when complete.
// Responds with a unbound socket using the specified directory and base
// name on the current machine.
//
exports.getSocket = function (options, callback) {
if (!callback) {
callback = options;
options = {};
}
options.mod = options.mod || 0755;
options.path = options.path || exports.basePath + '.sock';
//
// Tests the specified socket
//
function testSocket () {
fs.stat(options.path, function (err) {
//
// If file we're checking doesn't exist (thus, stating it emits ENOENT),
// we should be OK with listening on this socket.
//
if (err) {
if (err.code == 'ENOENT') {
callback(null, options.path);
}
else {
callback(err);
}
}
else {
//
// This file exists, so it isn't possible to listen on it. Lets try
// next socket.
//
options.path = exports.nextSocket(options.path);
exports.getSocket(options, callback);
}
});
}
//
// Create the target `dir` then test connection
// against the socket.
//
function createAndTestSocket (dir) {
mkdirp(dir, options.mod, function (err) {
if (err) {
return callback(err);
}
options.exists = true;
testSocket();
});
}
//
// Check if the parent directory of the target
// socket path exists. If it does, test connection
// against the socket. Otherwise, create the directory
// then test connection.
//
function checkAndTestSocket () {
var dir = path.dirname(options.path);
fs.stat(dir, function (err, stats) {
if (err || !stats.isDirectory()) {
return createAndTestSocket(dir);
}
options.exists = true;
testSocket();
});
}
//
// If it has been explicitly stated that the
// target `options.path` already exists, then
// simply test the socket.
//
return options.exists
? testSocket()
: checkAndTestSocket();
};
//
// ### function nextPort (port)
// #### @port {Number} Port to increment from.
// Gets the next port in sequence from the
// specified `port`.
//
exports.nextPort = function (port) {
return port + 1;
};
//
// ### function nextSocket (socketPath)
// #### @socketPath {string} Path to increment from
// Gets the next socket path in sequence from the
// specified `socketPath`.
//
exports.nextSocket = function (socketPath) {
var dir = path.dirname(socketPath),
name = path.basename(socketPath, '.sock'),
match = name.match(/^([a-zA-z]+)(\d*)$/i),
index = parseInt(match[2]),
base = match[1];
if (isNaN(index)) {
index = 0;
}
index += 1;
return path.join(dir, base + index + '.sock');
};

93
www/node_modules/portfinder/package.json generated vendored Normal file
View File

@@ -0,0 +1,93 @@
{
"_args": [
[
{
"raw": "portfinder@0.4.x",
"scope": null,
"escapedName": "portfinder",
"name": "portfinder",
"rawSpec": "0.4.x",
"spec": ">=0.4.0 <0.5.0",
"type": "range"
},
"/home/nau/MEGA/CODI/githubRepos/colspace/www/node_modules/http-server"
]
],
"_from": "portfinder@>=0.4.0 <0.5.0",
"_id": "portfinder@0.4.0",
"_inCache": true,
"_location": "/portfinder",
"_nodeVersion": "0.10.33",
"_npmUser": {
"name": "indexzero",
"email": "charlie.robbins@gmail.com"
},
"_npmVersion": "2.2.0",
"_phantomChildren": {},
"_requested": {
"raw": "portfinder@0.4.x",
"scope": null,
"escapedName": "portfinder",
"name": "portfinder",
"rawSpec": "0.4.x",
"spec": ">=0.4.0 <0.5.0",
"type": "range"
},
"_requiredBy": [
"/http-server"
],
"_resolved": "https://registry.npmjs.org/portfinder/-/portfinder-0.4.0.tgz",
"_shasum": "a3ffadffafe4fb98e0601a85eda27c27ce84ca1e",
"_shrinkwrap": null,
"_spec": "portfinder@0.4.x",
"_where": "/home/nau/MEGA/CODI/githubRepos/colspace/www/node_modules/http-server",
"author": {
"name": "Charlie Robbins",
"email": "charlie.robbins@gmail.com"
},
"bugs": {
"url": "https://github.com/indexzero/node-portfinder/issues"
},
"dependencies": {
"async": "0.9.0",
"mkdirp": "0.5.x"
},
"description": "A simple tool to find an open port on the current machine",
"devDependencies": {
"vows": "0.8.0"
},
"directories": {},
"dist": {
"shasum": "a3ffadffafe4fb98e0601a85eda27c27ce84ca1e",
"tarball": "https://registry.npmjs.org/portfinder/-/portfinder-0.4.0.tgz"
},
"engines": {
"node": ">= 0.8.0"
},
"gitHead": "8c3f20bf1d5ec399262c592f61129a65727004a9",
"homepage": "https://github.com/indexzero/node-portfinder",
"keywords": [
"http",
"ports",
"utilities"
],
"license": "MIT/X11",
"main": "./lib/portfinder",
"maintainers": [
{
"name": "indexzero",
"email": "charlie.robbins@gmail.com"
}
],
"name": "portfinder",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/indexzero/node-portfinder.git"
},
"scripts": {
"test": "vows test/*-test.js --spec"
},
"version": "0.4.0"
}

0
www/node_modules/portfinder/test/fixtures/.gitkeep generated vendored Normal file
View File

View File

@@ -0,0 +1,67 @@
/*
* portfinder-test.js: Tests for the `portfinder` module.
*
* (C) 2011, Charlie Robbins
*
*/
var vows = require('vows'),
assert = require('assert'),
async = require('async'),
http = require('http'),
portfinder = require('../lib/portfinder');
var servers = [];
function createServers (callback) {
var base = 8000;
async.whilst(
function () { return base < 8005 },
function (next) {
var server = http.createServer(function () { });
server.listen(base, next);
base++;
servers.push(server);
}, callback);
}
vows.describe('portfinder').addBatch({
"When using portfinder module": {
"with 5 existing servers": {
topic: function () {
createServers(this.callback);
},
"the getPorts() method with an argument of 3": {
topic: function () {
portfinder.getPorts(3, this.callback);
},
"should respond with the first three available ports (8005, 8006, 8007)": function (err, ports) {
assert.isTrue(!err);
assert.deepEqual(ports, [8005, 8006, 8007]);
}
}
}
}
}).addBatch({
"When using portfinder module": {
"with no existing servers": {
topic: function () {
servers.forEach(function (server) {
server.close();
});
return null;
},
"the getPorts() method with an argument of 3": {
topic: function () {
portfinder.getPorts(3, this.callback);
},
"should respond with the first three available ports (8000, 8001, 80072": function (err, ports) {
assert.isTrue(!err);
assert.deepEqual(ports, [8000, 8001, 8002]);
}
}
}
}
}).export(module);

View File

@@ -0,0 +1,92 @@
/*
* portfinder-test.js: Tests for the `portfinder` module.
*
* (C) 2011, Charlie Robbins
*
*/
var assert = require('assert'),
exec = require('child_process').exec,
net = require('net'),
path = require('path'),
async = require('async'),
vows = require('vows'),
portfinder = require('../lib/portfinder');
var servers = [],
socketDir = path.join(__dirname, 'fixtures'),
badDir = path.join(__dirname, 'bad-dir');
function createServers (callback) {
var base = 0;
async.whilst(
function () { return base < 5 },
function (next) {
var server = net.createServer(function () { }),
name = base === 0 ? 'test.sock' : 'test' + base + '.sock';
server.listen(path.join(socketDir, name), next);
base++;
servers.push(server);
}, callback);
}
vows.describe('portfinder').addBatch({
"When using portfinder module": {
"with 5 existing servers": {
topic: function () {
createServers(this.callback);
},
"the getPort() method": {
topic: function () {
portfinder.getSocket({
path: path.join(socketDir, 'test.sock')
}, this.callback);
},
"should respond with the first free socket (test5.sock)": function (err, socket) {
assert.isTrue(!err);
assert.equal(socket, path.join(socketDir, 'test5.sock'));
}
}
}
}
}).addBatch({
"When using portfinder module": {
"with no existing servers": {
"the getSocket() method": {
"with a directory that doesnt exist": {
topic: function () {
var that = this;
exec('rm -rf ' + badDir, function () {
portfinder.getSocket({
path: path.join(badDir, 'test.sock')
}, that.callback);
});
},
"should respond with the first free socket (test.sock)": function (err, socket) {
assert.isTrue(!err);
assert.equal(socket, path.join(badDir, 'test.sock'));
}
},
"with a directory that exists": {
topic: function () {
portfinder.getSocket({
path: path.join(socketDir, 'exists.sock')
}, this.callback);
},
"should respond with the first free socket (exists.sock)": function (err, socket) {
assert.isTrue(!err);
assert.equal(socket, path.join(socketDir, 'exists.sock'));
}
}
}
}
}
}).addBatch({
"When the tests are over": {
"necessary cleanup should take place": function () {
exec('rm -rf ' + badDir + ' ' + path.join(socketDir, '*'), function () { });
}
}
}).export(module);

67
www/node_modules/portfinder/test/port-finder-test.js generated vendored Normal file
View File

@@ -0,0 +1,67 @@
/*
* portfinder-test.js: Tests for the `portfinder` module.
*
* (C) 2011, Charlie Robbins
*
*/
var vows = require('vows'),
assert = require('assert'),
async = require('async'),
http = require('http'),
portfinder = require('../lib/portfinder');
var servers = [];
function createServers (callback) {
var base = 8000;
async.whilst(
function () { return base < 8005 },
function (next) {
var server = http.createServer(function () { });
server.listen(base, next);
base++;
servers.push(server);
}, callback);
}
vows.describe('portfinder').addBatch({
"When using portfinder module": {
"with 5 existing servers": {
topic: function () {
createServers(this.callback);
},
"the getPort() method": {
topic: function () {
portfinder.getPort(this.callback);
},
"should respond with the first free port (8005)": function (err, port) {
assert.isTrue(!err);
assert.equal(port, 8005);
}
}
}
}
}).addBatch({
"When using portfinder module": {
"with no existing servers": {
topic: function () {
servers.forEach(function (server) {
server.close();
});
return null;
},
"the getPort() method": {
topic: function () {
portfinder.getPort(this.callback);
},
"should respond with the first free port (8000)": function (err, port) {
assert.isTrue(!err);
assert.equal(port, 8000);
}
}
}
}
}).export(module);