diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp index 8836df9f5..c6cf7f36e 100644 --- a/node/IncomingPacket.cpp +++ b/node/IncomingPacket.cpp @@ -449,22 +449,26 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *RR,const SharedPtr &p InetAddress externalSurfaceAddress; unsigned int ptr = ZT_PROTO_VERB_HELLO__OK__IDX_REVISION + 2; - // Get reported external surface address if present (was not on old versions) + // Get reported external surface address if present if (ptr < size()) ptr += externalSurfaceAddress.deserialize(*this,ptr); - // Handle planet or moon updates if present (older versions don't send this) + // Handle planet or moon updates if present if ((ptr + 2) <= size()) { const unsigned int worldLen = at(ptr); ptr += 2; - const unsigned int endOfWorlds = ptr + worldLen; - while (ptr < endOfWorlds) { - World w; - ptr += w.deserialize(*this,ptr); - RR->topology->addWorld(w); + if (RR->topology->isUpstream(peer->identity())) { + const unsigned int endOfWorlds = ptr + worldLen; + while (ptr < endOfWorlds) { + World w; + ptr += w.deserialize(*this,ptr); + RR->topology->addWorld(w); + } + } else { + ptr += worldLen; } } - // Handle COR if present (older versions don't send this) + // Handle certificate of representation if present if ((ptr + 2) <= size()) { if (at(ptr) > 0) { CertificateOfRepresentation cor; diff --git a/node/Peer.cpp b/node/Peer.cpp index 338bea100..d58470921 100644 --- a/node/Peer.cpp +++ b/node/Peer.cpp @@ -360,12 +360,18 @@ void Peer::sendHELLO(const InetAddress &localAddr,const InetAddress &atAddress,u const unsigned int startCryptedPortionAt = outp.size(); std::vector moons(RR->topology->moons()); - outp.append((uint16_t)moons.size()); + std::vector moonsWanted(RR->topology->moonsWanted()); + outp.append((uint16_t)(moons.size() + moonsWanted.size())); for(std::vector::const_iterator m(moons.begin());m!=moons.end();++m) { outp.append((uint8_t)m->type()); outp.append((uint64_t)m->id()); outp.append((uint64_t)m->timestamp()); } + for(std::vector::const_iterator m(moonsWanted.begin());m!=moonsWanted.end();++m) { + outp.append((uint8_t)World::TYPE_MOON); + outp.append(*m); + outp.append((uint64_t)0); + } const unsigned int corSizeAt = outp.size(); outp.addSize(2); diff --git a/node/Topology.hpp b/node/Topology.hpp index 2465de64d..35f98cccb 100644 --- a/node/Topology.hpp +++ b/node/Topology.hpp @@ -215,6 +215,20 @@ public: return _moons; } + /** + * @return Moon IDs we are waiting for from seeds + */ + inline std::vector moonsWanted() const + { + Mutex::Lock _l(_upstreams_m); + std::vector mw; + for(std::vector< std::pair >::const_iterator s(_moonSeeds.begin());s!=_moonSeeds.end();++s) { + if (std::find(mw.begin(),mw.end(),s->first) == mw.end()) + mw.push_back(s->first); + } + return mw; + } + /** * @return Current planet */