From 1615ef1114de4627e6952d96c62c1d561f8bd03c Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 17 Nov 2016 16:31:58 -0800 Subject: [PATCH] Rename getBestRoot() etc. --- node/Multicaster.cpp | 2 +- node/Node.cpp | 8 ++------ node/Packet.hpp | 13 +------------ node/Switch.cpp | 10 +++++----- node/Topology.hpp | 9 --------- objects.mk | 1 - 6 files changed, 9 insertions(+), 34 deletions(-) diff --git a/node/Multicaster.cpp b/node/Multicaster.cpp index 17649c7b0..f8d585013 100644 --- a/node/Multicaster.cpp +++ b/node/Multicaster.cpp @@ -229,7 +229,7 @@ void Multicaster::send( Address explicitGatherPeers[16]; unsigned int numExplicitGatherPeers = 0; - SharedPtr bestRoot(RR->topology->getBestRoot()); + SharedPtr bestRoot(RR->topology->getUpstreamPeer()); if (bestRoot) explicitGatherPeers[numExplicitGatherPeers++] = bestRoot->address(); explicitGatherPeers[numExplicitGatherPeers++] = Network::controllerFor(nwid); diff --git a/node/Node.cpp b/node/Node.cpp index c05a1850a..add3117e2 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -211,8 +211,7 @@ public: } if (upstream) { - // "Upstream" devices are roots and relays and get special treatment -- they stay alive - // forever and we try to keep (if available) both IPv4 and IPv6 channels open to them. + // We keep connections to upstream peers alive forever. bool needToContactIndirect = true; if (p->doPingAndKeepalive(_now,AF_INET)) { needToContactIndirect = false; @@ -231,11 +230,8 @@ public: } } + // If we don't have a direct path or a static endpoint, send something indirectly to find one. if (needToContactIndirect) { - // If this is an upstream and we have no stable endpoint for either IPv4 or IPv6, - // send a NOP indirectly if possible to see if we can get to this peer in any - // way whatsoever. This will e.g. find network preferred relays that lack - // stable endpoints by using root servers. Packet outp(p->address(),RR->identity.address(),Packet::VERB_NOP); RR->sw->send(outp,true); } diff --git a/node/Packet.hpp b/node/Packet.hpp index 7a742aad0..8ff817aa0 100644 --- a/node/Packet.hpp +++ b/node/Packet.hpp @@ -1049,18 +1049,7 @@ public: * OK or ERROR and has no special semantics outside of whatever the user * (via the ZeroTier core API) chooses to give it. */ - VERB_USER_MESSAGE = 0x14, - - /** - * Information related to federation and mesh-like behavior: - * <[2] 16-bit length of Dictionary> - * <[...] topology definition info Dictionary> - * - * This message can carry information that can be used to define topology - * and implement "mesh-like" behavior. It can optionally generate OK or - * ERROR, and these carry the same payload. - */ - VERB_TOPOLOGY_HINT = 0x15 + VERB_USER_MESSAGE = 0x14 }; /** diff --git a/node/Switch.cpp b/node/Switch.cpp index 82b13483f..7400fd62e 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -131,8 +131,8 @@ void Switch::onRemotePacket(const InetAddress &localAddr,const InetAddress &from } #endif - // Don't know peer or no direct path -- so relay via root server - relayTo = RR->topology->getBestRoot(); + // Don't know peer or no direct path -- so relay via someone upstream + relayTo = RR->topology->getUpstreamPeer(); if (relayTo) relayTo->sendDirect(fragment.data(),fragment.size(),now,true); } @@ -254,7 +254,7 @@ void Switch::onRemotePacket(const InetAddress &localAddr,const InetAddress &from return; } #endif - relayTo = RR->topology->getBestRoot(&source,1,true); + relayTo = RR->topology->getUpstreamPeer(&source,1,true); if (relayTo) relayTo->sendDirect(packet.data(),packet.size(),now,true); } @@ -763,7 +763,7 @@ unsigned long Switch::doTimerTasks(uint64_t now) Address Switch::_sendWhoisRequest(const Address &addr,const Address *peersAlreadyConsulted,unsigned int numPeersAlreadyConsulted) { - SharedPtr upstream(RR->topology->getBestRoot(peersAlreadyConsulted,numPeersAlreadyConsulted,false)); + SharedPtr upstream(RR->topology->getUpstreamPeer(peersAlreadyConsulted,numPeersAlreadyConsulted,false)); if (upstream) { Packet outp(upstream->address(),RR->identity.address(),Packet::VERB_WHOIS); addr.appendTo(outp); @@ -793,7 +793,7 @@ bool Switch::_trySend(const Packet &packet,bool encrypt) viaPath.zero(); } if (!viaPath) { - SharedPtr relay(RR->topology->getBestRoot()); + SharedPtr relay(RR->topology->getUpstreamPeer()); if ( (!relay) || (!(viaPath = relay->getBestPath(now,false))) ) { if (!(viaPath = peer->getBestPath(now,true))) return false; diff --git a/node/Topology.hpp b/node/Topology.hpp index 573d5ca2d..8e1d28cb0 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -163,15 +163,6 @@ public: */ void setUpstream(const Address &a,bool upstream); - /** - * @return Vector of root server addresses - */ - inline std::vector
rootAddresses() const - { - Mutex::Lock _l(_lock); - return _rootAddresses; - } - /** * @return Vector of active upstream addresses (including roots) */ diff --git a/objects.mk b/objects.mk index 16858ef3d..078a92a7b 100644 --- a/objects.mk +++ b/objects.mk @@ -4,7 +4,6 @@ OBJS=\ node/C25519.o \ node/Capability.o \ node/CertificateOfMembership.o \ - node/CertificateOfTrust.o \ node/Cluster.o \ node/Identity.o \ node/IncomingPacket.o \