summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-06-21 14:58:30 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-06-21 14:58:30 -0700
commit674b84d908dd74fc639fc9279fb5d5fc7981c4fc (patch)
treeeb8ca3d045730e3c90bf92c9daab21358fa75515 /node
parente2ca239be05ac4787091eb298ce0ed1012eacbd3 (diff)
downloadinfinitytier-674b84d908dd74fc639fc9279fb5d5fc7981c4fc.tar.gz
infinitytier-674b84d908dd74fc639fc9279fb5d5fc7981c4fc.zip
Plumbing for network setting control, and GitHub issue #330
Diffstat (limited to 'node')
-rw-r--r--node/IncomingPacket.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp
index 532abafa..871297f7 100644
--- a/node/IncomingPacket.cpp
+++ b/node/IncomingPacket.cpp
@@ -1192,8 +1192,20 @@ bool IncomingPacket::_doCIRCUIT_TEST_REPORT(const RuntimeEnvironment *RR,const S
bool IncomingPacket::_doREQUEST_PROOF_OF_WORK(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
{
try {
- // Right now this is only allowed from root servers -- may be allowed from controllers and relays later.
- if (RR->topology->isRoot(peer->identity())) {
+ // If this were allowed from anyone, it would itself be a DOS vector. Right
+ // now we only allow it from roots and controllers of networks you have joined.
+ bool allowed = RR->topology->isRoot(peer->identity());
+ if (!allowed) {
+ std::vector< SharedPtr<Network> > allNetworks(RR->node->allNetworks());
+ for(std::vector< SharedPtr<Network> >::const_iterator n(allNetworks.begin());n!=allNetworks.end();++n) {
+ if (peer->address() == (*n)->controller()) {
+ allowed = true;
+ break;
+ }
+ }
+ }
+
+ if (allowed) {
const uint64_t pid = packetId();
const unsigned int difficulty = (*this)[ZT_PACKET_IDX_PAYLOAD + 1];
const unsigned int challengeLength = at<uint16_t>(ZT_PACKET_IDX_PAYLOAD + 2);