How to use the portscanner.findAPortNotInUse function in portscanner

To help you get started, we’ve selected a few portscanner examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / portscanner / portscanner-tests.ts View on Github external
assert(error === null);
    if (error) assert(error.message === '');
    assert(port === 3005);
};

const assertPort = (port: number) => {
    assert(port === 3005);
};

// one argument
findAPortNotInUse([3000, 3005, 3006]).then(assertPort);
findAPortNotInUse(3000).then(assertPort);

// two arguments
findAPortNotInUse([3000, 3005, 3006], findPortCallback);
findAPortNotInUse([3000, 3005, 3006], '127.0.0.1').then(assertPort);

findAPortNotInUse(3000, findPortCallback);
findAPortNotInUse(3000, '127.0.0.1').then(assertPort);
findAPortNotInUse(3000, 3010).then(assertPort);

// three arguments
findAPortNotInUse(3000, 3010, '127.0.0.1').then(assertPort);
findAPortNotInUse(3000, 3010, findPortCallback);

// four argumentss
findAPortNotInUse(3000, 3010, '127.0.0.1', findPortCallback);

// one argument
findAPortInUse([3000, 3005, 3006]).then(assertPort);
findAPortInUse(3000).then(assertPort);
github DefinitelyTyped / DefinitelyTyped / types / portscanner / portscanner-tests.ts View on Github external
const assertPort = (port: number) => {
    assert(port === 3005);
};

// one argument
findAPortNotInUse([3000, 3005, 3006]).then(assertPort);
findAPortNotInUse(3000).then(assertPort);

// two arguments
findAPortNotInUse([3000, 3005, 3006], findPortCallback);
findAPortNotInUse([3000, 3005, 3006], '127.0.0.1').then(assertPort);

findAPortNotInUse(3000, findPortCallback);
findAPortNotInUse(3000, '127.0.0.1').then(assertPort);
findAPortNotInUse(3000, 3010).then(assertPort);

// three arguments
findAPortNotInUse(3000, 3010, '127.0.0.1').then(assertPort);
findAPortNotInUse(3000, 3010, findPortCallback);

// four argumentss
findAPortNotInUse(3000, 3010, '127.0.0.1', findPortCallback);

// one argument
findAPortInUse([3000, 3005, 3006]).then(assertPort);
findAPortInUse(3000).then(assertPort);

// two arguments
findAPortInUse([3000, 3005, 3006], findPortCallback);
findAPortInUse([3000, 3005, 3006], '127.0.0.1').then(assertPort);
github DefinitelyTyped / DefinitelyTyped / types / portscanner / portscanner-tests.ts View on Github external
checkPortStatus(3000, '127.0.0.1', { timeout: 400 }).then(assertStatus);
checkPortStatus(3000, '127.0.0.1', { timeout: 400 }, checkPortCallback);

const findPortCallback = (error: Error | null, port: number) => {
    assert(error === null);
    if (error) assert(error.message === '');
    assert(port === 3005);
};

const assertPort = (port: number) => {
    assert(port === 3005);
};

// one argument
findAPortNotInUse([3000, 3005, 3006]).then(assertPort);
findAPortNotInUse(3000).then(assertPort);

// two arguments
findAPortNotInUse([3000, 3005, 3006], findPortCallback);
findAPortNotInUse([3000, 3005, 3006], '127.0.0.1').then(assertPort);

findAPortNotInUse(3000, findPortCallback);
findAPortNotInUse(3000, '127.0.0.1').then(assertPort);
findAPortNotInUse(3000, 3010).then(assertPort);

// three arguments
findAPortNotInUse(3000, 3010, '127.0.0.1').then(assertPort);
findAPortNotInUse(3000, 3010, findPortCallback);

// four argumentss
findAPortNotInUse(3000, 3010, '127.0.0.1', findPortCallback);
github farism / elm-factory / bin / dev.js View on Github external
.option('-m --main [n]', 'application main entry')
  .option('-c --stylesheets [n]', 'application stylesheets entry')
  .option('-h --host [n]', 'dev server address')
  .option('-p --port [n]', 'dev server port')
  .option('-t --template [n]', 'dev server html template file')
  .option('-r --reactor-host [n]', 'elm-reactor address')
  .option('-u --reactor-port [n]', 'elm-reactor port')
  .parse(process.argv)

// load the dev tasks

const opts = program.opts()

opts.host || opts.port
  ? dev(opts) && gulp.start('dev')
  : portscanner.findAPortNotInUse(8000, 9000).then(port => {
      portscanner.findAPortNotInUse(8010, 9000).then(reactorPort => {
        dev(Object.assign({}, opts, {port, reactorPort}))
        gulp.start('dev')
      })
    })
github collab-project / videojs-record / scripts / server.js View on Github external
import portscanner from 'portscanner';
import serveStatic from 'serve-static';

// Configuration for the server.
const PORT = 9999;
const MAX_PORT = PORT + 100;
const HOST = '127.0.0.1'

const app = connect();

// update mimetype
serveStatic.mime.define({'application/wasm': ['wasm']});

app.use(serveStatic(path.join(__dirname, '..')));

portscanner.findAPortNotInUse(PORT, MAX_PORT, HOST, (error, port) => {
    if (error) {
        throw error;
    }

    process.stdout.write(`Serving on http://${HOST}:${port}` + '\n\n');

    app.listen(port);
});
github stevenvachon / broken-link-checker / test / backup / utils.js View on Github external
function getAvailablePort(callback)
{
	portscanner.findAPortNotInUse(3000, 3030, host, function(error, port)
	{
		if (error) throw error;
		callback(port);
	})
}
github pursuit-gg / pursuit-client / public / uploadCaptureFolderBW.html View on Github external
ipc.on('upload', (event, folderPath, uId, spectatorMode, bandwidth) => {
      folder = folderPath;
      userId = uId;
      spectator = spectatorMode;
      console.log('upload', folder, userId, spectator, bandwidth);
      if (bandwidth !== 0) {
        portscanner.findAPortNotInUse(50000, 60000, (err, port) => {
          if (err) {
            console.error(err);
            Sentry.captureException(err);
          }
          createProxy(err ? 1080 : port, bandwidth);
          AWS.config.update({
            httpOptions: { agent: proxyAgent(`socks5://localhost:${err ? 1080 : port}`) },
          });
          uploadFolder(folder, userId, spectator);
        });
      } else {
        uploadFolder(folder, userId, spectator);
      }
    });
github rhinoman / wikifeat / frontend / web_app / node_modules / grunt-contrib-connect / tasks / connect.js View on Github external
function findUnusedPort(port, maxPort, hostname, callback) {
          if (hostname === '0.0.0.0') {
            hostname = '127.0.0.1';
          }

          if (port === 0) {
            async.nextTick(function() {
              callback(null, 0);
            });
          } else {
            portscanner.findAPortNotInUse(port, maxPort, hostname, callback);
          }
        }
github trendscenter / coinstac / packages / coinstac-docker-manager / src / index.js View on Github external
const generateServicePort = (serviceId) => {
  return portscanner.findAPortNotInUse(8100, 49151, '127.0.0.1')
    .then((newPort) => {
      services[serviceId].port = newPort;
      return newPort;
    });
};

portscanner

Asynchronous port scanner for Node.js

MIT
Latest version published 7 years ago

Package Health Score

71 / 100
Full package analysis