mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-06 12:33:44 +02: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
2 changed files with 16 additions and 9 deletions
|
@ -358,16 +358,18 @@ void Topology::_setWorld(const World &newWorld)
|
||||||
_rootAddresses.clear();
|
_rootAddresses.clear();
|
||||||
_rootPeers.clear();
|
_rootPeers.clear();
|
||||||
for(std::vector<World::Root>::const_iterator r(_world.roots().begin());r!=_world.roots().end();++r) {
|
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());
|
_rootAddresses.push_back(r->identity.address());
|
||||||
SharedPtr<Peer> *rp = _peers.get(r->identity.address());
|
if (r->identity.address() == RR->identity.address()) {
|
||||||
if (rp) {
|
_amRoot = true;
|
||||||
_rootPeers.push_back(*rp);
|
} else {
|
||||||
} else if (r->identity.address() != RR->identity.address()) {
|
SharedPtr<Peer> *rp = _peers.get(r->identity.address());
|
||||||
SharedPtr<Peer> newrp(new Peer(RR->identity,r->identity));
|
if (rp) {
|
||||||
_peers.set(r->identity.address(),newrp);
|
_rootPeers.push_back(*rp);
|
||||||
_rootPeers.push_back(newrp);
|
} 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 _peers.entries();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return True if I am a root server in the current World
|
||||||
|
*/
|
||||||
|
inline bool amRoot() const throw() { return _amRoot; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Identity _getIdentity(const Address &zta);
|
Identity _getIdentity(const Address &zta);
|
||||||
void _setWorld(const World &newWorld);
|
void _setWorld(const World &newWorld);
|
||||||
|
|
Loading…
Add table
Reference in a new issue