diff --git a/node/ExternalSurface.hpp b/node/ExternalSurface.hpp index 2f4bd38de..44c30b979 100644 --- a/node/ExternalSurface.hpp +++ b/node/ExternalSurface.hpp @@ -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); diff --git a/node/Topology.cpp b/node/Topology.cpp index 3f4043da9..dd0410071 100644 --- a/node/Topology.cpp +++ b/node/Topology.cpp @@ -258,6 +258,24 @@ void Topology::clean(uint64_t now) } } +bool Topology::updateSurface(const SharedPtr &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 >::const_iterator ap(_activePeers.begin());ap!=_activePeers.end();++ap) + ap->second->clearPaths(false); + + return true; + } + + return false; +} + bool Topology::authenticateRootTopology(const Dictionary &rt) { try { diff --git a/node/Topology.hpp b/node/Topology.hpp index 1dd556461..c68bf5076 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -354,6 +354,19 @@ public: std::vector< SharedPtr > &_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 &remotePeer,const InetAddress &mirroredAddress); + /** * Validate a root topology dictionary against the identities specified in Defaults *