/usr/lib/nodejs/macaddress/lib/windows.js is in node-macaddress 0.2.8-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | 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, ':'));
});
};
|