Surface logic in Topology.

This commit is contained in:
Adam Ierymenko 2015-02-02 16:23:26 -08:00
parent 61cff47f5b
commit 37d23336ed
3 changed files with 32 additions and 1 deletions

View File

@ -46,7 +46,7 @@ public:
* @param remote Remote address as reflected by any trusted peer
* @return True if our external surface has changed
*/
inline bool revise(const InetAddress &remote)
inline bool update(const InetAddress &remote)
throw()
{
const unsigned long idx = (remote.isV4() ? 0 : 2) | (remote.isLinkLocal() ? 1 : 0);

View File

@ -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)
{
try {

View File

@ -354,6 +354,19 @@ public:
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
*