|
|
|
|
@ -107,7 +107,7 @@ LFDB::LFDB(const Identity &myId,const char *path,const char *lfOwnerPrivate,cons
|
|
|
|
|
selectors.push_back(selector1); |
|
|
|
|
newrec["Selectors"] = selectors; |
|
|
|
|
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: |
|
|
|
|
for(int j=0;j<4;++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()) { |
|
|
|
|
const std::string idstr = network["id"]; |
|
|
|
|
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); |
|
|
|
|
_NetworkState &ns = _state[id]; |
|
|
|
|
if (!ns.dirty) { |
|
|
|
|
nlohmann::json nullJson; |
|
|
|
|
_networkChanged(nullJson,network,false); |
|
|
|
|
nlohmann::json oldNetwork; |
|
|
|
|
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 uint64_t nwid = Utils::hexStrToU64(nwidstr.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); |
|
|
|
|
auto ns = _state.find(nwid); |
|
|
|
|
if (ns != _state.end()) { |
|
|
|
|
_MemberState &ms = ns->second.members[id]; |
|
|
|
|
if (!ms.dirty) { |
|
|
|
|
nlohmann::json nullJson; |
|
|
|
|
_memberChanged(nullJson,member,false); |
|
|
|
|
if ((ns == _state.end())||(!ns->second.members[id].dirty)) { |
|
|
|
|
nlohmann::json network,oldMember; |
|
|
|
|
if (get(nwid,network,id,oldMember)) { |
|
|
|
|
const uint64_t revision = member["revision"]; |
|
|
|
|
const uint64_t prevRevision = oldMember["revision"]; |
|
|
|
|
if (prevRevision < revision) |
|
|
|
|
_memberChanged(oldMember,member,timeRangeStart > 0); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
nlohmann::json nullJson; |
|
|
|
|
_memberChanged(nullJson,member,timeRangeStart > 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|