2
0
Эх сурвалжийг харах

Rename getBestRoot() etc.

Adam Ierymenko 8 жил өмнө
parent
commit
1615ef1114

+ 1 - 1
node/Multicaster.cpp

@@ -229,7 +229,7 @@ void Multicaster::send(
 
 				Address explicitGatherPeers[16];
 				unsigned int numExplicitGatherPeers = 0;
-				SharedPtr<Peer> bestRoot(RR->topology->getBestRoot());
+				SharedPtr<Peer> bestRoot(RR->topology->getUpstreamPeer());
 				if (bestRoot)
 					explicitGatherPeers[numExplicitGatherPeers++] = bestRoot->address();
 				explicitGatherPeers[numExplicitGatherPeers++] = Network::controllerFor(nwid);

+ 2 - 6
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);
 			}

+ 1 - 12
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
 	};
 
 	/**

+ 5 - 5
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<Peer> upstream(RR->topology->getBestRoot(peersAlreadyConsulted,numPeersAlreadyConsulted,false));
+	SharedPtr<Peer> 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<Peer> relay(RR->topology->getBestRoot());
+			SharedPtr<Peer> relay(RR->topology->getUpstreamPeer());
 			if ( (!relay) || (!(viaPath = relay->getBestPath(now,false))) ) {
 				if (!(viaPath = peer->getBestPath(now,true)))
 					return false;

+ 0 - 9
node/Topology.hpp

@@ -163,15 +163,6 @@ public:
 	 */
 	void setUpstream(const Address &a,bool upstream);
 
-	/**
-	 * @return Vector of root server addresses
-	 */
-	inline std::vector<Address> rootAddresses() const
-	{
-		Mutex::Lock _l(_lock);
-		return _rootAddresses;
-	}
-
 	/**
 	 * @return Vector of active upstream addresses (including roots)
 	 */

+ 0 - 1
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 \