Skip to content

Commit

Permalink
Merge 39175d1 into f6cb1ef
Browse files Browse the repository at this point in the history
  • Loading branch information
Insoleet committed Mar 19, 2016
2 parents f6cb1ef + 39175d1 commit 05715ba
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
21 changes: 20 additions & 1 deletion app/controllers/webmin.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ function WebAdmin (dbConf, overConf) {
});
join += crypto.signSync(join, secretKey) + '\n';
yield that.pushEntity({ body: { membership: join }}, http2raw.membership, parsers.parseMembership);
yield server.recomputeSelfPeer();
}
//
return found;
Expand Down Expand Up @@ -219,6 +220,10 @@ function WebAdmin (dbConf, overConf) {
name: 'conf',
addresses: []
};
let lan = {
name: 'lan',
addresses: []
};
yield pluggedConfP;
let conf = server.conf;
if (conf.remoteipv4) {
Expand All @@ -245,10 +250,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(),
Expand Down
26 changes: 26 additions & 0 deletions app/lib/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ module.exports = {

getBestLocalIPv4: () => getBestLocal('IPv4'),
getBestLocalIPv6: () => getBestLocal('IPv6'),
getLANIPv4: () => getLAN('IPv4'),
getLANIPv6: () => getLAN('IPv6'),

listInterfaces: () => {
let netInterfaces = os.networkInterfaces();
Expand Down Expand Up @@ -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;
}
3 changes: 2 additions & 1 deletion app/lib/streams/dtos.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ dtos.UD = {
"block_number": Number,
"consumed": Boolean,
"time": Number,
"amount": Number
"amount": Number,
"base": Number
};

dtos.UDHistory = {
Expand Down

0 comments on commit 05715ba

Please sign in to comment.