mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-18 02:40:13 +00:00
More tying up of certificate of membership stuff in the client.
This commit is contained in:
parent
bbcd76ecd0
commit
5901972958
@ -86,6 +86,9 @@ void CertificateOfMembership::fromString(const char *s)
|
||||
_signedBy.zero();
|
||||
memset(_signature.data,0,_signature.size());
|
||||
|
||||
if (!*s)
|
||||
return;
|
||||
|
||||
unsigned int colonAt = 0;
|
||||
while ((s[colonAt])&&(s[colonAt] != ':')) ++colonAt;
|
||||
|
||||
|
@ -265,6 +265,7 @@ public:
|
||||
*
|
||||
* Invalid strings will result in invalid or undefined certificate
|
||||
* contents. These will subsequently fail validation and comparison.
|
||||
* Empty strings will result in an empty certificate.
|
||||
*
|
||||
* @param s String to deserialize
|
||||
*/
|
||||
|
@ -221,12 +221,14 @@ void Network::_CBhandleTapData(void *arg,const MAC &from,const MAC &to,unsigned
|
||||
|
||||
void Network::_pushMembershipCertificate(const Address &peer,bool force,uint64_t now)
|
||||
{
|
||||
uint64_t timestampMaxDelta = _config->com().timestampMaxDelta();
|
||||
if (!timestampMaxDelta)
|
||||
uint64_t pushTimeout = _config->com().timestampMaxDelta() / 2;
|
||||
if (!pushTimeout)
|
||||
return; // still waiting on my own cert
|
||||
if (pushTimeout > 1000)
|
||||
pushTimeout -= 1000;
|
||||
|
||||
uint64_t &lastPushed = _lastPushedMembershipCertificate[peer];
|
||||
if ((force)||((now - lastPushed) > (timestampMaxDelta / 2))) {
|
||||
if ((force)||((now - lastPushed) > pushTimeout)) {
|
||||
lastPushed = now;
|
||||
|
||||
Packet outp(peer,_r->identity.address(),Packet::VERB_NETWORK_MEMBERSHIP_CERTIFICATE);
|
||||
|
@ -203,7 +203,7 @@ public:
|
||||
inline void pushMembershipCertificate(const Address &peer,bool force,uint64_t now)
|
||||
{
|
||||
Mutex::Lock _l(_lock);
|
||||
if ((_config)&&(!_config->isOpen()))
|
||||
if ((_config)&&(!_config->isOpen())&&(_config->com()))
|
||||
_pushMembershipCertificate(peer,force,now);
|
||||
}
|
||||
|
||||
@ -214,15 +214,17 @@ public:
|
||||
* len is reached or a null address is encountered.
|
||||
*
|
||||
* @param peers Packed array of 5-byte big-endian addresses
|
||||
* @param len Length of peers[] in total, MUST be a multiple of 5
|
||||
* @param len Length of peers[] in total (bytes, not addresses)
|
||||
* @param force If true, push even if we've already done so within required time frame
|
||||
* @param now Current time
|
||||
*/
|
||||
inline void pushMembershipCertificate(const void *peers,unsigned int len,bool force,uint64_t now)
|
||||
{
|
||||
Mutex::Lock _l(_lock);
|
||||
if ((_config)&&(!_config->isOpen())) {
|
||||
if ((_config)&&(!_config->isOpen())&&(_config->com())) {
|
||||
for(unsigned int i=0;i<len;i+=ZT_ADDRESS_LENGTH) {
|
||||
if ((i + ZT_ADDRESS_LENGTH) > len)
|
||||
break;
|
||||
Address a((char *)peers + i,ZT_ADDRESS_LENGTH);
|
||||
if (a)
|
||||
_pushMembershipCertificate(a,force,now);
|
||||
|
@ -128,6 +128,8 @@ void NetworkConfig::_fromDictionary(const Dictionary &d)
|
||||
if (params.size() >= 3)
|
||||
_multicastRates[MulticastGroup(i->first)] = MulticastRate(Utils::hexStrToUInt(params[0].c_str()),Utils::hexStrToUInt(params[1].c_str()),Utils::hexStrToUInt(params[2].c_str()));
|
||||
}
|
||||
|
||||
_com.fromString(d.get(ZT_NETWORKCONFIG_DICT_KEY_CERTIFICATE_OF_MEMBERSHIP,std::string()));
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
Loading…
Reference in New Issue
Block a user