summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-05-21 02:48:58 +0000
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-05-21 02:48:58 +0000
commitf0b821f880996a9295f8eedb370d43f28578e15e (patch)
treeaf79b8c1d1f9bae39d3815f911c770fc8fdbd91a
parent319f9a9346198d3f9326b46da5f72fd0bab3b4f9 (diff)
downloadinfinitytier-f0b821f880996a9295f8eedb370d43f28578e15e.tar.gz
infinitytier-f0b821f880996a9295f8eedb370d43f28578e15e.zip
.
-rw-r--r--netconf-service/index.js17
-rwxr-xr-xnetconf-service/netconf.service2
-rw-r--r--netconf-service/redis-schema.md2
3 files changed, 11 insertions, 10 deletions
diff --git a/netconf-service/index.js b/netconf-service/index.js
index 66a85052..c2f4610f 100644
--- a/netconf-service/index.js
+++ b/netconf-service/index.js
@@ -307,6 +307,7 @@ function doNetconfRequest(message)
DB.hmset(memberKey,{
'lastSeen': Date.now(),
'lastAt': fromIpAndPort,
+ 'authorized': authorized ? '1' : '0', // reset authorized to unhide in UI, since UI uses -1 to hide
'clientVersion': (message.data['clientVersion']) ? message.data['clientVersion'] : '?.?.?',
'clientOs': (message.data['clientOs']) ? message.data['clientOs'] : '?'
},next);
@@ -362,19 +363,19 @@ function doNetconfRequest(message)
var peerAddress = peerId.address();
- var network = 0;
+ var ipnetwork = 0;
var netmask = 0;
var netmaskBits = 0;
var v4pool = network['v4AssignPool']; // technically csv but only one netblock currently supported
if (v4pool) {
- var v4poolSplit = v4Pool.split('/');
+ var v4poolSplit = v4pool.split('/');
if (v4poolSplit.length === 2) {
var networkSplit = v4poolSplit[0].split('.');
if (networkSplit.length === 4) {
- network |= (parseInt(networkSplit[0],10) << 24) & 0xff000000;
- network |= (parseInt(networkSplit[1],10) << 16) & 0x00ff0000;
- network |= (parseInt(networkSplit[2],10) << 8) & 0x0000ff00;
- network |= parseInt(networkSplit[3],10) & 0x000000ff;
+ ipnetwork |= (parseInt(networkSplit[0],10) << 24) & 0xff000000;
+ ipnetwork |= (parseInt(networkSplit[1],10) << 16) & 0x00ff0000;
+ ipnetwork |= (parseInt(networkSplit[2],10) << 8) & 0x0000ff00;
+ ipnetwork |= parseInt(networkSplit[3],10) & 0x000000ff;
netmaskBits = parseInt(v4poolSplit[1],10);
if (netmaskBits > 32)
netmaskBits = 32; // sanity check
@@ -384,7 +385,7 @@ function doNetconfRequest(message)
}
}
}
- if ((network === 0)||(netmask === 0xffffffff))
+ if ((ipnetwork === 0)||(netmask === 0xffffffff))
return next(null);
var invmask = netmask ^ 0xffffffff;
@@ -409,7 +410,7 @@ function doNetconfRequest(message)
abcd &= 0xffffffff;
// Derive an IP to test and generate assignment ip/bits string
- var ip = (abcd & invmask) | (network & netmask);
+ var ip = (abcd & invmask) | (ipnetwork & netmask);
var assignment = ((ip >> 24) & 0xff).toString(10) + '.' + ((ip >> 16) & 0xff).toString(10) + '.' + ((ip >> 8) & 0xff).toString(10) + '.' + (ip & 0xff).toString(10) + '/' + netmaskBits.toString(10);
// Check :ipAssignments to see if this IP is already taken
diff --git a/netconf-service/netconf.service b/netconf-service/netconf.service
index 5371ff0c..e799b369 100755
--- a/netconf-service/netconf.service
+++ b/netconf-service/netconf.service
@@ -5,7 +5,7 @@ export PATH=/bin:/usr/bin:/usr/local/bin
# We will start in ZT_HOME
if [ ! -d ./services.d/netconf-service ]; then
- echo 'cannot find netconf-service subfolder to launch subprocess' >>&2
+ echo 'cannot find netconf-service subfolder to launch subprocess' >&2
exit 1
fi
diff --git a/netconf-service/redis-schema.md b/netconf-service/redis-schema.md
index 244951e0..a9ae97d9 100644
--- a/netconf-service/redis-schema.md
+++ b/netconf-service/redis-schema.md
@@ -101,6 +101,6 @@ The ipAssignments field is re-generated whenever the zt1:network:\<nwid\>:ipAssi
### zt1:network:\<nwid\>:ipAssignments
-This is a hash mapping IP/netmask bits fields to 10-digit ZeroTier addresses of network members. IPv4 fields contain dots, e.g. "10.2.3.4/24" or "29.1.1.1/7". IPv6 fields contain colons. Note that IPv6 IP abbreviations should *not* be used; use \:0000\: instead of \:\: for zero parts of addresses. This is to simplify parser code and canonicalize for rapid search. All hex digits must be lower-case.
+This is a hash mapping IP/netmask bits fields to 10-digit ZeroTier addresses of network members. IPv4 fields contain dots, e.g. "10.2.3.4/24" or "29.1.1.1/7". IPv6 fields contain colons. Note that IPv6 IP abbreviations must *not* be used; use \:0000\: instead of \:\: for zero parts of addresses. This is to simplify parser code and canonicalize for rapid search. All hex digits must be lower-case.
This is only used if the network's IPv4 and/or IPv6 auto-assign mode is 'zt' for ZeroTier assignment. The netconf-master will auto-populate by choosing unused IPs, and it can be edited via the API as well.