From a425bbc67301bf486fe5b0aba8adb59ae791403e Mon Sep 17 00:00:00 2001 From: Kees Bos Date: Wed, 6 May 2015 12:05:20 +0200 Subject: Renamed supernode to rootserver --- node/Constants.hpp | 6 +-- node/Dictionary.cpp | 9 ++++- node/Dictionary.hpp | 3 ++ node/IncomingPacket.cpp | 12 +++--- node/Multicaster.cpp | 6 +-- node/Network.cpp | 6 +-- node/Node.cpp | 14 ++++--- node/Packet.hpp | 2 +- node/Peer.cpp | 6 +-- node/SelfAwareness.cpp | 2 +- node/Switch.cpp | 26 ++++++------ node/Topology.cpp | 102 ++++++++++++++++++++++++------------------------ node/Topology.hpp | 64 +++++++++++++++--------------- 13 files changed, 134 insertions(+), 124 deletions(-) (limited to 'node') diff --git a/node/Constants.hpp b/node/Constants.hpp index ed227f9f..aced6fe7 100644 --- a/node/Constants.hpp +++ b/node/Constants.hpp @@ -254,7 +254,7 @@ /** * Delay between scans of the topology active peer DB for peers that need ping * - * This is also how often pings will be retried to upstream peers (supernodes) + * This is also how often pings will be retried to upstream peers (rootservers) * constantly until something is heard. */ #define ZT_PING_CHECK_INVERVAL 6250 @@ -279,9 +279,9 @@ * * When we send something (including frames), we generally expect a response. * Switching relays if no response in a short period of time causes more - * rapid failover if a supernode goes down or becomes unreachable. In the + * rapid failover if a rootserver goes down or becomes unreachable. In the * mistaken case, little harm is done as it'll pick the next-fastest - * supernode and will switch back eventually. + * rootserver and will switch back eventually. */ #define ZT_PEER_RELAY_CONVERSATION_LATENCY_THRESHOLD 10000 diff --git a/node/Dictionary.cpp b/node/Dictionary.cpp index b3b01525..fb49002a 100644 --- a/node/Dictionary.cpp +++ b/node/Dictionary.cpp @@ -32,9 +32,8 @@ namespace ZeroTier { -void Dictionary::fromString(const char *s,unsigned int maxlen) +void Dictionary::updateFromString(const char *s,unsigned int maxlen) { - clear(); bool escapeState = false; std::string keyBuf; std::string *element = &keyBuf; @@ -75,6 +74,12 @@ void Dictionary::fromString(const char *s,unsigned int maxlen) (*this)[keyBuf]; } +void Dictionary::fromString(const char *s,unsigned int maxlen) +{ + clear(); + updateFromString(s,maxlen); +} + bool Dictionary::sign(const Identity &id,uint64_t now) { try { diff --git a/node/Dictionary.hpp b/node/Dictionary.hpp index afdc2d74..8628bc44 100644 --- a/node/Dictionary.hpp +++ b/node/Dictionary.hpp @@ -259,6 +259,9 @@ public: */ void fromString(const char *s,unsigned int maxlen); inline void fromString(const std::string &s) { fromString(s.c_str(),(unsigned int)s.length()); } + void updateFromString(const char *s,unsigned int maxlen); + inline void update(const char *s,unsigned int maxlen) { updateFromString(s, maxlen); } + inline void update(const std::string &s) { updateFromString(s.c_str(),(unsigned int)s.length()); } /** * @return True if this dictionary is cryptographically signed diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp index 8b228de5..5c83f24f 100644 --- a/node/IncomingPacket.cpp +++ b/node/IncomingPacket.cpp @@ -110,7 +110,7 @@ bool IncomingPacket::_doERROR(const RuntimeEnvironment *RR,const SharedPtr case Packet::ERROR_OBJ_NOT_FOUND: if (inReVerb == Packet::VERB_WHOIS) { - if (RR->topology->isSupernode(peer->address())) + if (RR->topology->isRootserver(peer->address())) RR->sw->cancelWhoisRequest(Address(field(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD,ZT_ADDRESS_LENGTH),ZT_ADDRESS_LENGTH)); } else if (inReVerb == Packet::VERB_NETWORK_CONFIG_REQUEST) { SharedPtr network(RR->node->network(at(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD))); @@ -128,7 +128,7 @@ bool IncomingPacket::_doERROR(const RuntimeEnvironment *RR,const SharedPtr break; case Packet::ERROR_IDENTITY_COLLISION: - if (RR->topology->isSupernode(peer->address())) + if (RR->topology->isRootserver(peer->address())) RR->node->postEvent(ZT1_EVENT_FATAL_ERROR_IDENTITY_COLLISION); break; @@ -268,7 +268,7 @@ bool IncomingPacket::_doHELLO(const RuntimeEnvironment *RR) peer->setRemoteVersion(protoVersion,vMajor,vMinor,vRevision); bool trusted = false; - if (RR->topology->isSupernode(id.address())) { + if (RR->topology->isRootserver(id.address())) { RR->node->postNewerVersionIfNewer(vMajor,vMinor,vRevision); trusted = true; } @@ -353,7 +353,7 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *RR,const SharedPtr &p peer->setRemoteVersion(vProto,vMajor,vMinor,vRevision); bool trusted = false; - if (RR->topology->isSupernode(peer->address())) { + if (RR->topology->isRootserver(peer->address())) { RR->node->postNewerVersionIfNewer(vMajor,vMinor,vRevision); trusted = true; } @@ -362,10 +362,10 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *RR,const SharedPtr &p } break; case Packet::VERB_WHOIS: { - // Right now only supernodes are allowed to send OK(WHOIS) to prevent + // Right now only rootservers are allowed to send OK(WHOIS) to prevent // poisoning attacks. Further decentralization will require some other // kind of trust mechanism. - if (RR->topology->isSupernode(peer->address())) { + if (RR->topology->isRootserver(peer->address())) { const Identity id(*this,ZT_PROTO_VERB_WHOIS__OK__IDX_IDENTITY); if (id.locallyValidate()) RR->sw->doAnythingWaitingForPeer(RR->topology->addPeer(SharedPtr(new Peer(RR->identity,id)))); diff --git a/node/Multicaster.cpp b/node/Multicaster.cpp index 7da2b14c..0cc4fb87 100644 --- a/node/Multicaster.cpp +++ b/node/Multicaster.cpp @@ -216,7 +216,7 @@ void Multicaster::send( if ((now - gs.lastExplicitGather) >= ZT_MULTICAST_EXPLICIT_GATHER_DELAY) { gs.lastExplicitGather = now; - SharedPtr sn(RR->topology->getBestSupernode()); + SharedPtr sn(RR->topology->getBestRootserver()); if (sn) { TRACE(">>MC upstream GATHER up to %u for group %.16llx/%s",gatherLimit,nwid,mg.toString().c_str()); @@ -271,12 +271,12 @@ void Multicaster::send( delete [] indexes; #ifdef ZT_SUPPORT_LEGACY_MULTICAST - // This sends a P5 multicast up to our supernode, who then + // This sends a P5 multicast up to our rootserver, who then // redistributes it manually down to all <1.0.0 peers for // legacy support. These peers don't support the new multicast // frame type, so even if they receive it they will ignore it. { - SharedPtr sn(RR->topology->getBestSupernode()); + SharedPtr sn(RR->topology->getBestRootserver()); if (sn) { uint32_t rn = RR->prng->next32(); Packet outp(sn->address(),RR->identity.address(),Packet::VERB_P5_MULTICAST_FRAME); diff --git a/node/Network.cpp b/node/Network.cpp index e513f43f..60262cd5 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -518,13 +518,13 @@ public: RR(renv), _now(renv->node->now()), _network(nw), - _supernodeAddresses(renv->topology->supernodeAddresses()), + _rootserverAddresses(renv->topology->rootserverAddresses()), _allMulticastGroups(nw->_allMulticastGroups()) {} inline void operator()(Topology &t,const SharedPtr &p) { - if ( ( (p->hasActiveDirectPath(_now)) && (_network->_isAllowed(p->address())) ) || (std::find(_supernodeAddresses.begin(),_supernodeAddresses.end(),p->address()) != _supernodeAddresses.end()) ) { + if ( ( (p->hasActiveDirectPath(_now)) && (_network->_isAllowed(p->address())) ) || (std::find(_rootserverAddresses.begin(),_rootserverAddresses.end(),p->address()) != _rootserverAddresses.end()) ) { Packet outp(p->address(),RR->identity.address(),Packet::VERB_MULTICAST_LIKE); for(std::vector::iterator mg(_allMulticastGroups.begin());mg!=_allMulticastGroups.end();++mg) { @@ -551,7 +551,7 @@ private: const RuntimeEnvironment *RR; uint64_t _now; Network *_network; - std::vector
_supernodeAddresses; + std::vector
_rootserverAddresses; std::vector _allMulticastGroups; }; diff --git a/node/Node.cpp b/node/Node.cpp index 9f195a10..1f6d474c 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -133,7 +133,9 @@ Node::Node( if (!rt.size()) rt.fromString(ZT_DEFAULTS.defaultRootTopology); } - RR->topology->setSupernodes(Dictionary(rt.get("supernodes",""))); + Dictionary rootservers(rt.get("rootservers","")); + rootservers.update(rt.get("supernodes","")); + RR->topology->setRootservers(rootservers); postEvent(ZT1_EVENT_UP); } @@ -189,7 +191,7 @@ public: RR(renv), _now(now), _relays(relays), - _supernodes(RR->topology->supernodeAddresses()) + _rootservers(RR->topology->rootserverAddresses()) { } @@ -205,7 +207,7 @@ public: } } - if ((isRelay)||(std::find(_supernodes.begin(),_supernodes.end(),p->address()) != _supernodes.end())) { + if ((isRelay)||(std::find(_rootservers.begin(),_rootservers.end(),p->address()) != _rootservers.end())) { p->doPingAndKeepalive(RR,_now); if (p->lastReceive() > lastReceiveFromUpstream) lastReceiveFromUpstream = p->lastReceive(); @@ -219,7 +221,7 @@ private: const RuntimeEnvironment *RR; uint64_t _now; const std::vector< std::pair > &_relays; - std::vector
_supernodes; + std::vector
_rootservers; }; ZT1_ResultCode Node::processBackgroundTasks(uint64_t now,volatile uint64_t *nextBackgroundTaskDeadline) @@ -260,7 +262,7 @@ ZT1_ResultCode Node::processBackgroundTasks(uint64_t now,volatile uint64_t *next } } - // Ping living or supernode/relay peers + // Ping living or rootserver/relay peers _PingPeersThatNeedPing pfunc(RR,now,networkRelays); RR->topology->eachPeer<_PingPeersThatNeedPing &>(pfunc); @@ -384,7 +386,7 @@ ZT1_PeerList *Node::peers() const p->versionRev = -1; } p->latency = pi->second->latency(); - p->role = RR->topology->isSupernode(pi->second->address()) ? ZT1_PEER_ROLE_SUPERNODE : ZT1_PEER_ROLE_LEAF; + p->role = RR->topology->isRootserver(pi->second->address()) ? ZT1_PEER_ROLE_ROOTSERVER : ZT1_PEER_ROLE_LEAF; std::vector paths(pi->second->paths()); Path *bestPath = pi->second->getBestPath(_now); diff --git a/node/Packet.hpp b/node/Packet.hpp index 1ec145d5..21f8ca57 100644 --- a/node/Packet.hpp +++ b/node/Packet.hpp @@ -626,7 +626,7 @@ public: * [... additional tuples of network/address/adi ...] * * LIKEs are sent to peers with whom you have a direct peer to peer - * connection, and always including supernodes. + * connection, and always including rootservers. * * OK/ERROR are not generated. */ diff --git a/node/Peer.cpp b/node/Peer.cpp index d788d006..3093ef41 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -122,16 +122,16 @@ void Peer::received( /* Announce multicast groups of interest to direct peers if they are * considered authorized members of a given network. Also announce to - * supernodes and network controllers. */ + * rootservers and network controllers. */ if ((pathIsConfirmed)&&((now - _lastAnnouncedTo) >= ((ZT_MULTICAST_LIKE_EXPIRE / 2) - 1000))) { _lastAnnouncedTo = now; - const bool isSupernode = RR->topology->isSupernode(_id.address()); + const bool isRootserver = RR->topology->isRootserver(_id.address()); Packet outp(_id.address(),RR->identity.address(),Packet::VERB_MULTICAST_LIKE); const std::vector< SharedPtr > networks(RR->node->allNetworks()); for(std::vector< SharedPtr >::const_iterator n(networks.begin());n!=networks.end();++n) { - if ( (isSupernode) || ((*n)->isAllowed(_id.address())) ) { + if ( (isRootserver) || ((*n)->isAllowed(_id.address())) ) { const std::vector mgs((*n)->allMulticastGroups()); for(std::vector::const_iterator mg(mgs.begin());mg!=mgs.end();++mg) { if ((outp.size() + 18) > ZT_UDP_DEFAULT_PAYLOAD_MTU) { diff --git a/node/SelfAwareness.cpp b/node/SelfAwareness.cpp index d7c0e5cc..5fc8be2a 100644 --- a/node/SelfAwareness.cpp +++ b/node/SelfAwareness.cpp @@ -118,7 +118,7 @@ void SelfAwareness::iam(const Address &reporter,const InetAddress &reporterPhysi // For all peers for whom we forgot an address, send a packet indirectly if // they are still considered alive so that we will re-establish direct links. - SharedPtr sn(RR->topology->getBestSupernode()); + SharedPtr sn(RR->topology->getBestRootserver()); if (sn) { Path *snp = sn->getBestPath(now); if (snp) { diff --git a/node/Switch.cpp b/node/Switch.cpp index 0aa0b664..3ac0b920 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -320,8 +320,8 @@ bool Switch::unite(const Address &p1,const Address &p2,bool force) * P2 in randomized order in terms of which gets sent first. This is done * since in a few cases NAT-t can be sensitive to slight timing differences * in terms of when the two peers initiate. Normally this is accounted for - * by the nearly-simultaneous RENDEZVOUS kickoff from the supernode, but - * given that supernodes are hosted on cloud providers this can in some + * by the nearly-simultaneous RENDEZVOUS kickoff from the rootserver, but + * given that rootservers are hosted on cloud providers this can in some * cases have a few ms of latency between packet departures. By randomizing * the order we make each attempted NAT-t favor one or the other going * first, meaning if it doesn't succeed the first time it might the second @@ -565,8 +565,8 @@ void Switch::_handleRemotePacketFragment(const InetAddress &fromAddr,const void // It wouldn't hurt anything, just redundant and unnecessary. SharedPtr relayTo = RR->topology->getPeer(destination); if ((!relayTo)||(!relayTo->send(RR,fragment.data(),fragment.size(),RR->node->now()))) { - // Don't know peer or no direct path -- so relay via supernode - relayTo = RR->topology->getBestSupernode(); + // Don't know peer or no direct path -- so relay via rootserver + relayTo = RR->topology->getBestRootserver(); if (relayTo) relayTo->send(RR,fragment.data(),fragment.size(),RR->node->now()); } @@ -641,8 +641,8 @@ void Switch::_handleRemotePacketHead(const InetAddress &fromAddr,const void *dat if ((relayTo)&&((relayTo->send(RR,packet->data(),packet->size(),RR->node->now())))) { unite(source,destination,false); } else { - // Don't know peer or no direct path -- so relay via supernode - relayTo = RR->topology->getBestSupernode(&source,1,true); + // Don't know peer or no direct path -- so relay via rootserver + relayTo = RR->topology->getBestRootserver(&source,1,true); if (relayTo) relayTo->send(RR,packet->data(),packet->size(),RR->node->now()); } @@ -712,13 +712,13 @@ void Switch::_handleBeacon(const InetAddress &fromAddr,const Buffer supernode(RR->topology->getBestSupernode(peersAlreadyConsulted,numPeersAlreadyConsulted,false)); - if (supernode) { - Packet outp(supernode->address(),RR->identity.address(),Packet::VERB_WHOIS); + SharedPtr rootserver(RR->topology->getBestRootserver(peersAlreadyConsulted,numPeersAlreadyConsulted,false)); + if (rootserver) { + Packet outp(rootserver->address(),RR->identity.address(),Packet::VERB_WHOIS); addr.appendTo(outp); - outp.armor(supernode->key(),true); - if (supernode->send(RR,outp.data(),outp.size(),RR->node->now())) - return supernode->address(); + outp.armor(rootserver->key(),true); + if (rootserver->send(RR,outp.data(),outp.size(),RR->node->now())) + return rootserver->address(); } return Address(); } @@ -752,7 +752,7 @@ bool Switch::_trySend(const Packet &packet,bool encrypt,uint64_t nwid) } if (!relay) - relay = RR->topology->getBestSupernode(); + relay = RR->topology->getBestRootserver(); if (!(relay)||(!(viaPath = relay->getBestPath(now)))) return false; diff --git a/node/Topology.cpp b/node/Topology.cpp index 5fcc2e61..cfa6749c 100644 --- a/node/Topology.cpp +++ b/node/Topology.cpp @@ -36,7 +36,7 @@ namespace ZeroTier { Topology::Topology(const RuntimeEnvironment *renv) : RR(renv), - _amSupernode(false) + _amRootserver(false) { } @@ -44,16 +44,16 @@ Topology::~Topology() { } -void Topology::setSupernodes(const std::map< Identity,std::vector > &sn) +void Topology::setRootservers(const std::map< Identity,std::vector > &sn) { Mutex::Lock _l(_lock); - if (_supernodes == sn) + if (_rootservers == sn) return; // no change - _supernodes = sn; - _supernodeAddresses.clear(); - _supernodePeers.clear(); + _rootservers = sn; + _rootserverAddresses.clear(); + _rootserverPeers.clear(); const uint64_t now = RR->node->now(); for(std::map< Identity,std::vector >::const_iterator i(sn.begin());i!=sn.end();++i) { @@ -64,17 +64,17 @@ void Topology::setSupernodes(const std::map< Identity,std::vector > for(std::vector::const_iterator j(i->second.begin());j!=i->second.end();++j) p->addPath(Path(*j,true)); p->use(now); - _supernodePeers.push_back(p); + _rootserverPeers.push_back(p); } - _supernodeAddresses.push_back(i->first.address()); + _rootserverAddresses.push_back(i->first.address()); } - std::sort(_supernodeAddresses.begin(),_supernodeAddresses.end()); + std::sort(_rootserverAddresses.begin(),_rootserverAddresses.end()); - _amSupernode = (_supernodes.find(RR->identity) != _supernodes.end()); + _amRootserver = (_rootservers.find(RR->identity) != _rootservers.end()); } -void Topology::setSupernodes(const Dictionary &sn) +void Topology::setRootservers(const Dictionary &sn) { std::map< Identity,std::vector > m; for(Dictionary::const_iterator d(sn.begin());d!=sn.end();++d) { @@ -86,11 +86,11 @@ void Topology::setSupernodes(const Dictionary &sn) if (udp.length() > 0) a.push_back(InetAddress(udp)); } catch ( ... ) { - TRACE("supernode list contained invalid entry for: %s",d->first.c_str()); + TRACE("rootserver list contained invalid entry for: %s",d->first.c_str()); } } } - this->setSupernodes(m); + this->setRootservers(m); } SharedPtr Topology::addPeer(const SharedPtr &peer) @@ -141,28 +141,28 @@ SharedPtr Topology::getPeer(const Address &zta) return SharedPtr(); } -SharedPtr Topology::getBestSupernode(const Address *avoid,unsigned int avoidCount,bool strictAvoid) +SharedPtr Topology::getBestRootserver(const Address *avoid,unsigned int avoidCount,bool strictAvoid) { - SharedPtr bestSupernode; + SharedPtr bestRootserver; const uint64_t now = RR->node->now(); Mutex::Lock _l(_lock); - if (_amSupernode) { - /* If I am a supernode, the "best" supernode is the one whose address + if (_amRootserver) { + /* If I am a rootserver, the "best" rootserver is the one whose address * is numerically greater than mine (with wrap at top of list). This * causes packets searching for a route to pretty much literally * circumnavigate the globe rather than bouncing between just two. */ - if (_supernodeAddresses.size() > 1) { // gotta be one other than me for this to work - std::vector
::const_iterator sna(std::find(_supernodeAddresses.begin(),_supernodeAddresses.end(),RR->identity.address())); - if (sna != _supernodeAddresses.end()) { // sanity check -- _amSupernode should've been false in this case + if (_rootserverAddresses.size() > 1) { // gotta be one other than me for this to work + std::vector
::const_iterator sna(std::find(_rootserverAddresses.begin(),_rootserverAddresses.end(),RR->identity.address())); + if (sna != _rootserverAddresses.end()) { // sanity check -- _amRootserver should've been false in this case for(;;) { - if (++sna == _supernodeAddresses.end()) - sna = _supernodeAddresses.begin(); // wrap around at end + if (++sna == _rootserverAddresses.end()) + sna = _rootserverAddresses.begin(); // wrap around at end if (*sna != RR->identity.address()) { // pick one other than us -- starting from me+1 in sorted set order std::map< Address,SharedPtr >::const_iterator p(_activePeers.find(*sna)); if ((p != _activePeers.end())&&(p->second->hasActiveDirectPath(now))) { - bestSupernode = p->second; + bestRootserver = p->second; break; } } @@ -170,80 +170,80 @@ SharedPtr Topology::getBestSupernode(const Address *avoid,unsigned int avo } } } else { - /* If I am not a supernode, the best supernode is the active one with + /* If I am not a rootserver, the best rootserver is the active one with * the lowest latency. */ - unsigned int l,bestSupernodeLatency = 65536; + unsigned int l,bestRootserverLatency = 65536; uint64_t lds,ldr; - // First look for a best supernode by comparing latencies, but exclude - // supernodes that have not responded to direct messages in order to + // First look for a best rootserver by comparing latencies, but exclude + // rootservers that have not responded to direct messages in order to // try to exclude any that are dead or unreachable. - for(std::vector< SharedPtr >::const_iterator sn(_supernodePeers.begin());sn!=_supernodePeers.end();) { + for(std::vector< SharedPtr >::const_iterator sn(_rootserverPeers.begin());sn!=_rootserverPeers.end();) { // Skip explicitly avoided relays for(unsigned int i=0;iaddress()) - goto keep_searching_for_supernodes; + goto keep_searching_for_rootservers; } // Skip possibly comatose or unreachable relays lds = (*sn)->lastDirectSend(); ldr = (*sn)->lastDirectReceive(); if ((lds)&&(lds > ldr)&&((lds - ldr) > ZT_PEER_RELAY_CONVERSATION_LATENCY_THRESHOLD)) - goto keep_searching_for_supernodes; + goto keep_searching_for_rootservers; if ((*sn)->hasActiveDirectPath(now)) { l = (*sn)->latency(); - if (bestSupernode) { - if ((l)&&(l < bestSupernodeLatency)) { - bestSupernodeLatency = l; - bestSupernode = *sn; + if (bestRootserver) { + if ((l)&&(l < bestRootserverLatency)) { + bestRootserverLatency = l; + bestRootserver = *sn; } } else { if (l) - bestSupernodeLatency = l; - bestSupernode = *sn; + bestRootserverLatency = l; + bestRootserver = *sn; } } -keep_searching_for_supernodes: +keep_searching_for_rootservers: ++sn; } - if (bestSupernode) { - bestSupernode->use(now); - return bestSupernode; + if (bestRootserver) { + bestRootserver->use(now); + return bestRootserver; } else if (strictAvoid) return SharedPtr(); // If we have nothing from above, just pick one without avoidance criteria. - for(std::vector< SharedPtr >::const_iterator sn=_supernodePeers.begin();sn!=_supernodePeers.end();++sn) { + for(std::vector< SharedPtr >::const_iterator sn=_rootserverPeers.begin();sn!=_rootserverPeers.end();++sn) { if ((*sn)->hasActiveDirectPath(now)) { unsigned int l = (*sn)->latency(); - if (bestSupernode) { - if ((l)&&(l < bestSupernodeLatency)) { - bestSupernodeLatency = l; - bestSupernode = *sn; + if (bestRootserver) { + if ((l)&&(l < bestRootserverLatency)) { + bestRootserverLatency = l; + bestRootserver = *sn; } } else { if (l) - bestSupernodeLatency = l; - bestSupernode = *sn; + bestRootserverLatency = l; + bestRootserver = *sn; } } } } - if (bestSupernode) - bestSupernode->use(now); - return bestSupernode; + if (bestRootserver) + bestRootserver->use(now); + return bestRootserver; } void Topology::clean(uint64_t now) { Mutex::Lock _l(_lock); for(std::map< Address,SharedPtr >::iterator p(_activePeers.begin());p!=_activePeers.end();) { - if (((now - p->second->lastUsed()) >= ZT_PEER_IN_MEMORY_EXPIRATION)&&(std::find(_supernodeAddresses.begin(),_supernodeAddresses.end(),p->first) == _supernodeAddresses.end())) { + if (((now - p->second->lastUsed()) >= ZT_PEER_IN_MEMORY_EXPIRATION)&&(std::find(_rootserverAddresses.begin(),_rootserverAddresses.end(),p->first) == _rootserverAddresses.end())) { _activePeers.erase(p++); } else ++p; } diff --git a/node/Topology.hpp b/node/Topology.hpp index 56a9709f..8aeae784 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -59,21 +59,21 @@ public: ~Topology(); /** - * Set up supernodes for this network + * Set up rootservers for this network * - * @param sn Supernodes for this network + * @param sn Rootservers for this network */ - void setSupernodes(const std::map< Identity,std::vector > &sn); + void setRootservers(const std::map< Identity,std::vector > &sn); /** - * Set up supernodes for this network + * Set up rootservers for this network * * This performs no signature verification of any kind. The caller must * check the signature of the root topology dictionary first. * - * @param sn Supernodes dictionary from root-topology + * @param sn Rootservers dictionary from root-topology */ - void setSupernodes(const Dictionary &sn); + void setRootservers(const Dictionary &sn); /** * Add a peer to database @@ -95,65 +95,65 @@ public: SharedPtr getPeer(const Address &zta); /** - * @return Vector of peers that are supernodes + * @return Vector of peers that are rootservers */ - inline std::vector< SharedPtr > supernodePeers() const + inline std::vector< SharedPtr > rootserverPeers() const { Mutex::Lock _l(_lock); - return _supernodePeers; + return _rootserverPeers; } /** - * @return Number of supernodes + * @return Number of rootservers */ - inline unsigned int numSupernodes() const + inline unsigned int numRootservers() const { Mutex::Lock _l(_lock); - return (unsigned int)_supernodePeers.size(); + return (unsigned int)_rootserverPeers.size(); } /** - * Get the current favorite supernode + * Get the current favorite rootserver * - * @return Supernode with lowest latency or NULL if none + * @return Rootserver with lowest latency or NULL if none */ - inline SharedPtr getBestSupernode() + inline SharedPtr getBestRootserver() { - return getBestSupernode((const Address *)0,0,false); + return getBestRootserver((const Address *)0,0,false); } /** - * Get the best supernode, avoiding supernodes listed in an array + * Get the best rootserver, avoiding rootservers listed in an array * - * This will get the best supernode (lowest latency, etc.) but will - * try to avoid the listed supernodes, only using them if no others + * This will get the best rootserver (lowest latency, etc.) but will + * try to avoid the listed rootservers, only using them if no others * are available. * * @param avoid Nodes to avoid * @param avoidCount Number of nodes to avoid - * @param strictAvoid If false, consider avoided supernodes anyway if no non-avoid supernodes are available - * @return Supernode or NULL if none + * @param strictAvoid If false, consider avoided rootservers anyway if no non-avoid rootservers are available + * @return Rootserver or NULL if none */ - SharedPtr getBestSupernode(const Address *avoid,unsigned int avoidCount,bool strictAvoid); + SharedPtr getBestRootserver(const Address *avoid,unsigned int avoidCount,bool strictAvoid); /** * @param zta ZeroTier address - * @return True if this is a designated supernode + * @return True if this is a designated rootserver */ - inline bool isSupernode(const Address &zta) const + inline bool isRootserver(const Address &zta) const throw() { Mutex::Lock _l(_lock); - return (std::find(_supernodeAddresses.begin(),_supernodeAddresses.end(),zta) != _supernodeAddresses.end()); + return (std::find(_rootserverAddresses.begin(),_rootserverAddresses.end(),zta) != _rootserverAddresses.end()); } /** - * @return Vector of supernode addresses + * @return Vector of rootserver addresses */ - inline std::vector
supernodeAddresses() const + inline std::vector
rootserverAddresses() const { Mutex::Lock _l(_lock); - return _supernodeAddresses; + return _rootserverAddresses; } /** @@ -206,13 +206,13 @@ private: const RuntimeEnvironment *RR; std::map< Address,SharedPtr > _activePeers; - std::map< Identity,std::vector > _supernodes; - std::vector< Address > _supernodeAddresses; - std::vector< SharedPtr > _supernodePeers; + std::map< Identity,std::vector > _rootservers; + std::vector< Address > _rootserverAddresses; + std::vector< SharedPtr > _rootserverPeers; Mutex _lock; - bool _amSupernode; + bool _amRootserver; }; } // namespace ZeroTier -- cgit v1.2.3