From 4d594b24bc992962c125b3c0ff18ad4d670090c3 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 7 Oct 2013 16:13:52 -0400 Subject: Automagically push netconf certs -- Network support. --- node/Network.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'node/Network.cpp') diff --git a/node/Network.cpp b/node/Network.cpp index 911ae998..2d08a91f 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -169,6 +169,30 @@ void Network::addMembershipCertificate(const Address &peer,const CertificateOfMe _membershipCertificates[peer] = cert; } +void Network::pushMembershipCertificate(const Address &peer,bool force,uint64_t now) +{ + Mutex::Lock _l(_lock); + + if (_isOpen) + return; + + uint64_t timestampMaxDelta = _myCertificate.timestampMaxDelta(); + if (!timestampMaxDelta) { + LOG("unable to push my certificate to %s for network %.16llx: certificate invalid, missing required timestamp field",peer.toString().c_str(),_id); + return; // required field missing! + } + + uint64_t &lastPushed = _lastPushedMembershipCertificate[peer]; + if ((force)||((now - lastPushed) > (timestampMaxDelta / 2))) { + lastPushed = now; + + Packet outp(peer,_r->identity.address(),Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE); + outp.append((uint64_t)_id); + _myCertificate.serialize(outp); + _r->sw->send(outp,true); + } +} + bool Network::isAllowed(const Address &peer) const { // Exceptions can occur if we do not yet have *our* configuration. -- cgit v1.2.3