Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
]
},
"dependencies": {
"arpping": "github:skydiver/arpping",
"crypto-js": "^4.0.0",
"delay": "^4.4.0",
"node-fetch": "^2.6.1",
Expand All @@ -63,5 +62,8 @@
"jest": "^26.5.3",
"nock": "^12.0.3",
"prettier": "^1.19.1"
},
"optionalDependencies": {
"arpping": "github:skydiver/arpping"
}
}
25 changes: 17 additions & 8 deletions src/classes/Zeroconf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const fs = require('fs');
const arpping = require('arpping')({});
let arpping

try {
arpping = require('arpping')({});
} catch ( err ) {
}

class Zeroconf {
/**
Expand All @@ -9,13 +14,17 @@ class Zeroconf {
*/
static getArpTable(ip = null) {
return new Promise((resolve, reject) => {
arpping.discover(ip, (err, hosts) => {
if (err) {
return reject(err);
}
const arpTable = Zeroconf.fixMacAddresses(hosts);
return resolve(arpTable);
});
if ( !arpping ) {
reject(new Error('arpping is not installed'))
} else {
arpping.discover(ip, (err, hosts) => {
if (err) {
return reject(err);
}
const arpTable = Zeroconf.fixMacAddresses(hosts);
return resolve(arpTable);
});
}
});
}

Expand Down