Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,11 @@
var exec = require('child_process').exec;
module.exports = function (iface, callback) {
exec("cat /sys/class/net/" + iface + "/address", function (err, out) {
if (err) {
callback(err, null);
return;
}
callback(null, out.trim().toLowerCase());
});
};

View File

@@ -0,0 +1,16 @@
var exec = require('child_process').exec;
module.exports = function (iface, callback) {
exec("networksetup -getmacaddress " + iface, function (err, out) {
if (err) {
callback(err, null);
return;
}
var match = /[a-f0-9]{2}(:[a-f0-9]{2}){5}/.exec(out.toLowerCase());
if (!match) {
callback("did not find a mac address", null);
return;
}
callback(null, match[0]);
});
};

View File

@@ -0,0 +1,16 @@
var exec = require('child_process').exec;
module.exports = function (iface, callback) {
exec("ifconfig " + iface, function (err, out) {
if (err) {
callback(err, null);
return;
}
var match = /[a-f0-9]{2}(:[a-f0-9]{2}){5}/.exec(out.toLowerCase());
if (!match) {
callback("did not find a mac address", null);
return;
}
callback(null, match[0].toLowerCase());
});
};

View File

@@ -0,0 +1,28 @@
var exec = require('child_process').exec;
var regexRegex = /[-\/\\^$*+?.()|[\]{}]/g;
function escape(string) {
return string.replace(regexRegex, '\\$&');
}
module.exports = function (iface, callback) {
exec("ipconfig /all", function (err, out) {
if (err) {
callback(err, null);
return;
}
var match = new RegExp(escape(iface)).exec(out);
if (!match) {
callback("did not find interface in `ipconfig /all`", null);
return;
}
out = out.substring(match.index + iface.length);
match = /[A-Fa-f0-9]{2}(\-[A-Fa-f0-9]{2}){5}/.exec(out);
if (!match) {
callback("did not find a mac address", null);
return;
}
callback(null, match[0].toLowerCase().replace(/\-/g, ':'));
});
};