forked from casperboone/homey-samsung-smart-tv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal-network.js
33 lines (26 loc) · 835 Bytes
/
local-network.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
32
33
module.exports.mac = function () {
var ifaces = require('os').networkInterfaces();
var result = "00:00:00:00";
Object.keys(ifaces).forEach(function (ifname) {
ifaces[ifname].forEach(function (iface) {
if (iface.family === 'IPv4' && iface.internal === false) {
result = iface.mac;
return;
}
});
});
return result;
}
module.exports.ip = function () {
var ifaces = require('os').networkInterfaces();
var result = "0.0.0.0";
Object.keys(ifaces).forEach(function (ifname) {
ifaces[ifname].forEach(function (iface) {
if (iface.family === 'IPv4' && iface.internal === false) {
result = iface.address;
return;
}
});
});
return result;
}