-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (31 loc) · 1.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var exec = require('child_process').exec;
module.exports = {
get: (successCallback, errorCallback) => {
var command = "arp -a";
exec(command, function(error, stdout, stderr) {
if(error) {
errorCallback(error);
return;
}
var lines = stdout.split("\n");
var output = [];
var interface = "Unknown";
for (x in lines) {
var line = lines[x].trim();
if(line.indexOf('Interface:') !== -1) {
interface = line.trim().replace('Interface: ','');
}
else if(line && line.indexOf('Internet Address') === -1) {
var columns = line.match(/[^ ]+/g);
output.push({
'Interface': interface,
'InternetAddress': columns[0],
'PhysicalAddress': columns[1],
'Type': columns[2]
});
}
}
successCallback(output);
});
}
}