Auto merge of #1589 - bitcartel:upstream_7856_one_getaddr_per_connection, r=daira
Upstream: Only send one GetAddr response per connection. bitcoin/bitcoin#8427
This commit is contained in:
commit
f808be7546
|
@ -4867,6 +4867,14 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
// the getaddr message mitigates the attack.
|
// the getaddr message mitigates the attack.
|
||||||
else if ((strCommand == "getaddr") && (pfrom->fInbound))
|
else if ((strCommand == "getaddr") && (pfrom->fInbound))
|
||||||
{
|
{
|
||||||
|
// 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();
|
pfrom->vAddrToSend.clear();
|
||||||
vector<CAddress> vAddr = addrman.GetAddr();
|
vector<CAddress> vAddr = addrman.GetAddr();
|
||||||
BOOST_FOREACH(const CAddress &addr, vAddr)
|
BOOST_FOREACH(const CAddress &addr, vAddr)
|
||||||
|
|
|
@ -2142,6 +2142,7 @@ CNode::CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn, bool fIn
|
||||||
nStartingHeight = -1;
|
nStartingHeight = -1;
|
||||||
fGetAddr = false;
|
fGetAddr = false;
|
||||||
fRelayTxes = false;
|
fRelayTxes = false;
|
||||||
|
fSentAddr = false;
|
||||||
pfilter = new CBloomFilter();
|
pfilter = new CBloomFilter();
|
||||||
nPingNonceSent = 0;
|
nPingNonceSent = 0;
|
||||||
nPingUsecStart = 0;
|
nPingUsecStart = 0;
|
||||||
|
|
|
@ -278,6 +278,7 @@ public:
|
||||||
// b) the peer may tell us in its version message that we should not relay tx invs
|
// b) the peer may tell us in its version message that we should not relay tx invs
|
||||||
// until it has initialized its bloom filter.
|
// until it has initialized its bloom filter.
|
||||||
bool fRelayTxes;
|
bool fRelayTxes;
|
||||||
|
bool fSentAddr;
|
||||||
CSemaphoreGrant grantOutbound;
|
CSemaphoreGrant grantOutbound;
|
||||||
CCriticalSection cs_filter;
|
CCriticalSection cs_filter;
|
||||||
CBloomFilter* pfilter;
|
CBloomFilter* pfilter;
|
||||||
|
|
Loading…
Reference in New Issue