Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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);
};
await waitForCondition(async () => {
try {
return (await checkPortStatus(tmpPort, host)) === 'open';
} catch (ign) {
return false;
}
}, {
waitMs: TMPSERVER_STARTUP_TIMEOUT,
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();
});
});
}
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();
});
});
}
function checkIP(ip) {
count++;
portscanner.checkPortStatus(5555, ip, function(error, port) {
if (error || port !== 'open') {
count--;
itr();
} else {
cb(null, ip);
cb = function() {};
}
});
}
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)
const preconnect = async (fn, firstTimeout) => {
if (firstTimeout || (await checkPortStatus(port, host)) !== 'open') {
preconnectTimeout = setTimeout(() => preconnect(fn), 500);
return;
}
socket = await fn();
};
"/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);
}
});
};