diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2016-09-09 08:43:58 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2016-09-09 08:43:58 -0700 |
| commit | 0d4109a9f1f119e336d73039251ad17c0e2a56f4 (patch) | |
| tree | 7dbed18275342042878db41b7b7484bfb9afa5a1 /node/Switch.cpp | |
| parent | 16df2c33631eeb3e123fefa4febf20f202fd476b (diff) | |
| download | infinitytier-0d4109a9f1f119e336d73039251ad17c0e2a56f4.tar.gz infinitytier-0d4109a9f1f119e336d73039251ad17c0e2a56f4.zip | |
More refactoring to clean up code, and add a gate function to make sure we do not handle OK packets we did not expect. This hardens up a few potential edge cases around security, since such messages might be used to e.g. pollute a cache and DOS under certain conditions.
Diffstat (limited to 'node/Switch.cpp')
| -rw-r--r-- | node/Switch.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp index 21d0b3c9..f2a0d35b 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -734,13 +734,12 @@ unsigned long Switch::doTimerTasks(uint64_t now) Address Switch::_sendWhoisRequest(const Address &addr,const Address *peersAlreadyConsulted,unsigned int numPeersAlreadyConsulted) { - SharedPtr<Peer> root(RR->topology->getBestRoot(peersAlreadyConsulted,numPeersAlreadyConsulted,false)); - if (root) { - Packet outp(root->address(),RR->identity.address(),Packet::VERB_WHOIS); + SharedPtr<Peer> upstream(RR->topology->getBestRoot(peersAlreadyConsulted,numPeersAlreadyConsulted,false)); + if (upstream) { + Packet outp(upstream->address(),RR->identity.address(),Packet::VERB_WHOIS); addr.appendTo(outp); - outp.armor(root->key(),true); - if (root->sendDirect(outp.data(),outp.size(),RR->node->now(),true)) - return root->address(); + RR->node->expectReplyTo(outp.packetId()); + send(outp,true); } return Address(); } |
