diff --git a/app/controllers/webmin.controller.js b/app/controllers/webmin.controller.js index ed7973abd57e1abb4a4389acda1386f73bf174d9..26591294d51d7d83e227b8b9bc619211292bf60e 100644 --- a/app/controllers/webmin.controller.js +++ b/app/controllers/webmin.controller.js @@ -228,6 +228,10 @@ function WebAdmin (dbConf, overConf) { name: 'conf', addresses: [] }; + let lan = { + name: 'lan', + addresses: [] + }; yield pluggedConfP; let conf = server.conf; if (conf.remoteipv4) { @@ -254,10 +258,24 @@ function WebAdmin (dbConf, overConf) { } catch (e) { logger.error(e.stack || e); } + let lanIPv4 = network.getLANIPv4(); + lanIPv4.forEach(function(addr) { + lan.addresses.push({ + family: 'IPv4', + address: addr.value + }); + }); + let lanIPv6 = network.getLANIPv6(); + lanIPv6.forEach(function(addr) { + lan.addresses.push({ + family: 'IPv6', + address: addr.value + }); + }); let randomPort = network.getRandomPort(); return { local: network.listInterfaces(), - remote: [upnp, manual], + remote: [upnp, manual, lan], auto: { local: { ipv4: network.getBestLocalIPv4(), diff --git a/app/lib/network.js b/app/lib/network.js index 6dd8a58ad0c301ac101ad26ec175a29bec9a749d..30d7ea2f5dfe2745da0d44324838f3292ba578c2 100644 --- a/app/lib/network.js +++ b/app/lib/network.js @@ -19,6 +19,8 @@ module.exports = { getBestLocalIPv4: () => getBestLocal('IPv4'), getBestLocalIPv6: () => getBestLocal('IPv6'), + getLANIPv4: () => getLAN('IPv4'), + getLANIPv6: () => getLAN('IPv6'), listInterfaces: () => { let netInterfaces = os.networkInterfaces(); @@ -264,3 +266,27 @@ function getBestLocal(family) { return 10; })[0].value; } + +function getLAN(family) { + let netInterfaces = os.networkInterfaces(); + let keys = _.keys(netInterfaces); + let res = []; + for (let i = 0, len = keys.length; i < len; i++) { + let name = keys[i]; + let addresses = netInterfaces[name]; + for (let j = 0, len2 = addresses.length; j < len2; j++) { + let addr = addresses[j]; + if ((addr.family == "IPv4" && family == "IPv4" + && addr.address != "127.0.0.1" && addr.address != "lo" && addr.address != "localhost") + || (addr.family == "IPv6" && family == "IPv6" + && addr.address != "::1" && addr.address != "lo" && addr.address != "localhost")) + { + res.push({ + name: name, + value: addr.address + }); + } + } + } + return res; +}