mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Surface logic in Topology.
This commit is contained in:
parent
61cff47f5b
commit
37d23336ed
3 changed files with 32 additions and 1 deletions
|
@ -46,7 +46,7 @@ public:
|
||||||
* @param remote Remote address as reflected by any trusted peer
|
* @param remote Remote address as reflected by any trusted peer
|
||||||
* @return True if our external surface has changed
|
* @return True if our external surface has changed
|
||||||
*/
|
*/
|
||||||
inline bool revise(const InetAddress &remote)
|
inline bool update(const InetAddress &remote)
|
||||||
throw()
|
throw()
|
||||||
{
|
{
|
||||||
const unsigned long idx = (remote.isV4() ? 0 : 2) | (remote.isLinkLocal() ? 1 : 0);
|
const unsigned long idx = (remote.isV4() ? 0 : 2) | (remote.isLinkLocal() ? 1 : 0);
|
||||||
|
|
|
@ -258,6 +258,24 @@ void Topology::clean(uint64_t now)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Topology::updateSurface(const SharedPtr<Peer> &remotePeer,const InetAddress &mirroredAddress)
|
||||||
|
{
|
||||||
|
Mutex::Lock _l(_lock);
|
||||||
|
|
||||||
|
if (std::find(_supernodeAddresses.begin(),_supernodeAddresses.end(),remotePeer->address()) == _supernodeAddresses.end())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (_surface.update(mirroredAddress)) {
|
||||||
|
// Clear non-fixed paths for all peers
|
||||||
|
for(std::map< Address,SharedPtr<Peer> >::const_iterator ap(_activePeers.begin());ap!=_activePeers.end();++ap)
|
||||||
|
ap->second->clearPaths(false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Topology::authenticateRootTopology(const Dictionary &rt)
|
bool Topology::authenticateRootTopology(const Dictionary &rt)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -354,6 +354,19 @@ public:
|
||||||
std::vector< SharedPtr<Peer> > &_v;
|
std::vector< SharedPtr<Peer> > &_v;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update our knowledge of exterior network addresses
|
||||||
|
*
|
||||||
|
* If the remote peer in question is trusted, this will update our internal
|
||||||
|
* instance of ExternalSurface. If our surface has changed, this triggers a
|
||||||
|
* partial or total reset of ephemeral peer addresses and a renegotiation of
|
||||||
|
* new ones using supernodes / relays.
|
||||||
|
*
|
||||||
|
* @param remotePeer Remote peer address
|
||||||
|
* @param mirroredAddress Real-world network address the remote peer told us we have
|
||||||
|
*/
|
||||||
|
bool updateSurface(const SharedPtr<Peer> &remotePeer,const InetAddress &mirroredAddress);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a root topology dictionary against the identities specified in Defaults
|
* Validate a root topology dictionary against the identities specified in Defaults
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue