mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-27 22:39:46 +00:00
Cluster fix: was accumulating remote endpoints endlessly.
This commit is contained in:
parent
2a3dd53952
commit
964b30902a
@ -143,13 +143,20 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
|
||||
return;
|
||||
const uint16_t fromMemberId = dmsg.at<uint16_t>(0);
|
||||
unsigned int ptr = 2;
|
||||
if (fromMemberId == _id)
|
||||
if (fromMemberId == _id) // sanity check: we don't talk to ourselves
|
||||
return;
|
||||
const uint16_t toMemberId = dmsg.at<uint16_t>(ptr);
|
||||
ptr += 2;
|
||||
if (toMemberId != _id)
|
||||
if (toMemberId != _id) // sanity check: message not for us?
|
||||
return;
|
||||
|
||||
{ // make sure sender is actually considered a member
|
||||
Mutex::Lock _l3(_memberIds_m);
|
||||
if (std::find(_memberIds.begin(),_memberIds.end(),fromMemberId) == _memberIds.end())
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
_Member &m = _members[fromMemberId];
|
||||
Mutex::Lock mlck(m.lock);
|
||||
|
||||
@ -157,6 +164,8 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
|
||||
while (ptr < dmsg.size()) {
|
||||
const unsigned int mlen = dmsg.at<uint16_t>(ptr); ptr += 2;
|
||||
const unsigned int nextPtr = ptr + mlen;
|
||||
if (nextPtr > dmsg.size())
|
||||
break;
|
||||
|
||||
int mtype = -1;
|
||||
try {
|
||||
@ -176,6 +185,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
|
||||
std::string addrs;
|
||||
#endif
|
||||
unsigned int physicalAddressCount = dmsg[ptr++];
|
||||
m.zeroTierPhysicalEndpoints.clear();
|
||||
for(unsigned int i=0;i<physicalAddressCount;++i) {
|
||||
m.zeroTierPhysicalEndpoints.push_back(InetAddress());
|
||||
ptr += m.zeroTierPhysicalEndpoints.back().deserialize(dmsg,ptr);
|
||||
@ -192,7 +202,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
|
||||
}
|
||||
m.lastReceivedAliveAnnouncement = RR->node->now();
|
||||
#ifdef ZT_TRACE
|
||||
TRACE("[%u] I'm alive! send me peers at %s",(unsigned int)fromMemberId,addrs.c_str());
|
||||
TRACE("[%u] I'm alive! peers may be redirected to: %s",(unsigned int)fromMemberId,addrs.c_str());
|
||||
#endif
|
||||
} break;
|
||||
|
||||
@ -351,6 +361,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
|
||||
// drop invalids
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Cluster::sendViaCluster(const Address &fromPeerAddress,const Address &toPeerAddress,const void *data,unsigned int len)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user