How to use the portscanner.checkPortStatus 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(status === 'closed');
};

checkPortStatus(3000).then(assertStatus);

checkPortStatus(3000, '127.0.0.1').then(assertStatus);
checkPortStatus(3000, { host: '127.0.0.1' }).then(assertStatus);
checkPortStatus(3000, { timeout: 400 }).then(assertStatus);
checkPortStatus(3000, checkPortCallback);

checkPortStatus(3000, { host: '127.0.0.1' }, checkPortCallback);
checkPortStatus(3000, { timeout: 400 }, checkPortCallback);
checkPortStatus(3000, '127.0.0.1', checkPortCallback);

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
github DefinitelyTyped / DefinitelyTyped / types / portscanner / portscanner-tests.ts View on Github external
const checkPortCallback = (error: Error | null, status: Status) => {
    assert(error === null);
    if (error) assert(error.message === '');
    assert(status === 'open');
    assert(status === 'closed');
};

const assertStatus = (status: Status) => {
    assert(status === 'open');
    assert(status === 'closed');
};

checkPortStatus(3000).then(assertStatus);

checkPortStatus(3000, '127.0.0.1').then(assertStatus);
checkPortStatus(3000, { host: '127.0.0.1' }).then(assertStatus);
checkPortStatus(3000, { timeout: 400 }).then(assertStatus);
checkPortStatus(3000, checkPortCallback);

checkPortStatus(3000, { host: '127.0.0.1' }, checkPortCallback);
checkPortStatus(3000, { timeout: 400 }, checkPortCallback);
checkPortStatus(3000, '127.0.0.1', checkPortCallback);

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);
};
github appium / appium-xcuitest-driver / lib / commands / certificate.js View on Github external
await waitForCondition(async () => {
          try {
            return (await checkPortStatus(tmpPort, host)) === 'open';
          } catch (ign) {
            return false;
          }
        }, {
          waitMs: TMPSERVER_STARTUP_TIMEOUT,
github elastic / kibana / src / plugins / elasticsearch / lib / __tests__ / _ensure_elasticsearch.js View on Github external
return new Promise(function (resolve, reject) {
    portscanner.checkPortStatus(9200, '127.0.0.1', function (err, status) {
      if (err) return reject(err);
      if (status === 'closed') return startEs().then(resolve, reject);
      resolve();
    });
  });
}
github ezpaarse-project / ezpaarse / lib / bin / checkconfig.js View on Github external
return new Promise(resolve => {
    portscanner.checkPortStatus(config.EZPAARSE_NODEJS_PORT, '127.0.0.1', (err, status) => {
      if (!err && status == 'open') {
        console.error(fail + ' : Port already in use');
        success = false;
      } else {
        console.log('Available');
        console.log(pass);
      }
      resolve();
    });
  });
}
github arciisine / AlexaMedia / client / local-connect.js View on Github external
function checkIP(ip) {
    count++;
    portscanner.checkPortStatus(5555, ip, function(error, port) {
      if (error || port !== 'open') {
        count--;
        itr();
      } else {
        cb(null, ip);
        cb = function() {};          
      }
    });
  }
github Bastl34 / node-yeelight-wifi / lookup.js View on Github external
return new Promise((resolve,reject) =>
        {
            for(let i in ipAddresses)
            {
                for(let t=1;t<255;++t)
                {
                    let ip = ipAddresses[i] + t;
                    portscanner.checkPortStatus(YEELIGHT_PORT, {host :ip, timeout: PORT_SCAN_TIMEOUT}, (error, status) =>
                    {
                        ++checks;

                        if (status == "open")
                        {
                            //get mac (but it could be that there is no mac because of different (routed) net)
                            arp.getMAC(ip, (err, mac) =>
                            {
                                //check if already added
                                let light = null;
                                if (!err)
                                    light = this.lights.find(light => light.mac === mac);
                                else
                                    light = this.lights.find(light => light.host === ip);

                                if (!light)
github jhen0409 / react-native-debugger / app / middlewares / debuggerAPI.js View on Github external
const preconnect = async (fn, firstTimeout) => {
  if (firstTimeout || (await checkPortStatus(port, host)) !== 'open') {
    preconnectTimeout = setTimeout(() => preconnect(fn), 500);
    return;
  }
  socket = await fn();
};
github TestArmada / magellan / src / util / check_ports.js View on Github external
"/wd/hub/static/resource/hub.html", (seleniumErr) => {
    if (seleniumErr && seleniumErr.code === "ECONNREFUSED") {
      portscanner.checkPortStatus(desiredPort, "127.0.0.1", (error, portStatus) => {
        if (portStatus === "open") {
          return callback(PORT_STATUS_IN_USE);
        } else {
          return callback(PORT_STATUS_AVAILABLE);
        }
      });
    } else {
      logger.log(
          "Found selenium HTTP server at port " + desiredPort + ", port is in use.");
      return callback(PORT_STATUS_IN_USE);
    }
  });
};

portscanner

Asynchronous port scanner for Node.js

MIT
Latest version published 7 years ago

Package Health Score

74 / 100
Full package analysis