var updateHosts = function () { console.info('Updating host list'); var arpscanOpts = { interface: config.api.updateHostsInterface, sudo: true }; arpscan(onArpscanDone, arpscanOpts); };
function searchHost(options, callback) { if (!options.mac && !options.ip) return callback(true); options.mac = options.mac && options.mac.length > 0 ? options.mac : undefined; options.ip = options.ip && options.ip.length > 0 ? options.ip : undefined; var callbackSent = false; arpscanner((err, res) => { if (err || !res) { if (!callbackSent) { callbackSent = true; return callback(err, false); } return; } for (var i = 0; i < res.length; i++) { if (options.mac && res[i].mac == options.mac) return callback(null, res[i].ip); if (options.ip && res[i].mac == options.ip) return callback(null, res[i].mac); } }); }