aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorR E Broadley <rebroad+github@gmail.com>2015-06-26 22:38:07 +0300
committerMarcoFalke <falke.marco@gmail.com>2016-04-27 22:34:48 +0200
commitd3ead9bcb6d9c8dd59c299db914006d26382816d (patch)
tree05e3183b90a24fbbb027673d4139cf4d12482207 /src
parenta5bc6a1bc4696ddda26a75f5ee1d6dc6817ca675 (diff)
downloadbitcoin-d3ead9bcb6d9c8dd59c299db914006d26382816d.tar.xz
Avoid "Unknown command" messages when receiving getaddr on outbound connections.
Github-Pull: #7642 Rebased-From: d84ea1a59ce3704457a162f1fd8a7353047156de
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 24d292454b..8a9dae03ab 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5247,13 +5247,18 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
}
- // This asymmetric behavior for inbound and outbound connections was introduced
- // to prevent a fingerprinting attack: an attacker can send specific fake addresses
- // to users' AddrMan and later request them by sending getaddr messages.
- // Making nodes which are behind NAT and can only make outgoing connections ignore
- // the getaddr message mitigates the attack.
- else if ((strCommand == NetMsgType::GETADDR) && (pfrom->fInbound))
+ else if (strCommand == NetMsgType::GETADDR)
{
+ // This asymmetric behavior for inbound and outbound connections was introduced
+ // to prevent a fingerprinting attack: an attacker can send specific fake addresses
+ // to users' AddrMan and later request them by sending getaddr messages.
+ // Making nodes which are behind NAT and can only make outgoing connections ignore
+ // the getaddr message mitigates the attack.
+ if (!pfrom->fInbound) {
+ LogPrint("net", "Ignoring \"getaddr\" from outbound connection. peer=%d\n", pfrom->id);
+ return true;
+ }
+
pfrom->vAddrToSend.clear();
vector<CAddress> vAddr = addrman.GetAddr();
BOOST_FOREACH(const CAddress &addr, vAddr)