Browse Source

Add some more TRACE output for certs.

Adam Ierymenko 11 years ago
parent
commit
010616e3ae
3 changed files with 12 additions and 2 deletions
  1. 7 1
      node/Network.cpp
  2. 2 0
      node/Network.hpp
  3. 3 1
      node/PacketDecoder.cpp

+ 7 - 1
node/Network.cpp

@@ -142,6 +142,9 @@ void Network::requestConfiguration()
 
 
 void Network::addMembershipCertificate(const CertificateOfMembership &cert)
 void Network::addMembershipCertificate(const CertificateOfMembership &cert)
 {
 {
+	if (!cert) // sanity check
+		return;
+
 	Mutex::Lock _l(_lock);
 	Mutex::Lock _l(_lock);
 
 
 	// We go ahead and accept certs provisionally even if _isOpen is true, since
 	// We go ahead and accept certs provisionally even if _isOpen is true, since
@@ -149,8 +152,10 @@ void Network::addMembershipCertificate(const CertificateOfMembership &cert)
 	// These will be purged on clean() for open networks eventually.
 	// These will be purged on clean() for open networks eventually.
 
 
 	CertificateOfMembership &old = _membershipCertificates[cert.issuedTo()];
 	CertificateOfMembership &old = _membershipCertificates[cert.issuedTo()];
-	if (cert.timestamp() >= old.timestamp())
+	if (cert.timestamp() >= old.timestamp()) {
+		TRACE("got new certificate for %s on network %.16llx",cert.issuedTo().toString().c_str(),cert.networkId());
 		old = cert;
 		old = cert;
+	}
 }
 }
 
 
 bool Network::isAllowed(const Address &peer) const
 bool Network::isAllowed(const Address &peer) const
@@ -230,6 +235,7 @@ void Network::_pushMembershipCertificate(const Address &peer,bool force,uint64_t
 	uint64_t &lastPushed = _lastPushedMembershipCertificate[peer];
 	uint64_t &lastPushed = _lastPushedMembershipCertificate[peer];
 	if ((force)||((now - lastPushed) > pushTimeout)) {
 	if ((force)||((now - lastPushed) > pushTimeout)) {
 		lastPushed = now;
 		lastPushed = now;
+		TRACE("pushing membership cert for %.16llx to %s",(unsigned long long)_id,peer.toString().c_str());
 
 
 		Packet outp(peer,_r->identity.address(),Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE);
 		Packet outp(peer,_r->identity.address(),Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE);
 		_config->com().serialize(outp);
 		_config->com().serialize(outp);

+ 2 - 0
node/Network.hpp

@@ -322,6 +322,8 @@ public:
 	}
 	}
 
 
 	/**
 	/**
+	 * Get current network config or return NULL
+	 *
 	 * @return Network configuration -- may be NULL
 	 * @return Network configuration -- may be NULL
 	 */
 	 */
 	inline SharedPtr<NetworkConfig> config2() const
 	inline SharedPtr<NetworkConfig> config2() const

+ 3 - 1
node/PacketDecoder.cpp

@@ -847,8 +847,10 @@ bool PacketDecoder::_doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *_r,const
 		while ((ptr + sizeof(uint64_t)) <= size()) {
 		while ((ptr + sizeof(uint64_t)) <= size()) {
 			uint64_t nwid = at<uint64_t>(ptr); ptr += sizeof(uint64_t);
 			uint64_t nwid = at<uint64_t>(ptr); ptr += sizeof(uint64_t);
 			SharedPtr<Network> nw(_r->nc->network(nwid));
 			SharedPtr<Network> nw(_r->nc->network(nwid));
-			if ((nw)&&(source() == nw->controller())) // only respond to requests from controller
+			if ((nw)&&(source() == nw->controller())) { // only respond to requests from controller
+				TRACE("NETWORK_CONFIG_REFRESH from %s, refreshing network %.16llx",source().toString().c_str(),nwid);
 				nw->requestConfiguration();
 				nw->requestConfiguration();
+			}
 		}
 		}
 	} catch (std::exception &exc) {
 	} catch (std::exception &exc) {
 		TRACE("dropped NETWORK_CONFIG_REFRESH from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),exc.what());
 		TRACE("dropped NETWORK_CONFIG_REFRESH from %s(%s): unexpected exception: %s",source().toString().c_str(),_remoteAddress.toString().c_str(),exc.what());