mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-20 17:00:49 +00:00
Cleanup, including simplification of root server picking algorithm since we no longer need all that craziness.
This commit is contained in:
parent
9617208e40
commit
8a7a0b6b88
@ -239,7 +239,7 @@ void Cluster::handleIncomingStateMessage(const void *msg,unsigned int len)
|
||||
const MAC mac(dmsg.field(ptr,6),6); ptr += 6;
|
||||
const uint32_t adi = dmsg.at<uint32_t>(ptr); ptr += 4;
|
||||
RR->mc->add(RR->node->now(),nwid,MulticastGroup(mac,adi),address);
|
||||
TRACE("[%u] %s likes %s/%u on %.16llu",(unsigned int)fromMemberId,address.toString().c_str(),mac.toString().c_str(),(unsigned int)adi,nwid);
|
||||
TRACE("[%u] %s likes %s/%.8x on %.16llu",(unsigned int)fromMemberId,address.toString().c_str(),mac.toString().c_str(),(unsigned int)adi,nwid);
|
||||
} break;
|
||||
|
||||
case STATE_MESSAGE_COM: {
|
||||
|
@ -158,7 +158,20 @@ public:
|
||||
* while PROXY_SEND is used to implement proxy sending (which right
|
||||
* now is only used to send RENDEZVOUS).
|
||||
*/
|
||||
STATE_MESSAGE_PROXY_SEND = 6
|
||||
STATE_MESSAGE_PROXY_SEND = 6,
|
||||
|
||||
/**
|
||||
* Replicate a network config for a network we belong to:
|
||||
* <[8] 64-bit network ID>
|
||||
* <[2] 16-bit length of network config>
|
||||
* <[...] serialized network config>
|
||||
*
|
||||
* This is used by clusters to avoid every member having to query
|
||||
* for the same netconf for networks all members belong to.
|
||||
*
|
||||
* TODO: not implemented yet!
|
||||
*/
|
||||
STATE_MESSAGE_NETWORK_CONFIG = 7
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -215,10 +215,45 @@ SharedPtr<Peer> Topology::getBestRoot(const Address *avoid,unsigned int avoidCou
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
/* If I am not a root server, the best root server is the active one with
|
||||
* the lowest latency. */
|
||||
|
||||
unsigned int bestLatencyOverall = ~((unsigned int)0);
|
||||
unsigned int bestLatencyNotAvoid = ~((unsigned int)0);
|
||||
const SharedPtr<Peer> *bestOverall = (const SharedPtr<Peer> *)0;
|
||||
const SharedPtr<Peer> *bestNotAvoid = (const SharedPtr<Peer> *)0;
|
||||
|
||||
for(std::vector< SharedPtr<Peer> >::const_iterator r(_rootPeers.begin());r!=_rootPeers.end();++r) {
|
||||
if ((*r)->hasActiveDirectPath(now)) {
|
||||
bool avoiding = false;
|
||||
for(unsigned int i=0;i<avoidCount;++i) {
|
||||
if (avoid[i] == (*r)->address()) {
|
||||
avoiding = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
unsigned int l = (*r)->latency();
|
||||
if (!l) l = ~l; // zero latency indicates no measurment, so make this 'max'
|
||||
if (l <= bestLatencyOverall) {
|
||||
bestLatencyOverall = l;
|
||||
bestOverall = &(*r);
|
||||
}
|
||||
if ((!avoiding)&&(l <= bestLatencyNotAvoid)) {
|
||||
bestLatencyNotAvoid = l;
|
||||
bestNotAvoid = &(*r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bestNotAvoid)
|
||||
return *bestNotAvoid;
|
||||
else if ((!strictAvoid)&&(bestOverall))
|
||||
return *bestOverall;
|
||||
return SharedPtr<Peer>();
|
||||
|
||||
/*
|
||||
unsigned int l,bestLatency = 65536;
|
||||
uint64_t lds,ldr;
|
||||
|
||||
@ -278,6 +313,7 @@ keep_searching_for_roots:
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
if (bestRoot)
|
||||
|
Loading…
x
Reference in New Issue
Block a user