;
(function (win) {
var os = require('os');
var ifaces = os.networkInterfaces();
function NetworkUtil() {
var _self = this;
this.getMac = function(family){
var mac = '';
Object.keys(ifaces).forEach(function (ifname) {
ifaces[ifname].forEach(function (iface) {
if (family !== iface.family || iface.internal !== false) {
return;
}
mac = iface.mac;
});
});
return mac;
}
this.getIP = function(family){
var ip = '';
Object.keys(ifaces).forEach(function (ifname) {
ifaces[ifname].forEach(function (iface) {
if (family !== iface.family || iface.internal !== false) {
return;
}
ip = iface.address;
});
});
return ip;
}
}
win.global_NetworkUtil = new NetworkUtil();
})(window);