diff options
author | Suhas Daftuar <sdaftuar@gmail.com> | 2019-08-28 17:23:45 -0400 |
---|---|---|
committer | Suhas Daftuar <sdaftuar@gmail.com> | 2019-09-04 14:58:36 -0400 |
commit | 0ba08020c9791f7caf5986ad6490c16a2b66cd83 (patch) | |
tree | ec7abf1dd0f430fc2cfa653dd520f86b85024b58 /src/net_processing.cpp | |
parent | 937eba91e1550bc3038dc541c236ac83e0a0e6d5 (diff) |
Disconnect peers violating blocks-only mode
If we set fRelay=false in our VERSION message, and a peer sends an INV or TX
message anyway, disconnect. Since we use fRelay=false to minimize bandwidth,
we should not tolerate remaining connected to a peer violating the protocol.
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r-- | src/net_processing.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index baf3bc7448..4418174f95 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2266,7 +2266,9 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr { pfrom->AddInventoryKnown(inv); if (fBlocksOnly) { - LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->GetId()); + LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.hash.ToString(), pfrom->GetId()); + pfrom->fDisconnect = true; + return true; } else if (!fAlreadyHave && !fImporting && !fReindex && !::ChainstateActive().IsInitialBlockDownload()) { RequestTx(State(pfrom->GetId()), inv.hash, current_time); } @@ -2483,9 +2485,11 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr if (strCommand == NetMsgType::TX) { // Stop processing the transaction early if // We are in blocks only mode and peer is either not whitelisted or whitelistrelay is off - if (!g_relay_txes && !pfrom->HasPermission(PF_RELAY)) + // or if this peer is supposed to be a block-relay-only peer + if ((!g_relay_txes && !pfrom->HasPermission(PF_RELAY)) || (pfrom->m_tx_relay == nullptr)) { LogPrint(BCLog::NET, "transaction sent in violation of protocol peer=%d\n", pfrom->GetId()); + pfrom->fDisconnect = true; return true; } |