mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 09:01:08 +00:00
Some controller fixes.
This commit is contained in:
parent
e4a10cc510
commit
4704d115c4
@ -1277,9 +1277,6 @@ void EmbeddedNetworkController::_request(
|
|||||||
ms.vProto = (int)vProto;
|
ms.vProto = (int)vProto;
|
||||||
ms.lastRequestMetaData = metaData;
|
ms.lastRequestMetaData = metaData;
|
||||||
ms.identity = identity;
|
ms.identity = identity;
|
||||||
|
|
||||||
if (fromAddr)
|
|
||||||
ms.physicalAddr = fromAddr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -198,7 +198,6 @@ private:
|
|||||||
int vMajor,vMinor,vRev,vProto;
|
int vMajor,vMinor,vRev,vProto;
|
||||||
Dictionary<ZT_NETWORKCONFIG_METADATA_DICT_CAPACITY> lastRequestMetaData;
|
Dictionary<ZT_NETWORKCONFIG_METADATA_DICT_CAPACITY> lastRequestMetaData;
|
||||||
Identity identity;
|
Identity identity;
|
||||||
InetAddress physicalAddr; // last known physical address
|
|
||||||
inline bool online(const int64_t now) const { return ((now - lastRequestTime) < (ZT_NETWORK_AUTOCONF_DELAY * 2)); }
|
inline bool online(const int64_t now) const { return ((now - lastRequestTime) < (ZT_NETWORK_AUTOCONF_DELAY * 2)); }
|
||||||
};
|
};
|
||||||
struct _MemberStatusHash
|
struct _MemberStatusHash
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//#define ZT_CONTROLLER_USE_RETHINKDB
|
||||||
|
|
||||||
#ifdef ZT_CONTROLLER_USE_RETHINKDB
|
#ifdef ZT_CONTROLLER_USE_RETHINKDB
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -164,7 +166,7 @@ RethinkDB::RethinkDB(EmbeddedNetworkController *const nc,const Identity &myId,co
|
|||||||
while ((this->_commitQueue.get(config))&&(_run == 1)) {
|
while ((this->_commitQueue.get(config))&&(_run == 1)) {
|
||||||
if (!config)
|
if (!config)
|
||||||
continue;
|
continue;
|
||||||
json record;
|
nlohmann::json record;
|
||||||
const char *table = (const char *)0;
|
const char *table = (const char *)0;
|
||||||
std::string deleteId;
|
std::string deleteId;
|
||||||
try {
|
try {
|
||||||
@ -182,7 +184,7 @@ RethinkDB::RethinkDB(EmbeddedNetworkController *const nc,const Identity &myId,co
|
|||||||
const std::string id = (*config)["id"];
|
const std::string id = (*config)["id"];
|
||||||
record["id"] = id;
|
record["id"] = id;
|
||||||
record["controllerId"] = this->_myAddressStr;
|
record["controllerId"] = this->_myAddressStr;
|
||||||
record["config"] = *config;
|
record["config"] = *config;
|
||||||
table = "Network";
|
table = "Network";
|
||||||
} else if (objtype == "trace") {
|
} else if (objtype == "trace") {
|
||||||
record = *config;
|
record = *config;
|
||||||
@ -221,7 +223,7 @@ RethinkDB::RethinkDB(EmbeddedNetworkController *const nc,const Identity &myId,co
|
|||||||
R::db(this->_db).table(table).get(deleteId).delete_().run(*rdb);
|
R::db(this->_db).table(table).get(deleteId).delete_().run(*rdb);
|
||||||
} else {
|
} else {
|
||||||
//printf("UPSERT: %s" ZT_EOL_S,record.dump().c_str());
|
//printf("UPSERT: %s" ZT_EOL_S,record.dump().c_str());
|
||||||
R::db(this->_db).table(table).insert(R::Datum::from_json(record.dump()),R::optargs("conflict","update","return_changes",false)).run(*rdb);
|
R::db(this->_db).table(table).insert(R::Datum::from_json(OSUtils::jsonDump(record,-1)),R::optargs("conflict","update","return_changes",false)).run(*rdb);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@ -436,18 +438,8 @@ void RethinkDB::save(nlohmann::json *orig,nlohmann::json &record)
|
|||||||
waitForReady();
|
waitForReady();
|
||||||
if (orig) {
|
if (orig) {
|
||||||
if (*orig != record) {
|
if (*orig != record) {
|
||||||
nlohmann::json *q = new nlohmann::json();
|
record["revision"] = OSUtils::jsonInt(record["revision"],0ULL) + 1;
|
||||||
try {
|
_commitQueue.post(new nlohmann::json(record));
|
||||||
record["revision"] = OSUtils::jsonInt(record["revision"],0ULL) + 1;
|
|
||||||
for(auto kv=record.begin();kv!=record.end();++kv) {
|
|
||||||
if ((kv.key() == "id")||(kv.key() == "nwid")||(kv.key() == "objtype")||((*q)[kv.key()] != kv.value()))
|
|
||||||
(*q)[kv.key()] = kv.value();
|
|
||||||
}
|
|
||||||
_commitQueue.post(new nlohmann::json(record));
|
|
||||||
} catch ( ... ) {
|
|
||||||
delete q;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
record["revision"] = 1;
|
record["revision"] = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user