Skip to content

Commit c8d2473

Browse files
committed
Merge bitcoin#7642: Avoid "Unknown command" messages when receiving getaddr on outbound c…
9988554 No "Unknown command" for getaddr command. (R E Broadley)
2 parents 386f438 + 9988554 commit c8d2473

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/main.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5064,13 +5064,18 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
50645064
}
50655065

50665066

5067-
// This asymmetric behavior for inbound and outbound connections was introduced
5068-
// to prevent a fingerprinting attack: an attacker can send specific fake addresses
5069-
// to users' AddrMan and later request them by sending getaddr messages.
5070-
// Making nodes which are behind NAT and can only make outgoing connections ignore
5071-
// the getaddr message mitigates the attack.
5072-
else if ((strCommand == NetMsgType::GETADDR) && (pfrom->fInbound))
5067+
else if (strCommand == NetMsgType::GETADDR)
50735068
{
5069+
// This asymmetric behavior for inbound and outbound connections was introduced
5070+
// to prevent a fingerprinting attack: an attacker can send specific fake addresses
5071+
// to users' AddrMan and later request them by sending getaddr messages.
5072+
// Making nodes which are behind NAT and can only make outgoing connections ignore
5073+
// the getaddr message mitigates the attack.
5074+
if (!pfrom->fInbound) {
5075+
LogPrint("net", "Ignoring \"getaddr\" from outbound connection. peer=%d\n", pfrom->id);
5076+
return true;
5077+
}
5078+
50745079
pfrom->vAddrToSend.clear();
50755080
vector<CAddress> vAddr = addrman.GetAddr();
50765081
BOOST_FOREACH(const CAddress &addr, vAddr)

0 commit comments

Comments
 (0)