From 24f8c248f5ed986fc8410a95e5169d572cd22a09 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 15 Apr 2016 09:02:41 +0200 Subject: [PATCH] Merge #7856: Only send one GetAddr response per connection. 66b0724 Only send one GetAddr response per connection. (Gregory Maxwell) --- src/net.cpp | 1 + src/net.h | 1 + src/net_processing.cpp | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/src/net.cpp b/src/net.cpp index 4c0387eb2..7cb4a1a62 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2708,6 +2708,7 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn nNextAddrSend = 0; nNextInvSend = 0; fRelayTxes = false; + fSentAddr = false; pfilter = new CBloomFilter(); nLastBlockTime = 0; nLastTXTime = 0; diff --git a/src/net.h b/src/net.h index cd1a1e383..93795408c 100644 --- a/src/net.h +++ b/src/net.h @@ -709,6 +709,7 @@ public: // b) the peer may tell us in its version message that we should not relay tx invs // unless it loads a bloom filter. bool fRelayTxes; + bool fSentAddr; // If 'true' this node will be disconnected on CMasternodeMan::ProcessMasternodeConnections() bool fMasternode; CSemaphoreGrant grantOutbound; diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 22a9022d6..ad639edc3 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1938,6 +1938,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, return true; } + // Only send one GetAddr response per connection to reduce resource waste + // and discourage addr stamping of INV announcements. + if (pfrom->fSentAddr) { + LogPrint("net", "Ignoring repeated \"getaddr\". peer=%d\n", pfrom->id); + return true; + } + pfrom->fSentAddr = true; + pfrom->vAddrToSend.clear(); vector vAddr = connman.GetAddresses(); BOOST_FOREACH(const CAddress &addr, vAddr)