void Topology::_saveIdentity(const Identity &id) { if (id) { char p[128]; Utils::snprintf(p,sizeof(p),"iddb.d/%.10llx",(unsigned long long)id.address().toInt()); RR->node->dataStorePut(p,id.toString(false),false); } }
/** * Sign this tag * * @param signer Signing identity, must have private key * @return True if signature was successful */ inline bool sign(const Identity &signer) { if (signer.hasPrivate()) { Buffer<sizeof(Tag) + 64> tmp; _signedBy = signer.address(); this->serialize(tmp,true); _signature = signer.sign(tmp.data(),tmp.size()); return true; } return false; }
bool Topology::isUpstream(const Identity &id) const { if (isRoot(id)) return true; std::vector< SharedPtr<Network> > nws(RR->node->allNetworks()); for(std::vector< SharedPtr<Network> >::const_iterator nw(nws.begin());nw!=nws.end();++nw) { SharedPtr<NetworkConfig> nc((*nw)->config2()); if (nc) { for(std::vector< std::pair<Address,InetAddress> >::const_iterator r(nc->relays().begin());r!=nc->relays().end();++r) { if (r->first == id.address()) return true; } } } return false; }
/** * @param id Identity to check * @return True if this is a designated root server in this world */ inline bool isRoot(const Identity &id) const { Mutex::Lock _l(_lock); return (std::find(_rootAddresses.begin(),_rootAddresses.end(),id.address()) != _rootAddresses.end()); }