mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02:00
Fix for sharing of capabilities in 1.4 (problem introduced when push frequency was reduced)
This commit is contained in:
parent
4a9030b4a0
commit
75ebe5172f
3 changed files with 18 additions and 12 deletions
|
@ -48,9 +48,12 @@ Membership::Membership() :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Membership::pushCredentials(const RuntimeEnvironment *RR,void *tPtr,const int64_t now,const Address &peerAddress,const NetworkConfig &nconf,int localCapabilityIndex)
|
void Membership::pushCredentials(const RuntimeEnvironment *RR,void *tPtr,const int64_t now,const Address &peerAddress,const NetworkConfig &nconf)
|
||||||
{
|
{
|
||||||
const Capability *sendCap = (localCapabilityIndex >= 0) ? &(nconf.capabilities[localCapabilityIndex]) : (const Capability *)0;
|
const Capability *sendCaps[ZT_MAX_NETWORK_CAPABILITIES];
|
||||||
|
unsigned int sendCapCount = 0;
|
||||||
|
for(unsigned int c=0;c<nconf.capabilityCount;++c)
|
||||||
|
sendCaps[sendCapCount++] = &(nconf.capabilities[c]);
|
||||||
|
|
||||||
const Tag *sendTags[ZT_MAX_NETWORK_TAGS];
|
const Tag *sendTags[ZT_MAX_NETWORK_TAGS];
|
||||||
unsigned int sendTagCount = 0;
|
unsigned int sendTagCount = 0;
|
||||||
|
@ -62,10 +65,11 @@ void Membership::pushCredentials(const RuntimeEnvironment *RR,void *tPtr,const i
|
||||||
for(unsigned int c=0;c<nconf.certificateOfOwnershipCount;++c)
|
for(unsigned int c=0;c<nconf.certificateOfOwnershipCount;++c)
|
||||||
sendCoos[sendCooCount++] = &(nconf.certificatesOfOwnership[c]);
|
sendCoos[sendCooCount++] = &(nconf.certificatesOfOwnership[c]);
|
||||||
|
|
||||||
|
unsigned int capPtr = 0;
|
||||||
unsigned int tagPtr = 0;
|
unsigned int tagPtr = 0;
|
||||||
unsigned int cooPtr = 0;
|
unsigned int cooPtr = 0;
|
||||||
bool sendCom = (bool)(nconf.com);
|
bool sendCom = (bool)(nconf.com);
|
||||||
while ((tagPtr < sendTagCount)||(cooPtr < sendCooCount)||(sendCom)||(sendCap)) {
|
while ((capPtr < sendCapCount)||(tagPtr < sendTagCount)||(cooPtr < sendCooCount)||(sendCom)) {
|
||||||
Packet outp(peerAddress,RR->identity.address(),Packet::VERB_NETWORK_CREDENTIALS);
|
Packet outp(peerAddress,RR->identity.address(),Packet::VERB_NETWORK_CREDENTIALS);
|
||||||
|
|
||||||
if (sendCom) {
|
if (sendCom) {
|
||||||
|
@ -74,11 +78,14 @@ void Membership::pushCredentials(const RuntimeEnvironment *RR,void *tPtr,const i
|
||||||
}
|
}
|
||||||
outp.append((uint8_t)0x00);
|
outp.append((uint8_t)0x00);
|
||||||
|
|
||||||
if (sendCap) {
|
const unsigned int capCountAt = outp.size();
|
||||||
outp.append((uint16_t)1);
|
outp.addSize(2);
|
||||||
sendCap->serialize(outp);
|
unsigned int thisPacketCapCount = 0;
|
||||||
sendCap = (const Capability *)0;
|
while ((capPtr < sendCapCount)&&((outp.size() + sizeof(Capability) + 16) < ZT_PROTO_MAX_PACKET_LENGTH)) {
|
||||||
} else outp.append((uint16_t)0);
|
sendCaps[capPtr++]->serialize(outp);
|
||||||
|
++thisPacketCapCount;
|
||||||
|
}
|
||||||
|
outp.setAt(capCountAt,(uint16_t)thisPacketCapCount);
|
||||||
|
|
||||||
const unsigned int tagCountAt = outp.size();
|
const unsigned int tagCountAt = outp.size();
|
||||||
outp.addSize(2);
|
outp.addSize(2);
|
||||||
|
|
|
@ -74,9 +74,8 @@ public:
|
||||||
* @param now Current time
|
* @param now Current time
|
||||||
* @param peerAddress Address of member peer (the one that this Membership describes)
|
* @param peerAddress Address of member peer (the one that this Membership describes)
|
||||||
* @param nconf My network config
|
* @param nconf My network config
|
||||||
* @param localCapabilityIndex Index of local capability to include (in nconf.capabilities[]) or -1 if none
|
|
||||||
*/
|
*/
|
||||||
void pushCredentials(const RuntimeEnvironment *RR,void *tPtr,const int64_t now,const Address &peerAddress,const NetworkConfig &nconf,int localCapabilityIndex);
|
void pushCredentials(const RuntimeEnvironment *RR,void *tPtr,const int64_t now,const Address &peerAddress,const NetworkConfig &nconf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return True if we haven't pushed credentials in a long time (to cause proactive credential push)
|
* @return True if we haven't pushed credentials in a long time (to cause proactive credential push)
|
||||||
|
|
|
@ -365,7 +365,7 @@ public:
|
||||||
inline void pushCredentialsNow(void *tPtr,const Address &to,const int64_t now)
|
inline void pushCredentialsNow(void *tPtr,const Address &to,const int64_t now)
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_lock);
|
Mutex::Lock _l(_lock);
|
||||||
_membership(to).pushCredentials(RR,tPtr,now,to,_config,-1);
|
_membership(to).pushCredentials(RR,tPtr,now,to,_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -380,7 +380,7 @@ public:
|
||||||
Mutex::Lock _l(_lock);
|
Mutex::Lock _l(_lock);
|
||||||
Membership &m = _membership(to);
|
Membership &m = _membership(to);
|
||||||
if (m.shouldPushCredentials(now))
|
if (m.shouldPushCredentials(now))
|
||||||
m.pushCredentials(RR,tPtr,now,to,_config,-1);
|
m.pushCredentials(RR,tPtr,now,to,_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue