mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-13 22:12:56 +00:00
Fix bug in setWorld that might have caused a peer entry for myself (which would never be used)
This commit is contained in:
parent
29b966894c
commit
e6a63f5547
@ -358,16 +358,18 @@ void Topology::_setWorld(const World &newWorld)
|
||||
_rootAddresses.clear();
|
||||
_rootPeers.clear();
|
||||
for(std::vector<World::Root>::const_iterator r(_world.roots().begin());r!=_world.roots().end();++r) {
|
||||
if (r->identity == RR->identity)
|
||||
_amRoot = true;
|
||||
_rootAddresses.push_back(r->identity.address());
|
||||
SharedPtr<Peer> *rp = _peers.get(r->identity.address());
|
||||
if (rp) {
|
||||
_rootPeers.push_back(*rp);
|
||||
} else if (r->identity.address() != RR->identity.address()) {
|
||||
SharedPtr<Peer> newrp(new Peer(RR->identity,r->identity));
|
||||
_peers.set(r->identity.address(),newrp);
|
||||
_rootPeers.push_back(newrp);
|
||||
if (r->identity.address() == RR->identity.address()) {
|
||||
_amRoot = true;
|
||||
} else {
|
||||
SharedPtr<Peer> *rp = _peers.get(r->identity.address());
|
||||
if (rp) {
|
||||
_rootPeers.push_back(*rp);
|
||||
} else {
|
||||
SharedPtr<Peer> newrp(new Peer(RR->identity,r->identity));
|
||||
_peers.set(r->identity.address(),newrp);
|
||||
_rootPeers.push_back(newrp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,6 +225,11 @@ public:
|
||||
return _peers.entries();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if I am a root server in the current World
|
||||
*/
|
||||
inline bool amRoot() const throw() { return _amRoot; }
|
||||
|
||||
private:
|
||||
Identity _getIdentity(const Address &zta);
|
||||
void _setWorld(const World &newWorld);
|
||||
|
Loading…
x
Reference in New Issue
Block a user