Add and send certificates of representation to tell people what our valid upstreams are. These are not used yet but will be needed for future privacy modes, etc. Also some cleanup.

This commit is contained in:
Adam Ierymenko 2017-02-04 13:17:00 -08:00
parent beb642faa5
commit 3587aa1ea7
11 changed files with 247 additions and 35 deletions

View file

@ -38,6 +38,7 @@
#include "InetAddress.hpp"
#include "Hashtable.hpp"
#include "World.hpp"
#include "CertificateOfRepresentation.hpp"
namespace ZeroTier {
@ -383,6 +384,25 @@ public:
_trustedPathCount = count;
}
/**
* @return Current certificate of representation (copy)
*/
inline CertificateOfRepresentation certificateOfRepresentation() const
{
Mutex::Lock _l(_upstreams_m);
return _cor;
}
/**
* @param buf Buffer to receive COR
*/
template<unsigned int C>
void appendCertificateOfRepresentation(Buffer<C> &buf)
{
Mutex::Lock _l(_upstreams_m);
_cor.serialize(buf);
}
private:
Identity _getIdentity(const Address &zta);
void _memoizeUpstreams();
@ -404,6 +424,7 @@ private:
std::vector<World> _moons;
std::vector<Address> _contactingMoons;
std::vector<Address> _upstreamAddresses;
CertificateOfRepresentation _cor;
bool _amRoot;
Mutex _upstreams_m; // locks worlds, upstream info, moon info, etc.
};