summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--controller/SqliteNetworkController.cpp10
-rw-r--r--controller/schema.sql2
-rw-r--r--controller/schema.sql.c2
-rw-r--r--service/README.md4
4 files changed, 12 insertions, 6 deletions
diff --git a/controller/SqliteNetworkController.cpp b/controller/SqliteNetworkController.cpp
index c9535fef..cc53d4d5 100644
--- a/controller/SqliteNetworkController.cpp
+++ b/controller/SqliteNetworkController.cpp
@@ -190,7 +190,7 @@ SqliteNetworkController::SqliteNetworkController(const char *dbPath) :
/* Member */
||(sqlite3_prepare_v2(_db,"SELECT rowid,authorized,activeBridge FROM Member WHERE networkId = ? AND nodeId = ?",-1,&_sGetMember,(const char **)0) != SQLITE_OK)
- ||(sqlite3_prepare_v2(_db,"SELECT m.authorized,m.activeBridge,n.identity FROM Member AS m JOIN Node AS n ON n.id = m.nodeId WHERE m.networkId = ? AND m.nodeId = ?",-1,&_sGetMember2,(const char **)0) != SQLITE_OK)
+ ||(sqlite3_prepare_v2(_db,"SELECT m.authorized,m.activeBridge,m.memberRevision,n.identity FROM Member AS m JOIN Node AS n ON n.id = m.nodeId WHERE m.networkId = ? AND m.nodeId = ?",-1,&_sGetMember2,(const char **)0) != SQLITE_OK)
||(sqlite3_prepare_v2(_db,"INSERT INTO Member (networkId,nodeId,authorized,activeBridge,memberRevision) VALUES (?,?,?,0,(SELECT memberRevisionCounter FROM Network WHERE id = ?))",-1,&_sCreateMember,(const char **)0) != SQLITE_OK)
||(sqlite3_prepare_v2(_db,"SELECT nodeId FROM Member WHERE networkId = ? AND activeBridge > 0 AND authorized > 0",-1,&_sGetActiveBridges,(const char **)0) != SQLITE_OK)
||(sqlite3_prepare_v2(_db,"SELECT m.nodeId FROM Member AS m WHERE m.networkId = ? ORDER BY m.nodeId ASC",-1,&_sListNetworkMembers,(const char **)0) != SQLITE_OK)
@@ -1256,13 +1256,15 @@ unsigned int SqliteNetworkController::_doCPGet(
"\t\"address\": \"%s\",\n"
"\t\"authorized\": %s,\n"
"\t\"activeBridge\": %s,\n"
+ "\t\"memberRevision\": %llu,\n"
"\t\"identity\": \"%s\",\n"
"\t\"ipAssignments\": [",
nwids,
addrs,
(sqlite3_column_int(_sGetMember2,0) > 0) ? "true" : "false",
(sqlite3_column_int(_sGetMember2,1) > 0) ? "true" : "false",
- _jsonEscape((const char *)sqlite3_column_text(_sGetMember2,2)).c_str());
+ (unsigned long long)sqlite3_column_int64(_sGetMember2,2),
+ _jsonEscape((const char *)sqlite3_column_text(_sGetMember2,3)).c_str());
responseBody = json;
sqlite3_reset(_sGetIpAssignmentsForNode2);
@@ -1359,6 +1361,7 @@ unsigned int SqliteNetworkController::_doCPGet(
"\t\"multicastLimit\": %d,\n"
"\t\"creationTime\": %llu,\n"
"\t\"revision\": %llu,\n"
+ "\t\"memberRevisionCounter\": %llu,\n"
"\t\"members\": [",
nwids,
_jsonEscape((const char *)sqlite3_column_text(_sGetNetworkById,0)).c_str(),
@@ -1369,7 +1372,8 @@ unsigned int SqliteNetworkController::_doCPGet(
_jsonEscape((const char *)sqlite3_column_text(_sGetNetworkById,5)).c_str(),
sqlite3_column_int(_sGetNetworkById,6),
(unsigned long long)sqlite3_column_int64(_sGetNetworkById,7),
- (unsigned long long)sqlite3_column_int64(_sGetNetworkById,8));
+ (unsigned long long)sqlite3_column_int64(_sGetNetworkById,8),
+ (unsigned long long)sqlite3_column_int64(_sGetNetworkById,9));
responseBody = json;
sqlite3_reset(_sListNetworkMembers);
diff --git a/controller/schema.sql b/controller/schema.sql
index ea816b95..c3eec234 100644
--- a/controller/schema.sql
+++ b/controller/schema.sql
@@ -58,7 +58,7 @@ CREATE TABLE Member (
nodeId char(10) NOT NULL REFERENCES Node(id) ON DELETE CASCADE,
authorized integer NOT NULL DEFAULT(0),
activeBridge integer NOT NULL DEFAULT(0),
- memberRevision integer NOT NULL DEFAULT(0)
+ memberRevision integer NOT NULL DEFAULT(0),
PRIMARY KEY (networkId, nodeId)
);
diff --git a/controller/schema.sql.c b/controller/schema.sql.c
index 7f1342a8..78123db4 100644
--- a/controller/schema.sql.c
+++ b/controller/schema.sql.c
@@ -59,7 +59,7 @@
" nodeId char(10) NOT NULL REFERENCES Node(id) ON DELETE CASCADE,\n"\
" authorized integer NOT NULL DEFAULT(0),\n"\
" activeBridge integer NOT NULL DEFAULT(0),\n"\
-" memberRevision integer NOT NULL DEFAULT(0)\n"\
+" memberRevision integer NOT NULL DEFAULT(0),\n"\
" PRIMARY KEY (networkId, nodeId)\n"\
");\n"\
"\n"\
diff --git a/service/README.md b/service/README.md
index 873e577f..d2dc6e91 100644
--- a/service/README.md
+++ b/service/README.md
@@ -172,6 +172,7 @@ To create a new network with a random last six digits safely and atomically, you
<tr><td>multicastLimit</td><td>integer</td><td>Maximum number of multicast recipients per multicast/broadcast address</td><td>yes</td></tr>
<tr><td>creationTime</td><td>integer</td><td>Time network was created in ms since epoch</td><td>no</td></tr>
<tr><td>revision</td><td>integer</td><td>Network config revision number</td><td>no</td></tr>
+<tr><td>memberRevisionCounter</td><td>integer</td><td>Current value of network revision counter (incremented after every member add or revision)</td><td>no</td></tr>
<tr><td>members</td><td>[string]</td><td>Array of ZeroTier addresses of network members</td><td>no</td></tr>
<tr><td>relays</td><td>[object]</td><td>Array of network-specific relay nodes (see below)</td><td>yes</td></tr>
<tr><td>ipLocalRoutes</td><td>[string]</td><td>Array of IP network/netmask entries corresponding to networks routed directly via this interface (e.g. 10.0.0.0/8 to route 10.0.0.0 via this interface)</td></tr>
@@ -200,7 +201,7 @@ IP assignment pools are only used if they are within a network specified in ipLo
<table>
<tr><td><b>Field</b></td><td><b>Type</b></td><td><b>Description</b></td></tr>
<tr><td>ipRangeStart</td><td>string</td><td>Start of IP assignment range</td></tr>
-<tr><td>ipRangeEnd</td><td>integer</td><td>End of IP assignment range</td></tr>
+<tr><td>ipRangeEnd</td><td>string</td><td>End of IP assignment range</td></tr>
</table>
**Rule object format:**
@@ -247,4 +248,5 @@ IP related fields apply only to Ethernet frames of type IPv4 or IPV6. Otherwise
<tr><td>activeBridge</td><td>boolean</td><td>This member is an active network bridge</td><td>yes</td></tr>
<tr><td>identity</td><td>string</td><td>Full ZeroTier identity of member</td><td>no</td></tr>
<tr><td>ipAssignments</td><td>[string]</td><td>Array of IP/bits IP assignments</td><td>yes</td></tr>
+<tr><td>memberRevision</td><td>integer</td><td>Member revision counter value from network at time of last revision or member creation</td><td>no</td></tr>
</table>