mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Fix for detecting changes in LF from other instances of the same controller.
This commit is contained in:
parent
d9befe3fb3
commit
eb7081d2a3
1 changed files with 28 additions and 10 deletions
|
@ -107,7 +107,7 @@ LFDB::LFDB(const Identity &myId,const char *path,const char *lfOwnerPrivate,cons
|
||||||
selectors.push_back(selector1);
|
selectors.push_back(selector1);
|
||||||
newrec["Selectors"] = selectors;
|
newrec["Selectors"] = selectors;
|
||||||
const uint8_t *const rawip = (const uint8_t *)ms->second.lastOnlineAddress.rawIpData();
|
const uint8_t *const rawip = (const uint8_t *)ms->second.lastOnlineAddress.rawIpData();
|
||||||
switch(ms->second.lastOnlineAddress) {
|
switch(ms->second.lastOnlineAddress.ss_family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
for(int j=0;j<4;++j)
|
for(int j=0;j<4;++j)
|
||||||
ip.push_back((unsigned int)rawip[j]);
|
ip.push_back((unsigned int)rawip[j]);
|
||||||
|
@ -200,13 +200,24 @@ LFDB::LFDB(const Identity &myId,const char *path,const char *lfOwnerPrivate,cons
|
||||||
if (network.is_object()) {
|
if (network.is_object()) {
|
||||||
const std::string idstr = network["id"];
|
const std::string idstr = network["id"];
|
||||||
const uint64_t id = Utils::hexStrToU64(idstr.c_str());
|
const uint64_t id = Utils::hexStrToU64(idstr.c_str());
|
||||||
if ((id >> 24) == controllerAddressInt) {
|
if ((id >> 24) == controllerAddressInt) { // sanity check
|
||||||
|
|
||||||
std::lock_guard<std::mutex> sl(_state_l);
|
std::lock_guard<std::mutex> sl(_state_l);
|
||||||
_NetworkState &ns = _state[id];
|
_NetworkState &ns = _state[id];
|
||||||
if (!ns.dirty) {
|
if (!ns.dirty) {
|
||||||
nlohmann::json nullJson;
|
nlohmann::json oldNetwork;
|
||||||
_networkChanged(nullJson,network,false);
|
if (get(id,oldNetwork)) {
|
||||||
|
const uint64_t revision = network["revision"];
|
||||||
|
const uint64_t prevRevision = oldNetwork["revision"];
|
||||||
|
if (prevRevision < revision) {
|
||||||
|
_networkChanged(oldNetwork,network,timeRangeStart > 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nlohmann::json nullJson;
|
||||||
|
_networkChanged(nullJson,network,timeRangeStart > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,16 +268,23 @@ LFDB::LFDB(const Identity &myId,const char *path,const char *lfOwnerPrivate,cons
|
||||||
const std::string idstr = member["id"];
|
const std::string idstr = member["id"];
|
||||||
const uint64_t nwid = Utils::hexStrToU64(nwidstr.c_str());
|
const uint64_t nwid = Utils::hexStrToU64(nwidstr.c_str());
|
||||||
const uint64_t id = Utils::hexStrToU64(idstr.c_str());
|
const uint64_t id = Utils::hexStrToU64(idstr.c_str());
|
||||||
if ((id)&&((nwid >> 24) == controllerAddressInt)) {
|
if ((id)&&((nwid >> 24) == controllerAddressInt)) { // sanity check
|
||||||
|
|
||||||
std::lock_guard<std::mutex> sl(_state_l);
|
std::lock_guard<std::mutex> sl(_state_l);
|
||||||
auto ns = _state.find(nwid);
|
auto ns = _state.find(nwid);
|
||||||
if (ns != _state.end()) {
|
if ((ns == _state.end())||(!ns->second.members[id].dirty)) {
|
||||||
_MemberState &ms = ns->second.members[id];
|
nlohmann::json network,oldMember;
|
||||||
if (!ms.dirty) {
|
if (get(nwid,network,id,oldMember)) {
|
||||||
nlohmann::json nullJson;
|
const uint64_t revision = member["revision"];
|
||||||
_memberChanged(nullJson,member,false);
|
const uint64_t prevRevision = oldMember["revision"];
|
||||||
|
if (prevRevision < revision)
|
||||||
|
_memberChanged(oldMember,member,timeRangeStart > 0);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
nlohmann::json nullJson;
|
||||||
|
_memberChanged(nullJson,member,timeRangeStart > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue