Adam Ierymenko 8 years ago
parent
commit
640ad577d1
11 changed files with 1 additions and 223 deletions
  1. 0 0
      attic/ClusterGeoIpService.cpp
  2. 0 0
      attic/ClusterGeoIpService.hpp
  3. 0 5
      make-bsd.mk
  4. 0 4
      make-linux.mk
  5. 0 4
      make-mac.mk
  6. 0 5
      node/Constants.hpp
  7. 0 12
      node/Path.hpp
  8. 0 157
      node/Peer.cpp
  9. 0 31
      node/Peer.hpp
  10. 1 4
      node/Topology.cpp
  11. 0 1
      objects.mk

+ 0 - 0
service/ClusterGeoIpService.cpp → attic/ClusterGeoIpService.cpp


+ 0 - 0
service/ClusterGeoIpService.hpp → attic/ClusterGeoIpService.hpp


+ 0 - 5
make-bsd.mk

@@ -7,11 +7,6 @@ LIBS=
 include objects.mk
 ONE_OBJS+=osdep/BSDEthernetTap.o ext/http-parser/http_parser.o
 
-# Build with ZT_ENABLE_CLUSTER=1 to build with cluster support
-ifeq ($(ZT_ENABLE_CLUSTER),1)
-	DEFS+=-DZT_ENABLE_CLUSTER
-endif
-
 # "make debug" is a shortcut for this
 ifeq ($(ZT_DEBUG),1)
 	CFLAGS+=-Wall -Werror -g -pthread $(INCLUDES) $(DEFS)

+ 0 - 4
make-linux.mk

@@ -38,10 +38,6 @@ endif
 # Trying to use dynamically linked libhttp-parser causes tons of compatibility problems.
 ONE_OBJS+=ext/http-parser/http_parser.o
 
-ifeq ($(ZT_ENABLE_CLUSTER),1)
-	DEFS+=-DZT_ENABLE_CLUSTER
-endif
-
 ifeq ($(ZT_SYNOLOGY), 1)
 	DEFS+=-D__SYNOLOGY__
 endif

+ 0 - 4
make-mac.mk

@@ -33,10 +33,6 @@ else
 	DEFS+=-DZT_SOFTWARE_UPDATE_DEFAULT="\"download\""
 endif
 
-ifeq ($(ZT_ENABLE_CLUSTER),1)
-	DEFS+=-DZT_ENABLE_CLUSTER
-endif
-
 # Use fast ASM Salsa20/12 for x64 processors
 DEFS+=-DZT_USE_X64_ASM_SALSA2012
 CORE_OBJS+=ext/x64-salsa2012-asm/salsa2012.o

+ 0 - 5
node/Constants.hpp

@@ -218,11 +218,6 @@
  */
 #define ZT_HOUSEKEEPING_PERIOD 60000
 
-/**
- * How often in ms to write peer state to storage and/or cluster (approximate)
- */
-#define ZT_PEER_STATE_WRITE_PERIOD 10000
-
 /**
  * How long to remember peer records in RAM if they haven't been used
  */

+ 0 - 12
node/Path.hpp

@@ -283,18 +283,6 @@ public:
 	 */
 	inline uint64_t lastTrustEstablishedPacketReceived() const { return _lastTrustEstablishedPacketReceived; }
 
-	/**
-	 * @param lo Last out send
-	 * @param li Last in send
-	 * @param lt Last trust established packet received
-	 */
-	inline void updateFromRemoteState(const uint64_t lo,const uint64_t li,const uint64_t lt)
-	{
-		_lastOut = lo;
-		_lastIn = li;
-		_lastTrustEstablishedPacketReceived = lt;
-	}
-
 	/**
 	 * Return and increment outgoing packet counter (used with Packet::armor())
 	 *

+ 0 - 157
node/Peer.cpp

@@ -38,8 +38,6 @@ namespace ZeroTier {
 
 Peer::Peer(const RuntimeEnvironment *renv,const Identity &myIdentity,const Identity &peerIdentity) :
 	RR(renv),
-	_lastWroteState(0),
-	_lastReceivedStateTimestamp(0),
 	_lastReceive(0),
 	_lastNontrivialReceive(0),
 	_lastTriedMemorizedPath(0),
@@ -184,7 +182,6 @@ void Peer::received(
 				if (verb == Packet::VERB_OK) {
 					potentialNewPeerPath->lr = now;
 					potentialNewPeerPath->p = path;
-					_lastWroteState = 0; // force state write now
 				} else {
 					TRACE("got %s via unknown path %s(%s), confirming...",Packet::verbString(verb),_id.address().toString().c_str(),path->address().toString().c_str());
 					attemptToContactAt(tPtr,path->localSocket(),path->address(),now,true,path->nextOutgoingCounter());
@@ -263,9 +260,6 @@ void Peer::received(
 			}
 		}
 	}
-
-	if ((now - _lastWroteState) > ZT_PEER_STATE_WRITE_PERIOD)
-		writeState(tPtr,now);
 }
 
 bool Peer::sendDirect(void *tPtr,const void *data,unsigned int len,uint64_t now,bool force)
@@ -428,155 +422,4 @@ bool Peer::doPingAndKeepalive(void *tPtr,uint64_t now,int inetAddressFamily)
 	return false;
 }
 
-void Peer::writeState(void *tPtr,const uint64_t now)
-{
-	try {
-		Buffer<ZT_PEER_MAX_SERIALIZED_STATE_SIZE> b;
-
-		b.append((uint8_t)1); // version
-		b.append(now);
-
-		_id.serialize(b);
-
-		{
-			Mutex::Lock _l(_paths_m);
-			unsigned int count = 0;
-			if (_v4Path.lr)
-				++count;
-			if (_v6Path.lr)
-				++count;
-			b.append((uint8_t)count);
-			if (_v4Path.lr) {
-				b.append(_v4Path.lr);
-				b.append(_v4Path.p->lastOut());
-				b.append(_v4Path.p->lastIn());
-				b.append(_v4Path.p->lastTrustEstablishedPacketReceived());
-				_v4Path.p->address().serialize(b);
-			}
-			if (_v6Path.lr) {
-				b.append(_v6Path.lr);
-				b.append(_v6Path.p->lastOut());
-				b.append(_v6Path.p->lastIn());
-				b.append(_v6Path.p->lastTrustEstablishedPacketReceived());
-				_v6Path.p->address().serialize(b);
-			}
-		}
-
-		// Save space by sending these as time since now at 100ms resolution
-		b.append((uint16_t)(std::max(now - _lastReceive,(uint64_t)6553500) / 100));
-		b.append((uint16_t)(std::max(now - _lastNontrivialReceive,(uint64_t)6553500) / 100));
-		b.append((uint16_t)(std::max(now - _lastTriedMemorizedPath,(uint64_t)6553500) / 100));
-		b.append((uint16_t)(std::max(now - _lastDirectPathPushSent,(uint64_t)6553500) / 100));
-		b.append((uint16_t)(std::max(now - _lastDirectPathPushReceive,(uint64_t)6553500) / 100));
-		b.append((uint16_t)(std::max(now - _lastCredentialRequestSent,(uint64_t)6553500) / 100));
-		b.append((uint16_t)(std::max(now - _lastWhoisRequestReceived,(uint64_t)6553500) / 100));
-		b.append((uint16_t)(std::max(now - _lastEchoRequestReceived,(uint64_t)6553500) / 100));
-		b.append((uint16_t)(std::max(now - _lastComRequestReceived,(uint64_t)6553500) / 100));
-		b.append((uint16_t)(std::max(now - _lastComRequestSent,(uint64_t)6553500) / 100));
-		b.append((uint16_t)(std::max(now - _lastCredentialsReceived,(uint64_t)6553500) / 100));
-		b.append((uint16_t)(std::max(now - _lastTrustEstablishedPacketReceived,(uint64_t)6553500) / 100));
-
-		b.append((uint8_t)_vProto);
-		b.append((uint8_t)_vMajor);
-		b.append((uint8_t)_vMinor);
-		b.append((uint16_t)_vRevision);
-
-		b.append((uint16_t)0); // length of additional fields
-
-		uint64_t tmp[2];
-		tmp[0] = _id.address().toInt(); tmp[1] = 0;
-		//RR->node->stateObjectPut(tPtr,ZT_STATE_OBJECT_PEER_STATE,tmp,b.data(),b.size());
-
-		_lastWroteState = now;
-	} catch ( ... ) {} // sanity check, should not be possible
-}
-
-bool Peer::applyStateUpdate(const void *data,unsigned int len)
-{
-	try {
-		Buffer<ZT_PEER_MAX_SERIALIZED_STATE_SIZE> b(data,len);
-		unsigned int ptr = 0;
-
-		if (b[ptr++] != 1)
-			return false;
-		const uint64_t ts = b.at<uint64_t>(ptr); ptr += 8;
-		if (ts <= _lastReceivedStateTimestamp)
-			return false;
-
-		Identity id;
-		ptr += id.deserialize(b,ptr);
-		if (id != _id) // sanity check
-			return false;
-
-		const unsigned int pathCount = (unsigned int)b[ptr++];
-		{
-			Mutex::Lock _l(_paths_m);
-			for(unsigned int i=0;i<pathCount;++i) {
-				const uint64_t lr = b.at<uint64_t>(ptr); ptr += 8;
-				const uint64_t lastOut = b.at<uint64_t>(ptr); ptr += 8;
-				const uint64_t lastIn = b.at<uint64_t>(ptr); ptr += 8;
-				const uint64_t lastTrustEstablishedPacketReceived = b.at<uint64_t>(ptr); ptr += 8;
-				InetAddress addr;
-				ptr += addr.deserialize(b,ptr);
-				_PeerPath *p = (_PeerPath *)0;
-				switch(addr.ss_family) {
-					case AF_INET: p = &_v4Path; break;
-					case AF_INET6: p = &_v6Path; break;
-				}
-				if (p) {
-					if ( (!p->p) || (p->p->address() != addr) ) {
-						p->p = RR->topology->getPath(-1,addr);
-					}
-					p->lr = lr;
-					p->p->updateFromRemoteState(lastOut,lastIn,lastTrustEstablishedPacketReceived);
-				}
-			}
-		}
-
-		_lastReceive = std::max(_lastReceive,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-		_lastNontrivialReceive = std::max(_lastNontrivialReceive,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-		_lastTriedMemorizedPath = std::max(_lastTriedMemorizedPath,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-		_lastDirectPathPushSent = std::max(_lastDirectPathPushSent,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-		_lastDirectPathPushReceive = std::max(_lastDirectPathPushReceive,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-		_lastCredentialRequestSent = std::max(_lastCredentialRequestSent,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-		_lastWhoisRequestReceived = std::max(_lastWhoisRequestReceived,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-		_lastEchoRequestReceived = std::max(_lastEchoRequestReceived,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-		_lastComRequestReceived = std::max(_lastComRequestReceived,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-		_lastComRequestSent = std::max(_lastComRequestSent,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-		_lastCredentialsReceived = std::max(_lastCredentialsReceived,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-		_lastTrustEstablishedPacketReceived = std::max(_lastTrustEstablishedPacketReceived,ts - ((uint64_t)b.at<uint16_t>(ptr) * 100ULL)); ptr += 2;
-
-		_vProto = (uint16_t)b[ptr++];
-		_vMajor = (uint16_t)b[ptr++];
-		_vMinor = (uint16_t)b[ptr++];
-		_vRevision = b.at<uint16_t>(ptr); ptr += 2;
-
-		_lastReceivedStateTimestamp = ts;
-
-		return true;
-	} catch ( ... ) {} // ignore invalid state updates
-	return false;
-}
-
-SharedPtr<Peer> Peer::createFromStateUpdate(const RuntimeEnvironment *renv,void *tPtr,const void *data,unsigned int len)
-{
-	try {
-		Identity id;
-		{
-			Buffer<ZT_PEER_MAX_SERIALIZED_STATE_SIZE> b(data,len);
-			unsigned int ptr = 0;
-			if (b[ptr++] != 1)
-				return SharedPtr<Peer>();
-			ptr += 8; // skip TS, don't care
-			id.deserialize(b,ptr);
-		}
-		if (id) {
-			const SharedPtr<Peer> p(new Peer(renv,renv->identity,id));
-			if (p->applyStateUpdate(data,len))
-				return renv->topology->addPeer(tPtr,p);
-		}
-	} catch ( ... ) {}
-	return SharedPtr<Peer>();
-}
-
 } // namespace ZeroTier

+ 0 - 31
node/Peer.hpp

@@ -195,23 +195,6 @@ public:
 	 */
 	bool doPingAndKeepalive(void *tPtr,uint64_t now,int inetAddressFamily);
 
-	/**
-	 * Write object state to external storage and/or cluster network
-	 *
-	 * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
-	 * @param now Current time
-	 */
-	void writeState(void *tPtr,const uint64_t now);
-
-	/**
-	 * Apply a state update received from e.g. a remote cluster member
-	 *
-	 * @param data State update data
-	 * @param len Length of state update
-	 * @return True if state update was applied, false if ignored or invalid
-	 */
-	bool applyStateUpdate(const void *data,unsigned int len);
-
 	/**
 	 * Reset paths within a given IP scope and address family
 	 *
@@ -440,17 +423,6 @@ public:
 		return false;
 	}
 
-	/**
-	 * Create a peer from a remote state update
-	 *
-	 * @param renv Runtime environment
-	 * @param tPtr Thread pointer to be handed through to any callbacks called as a result of this call
-	 * @param data State update data
-	 * @param len State update length
-	 * @return Peer or NULL if data was invalid
-	 */
-	static SharedPtr<Peer> createFromStateUpdate(const RuntimeEnvironment *renv,void *tPtr,const void *data,unsigned int len);
-
 private:
 	struct _PeerPath
 	{
@@ -463,9 +435,6 @@ private:
 
 	const RuntimeEnvironment *RR;
 
-	uint64_t _lastWroteState;
-	uint64_t _lastReceivedStateTimestamp;
-
 	uint64_t _lastReceive; // direct or indirect
 	uint64_t _lastNontrivialReceive; // frames, things like netconf, etc.
 	uint64_t _lastTriedMemorizedPath;

+ 1 - 4
node/Topology.cpp

@@ -395,11 +395,8 @@ void Topology::doPeriodicTasks(void *tPtr,uint64_t now)
 		Address *a = (Address *)0;
 		SharedPtr<Peer> *p = (SharedPtr<Peer> *)0;
 		while (i.next(a,p)) {
-			if ( (!(*p)->isAlive(now)) && (std::find(_upstreamAddresses.begin(),_upstreamAddresses.end(),*a) == _upstreamAddresses.end()) ) {
+			if ( (!(*p)->isAlive(now)) && (std::find(_upstreamAddresses.begin(),_upstreamAddresses.end(),*a) == _upstreamAddresses.end()) )
 				_peers.erase(*a);
-			} else {
-				(*p)->writeState(tPtr,now);
-			}
 		}
 	}
 

+ 0 - 1
objects.mk

@@ -31,7 +31,6 @@ ONE_OBJS=\
 	osdep/ManagedRoute.o \
 	osdep/Http.o \
 	osdep/OSUtils.o \
-	service/ClusterGeoIpService.o \
 	service/SoftwareUpdater.o \
 	service/OneService.o