| 1570 | } |
| 1571 | |
| 1572 | bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CConnman* connman, const std::atomic<bool>& interruptMsgProc, bool enable_bip61) |
| 1573 | { |
| 1574 | LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->GetId()); |
| 1575 | if (gArgs.IsArgSet("-dropmessagestest") && GetRand(gArgs.GetArg("-dropmessagestest", 0)) == 0) |
| 1576 | { |
| 1577 | LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); |
| 1578 | return true; |
| 1579 | } |
| 1580 | |
| 1581 | |
| 1582 | if (!(pfrom->GetLocalServices() & NODE_BLOOM) && |
| 1583 | (strCommand == NetMsgType::FILTERLOAD || |
| 1584 | strCommand == NetMsgType::FILTERADD)) |
| 1585 | { |
| 1586 | if (pfrom->nVersion >= NO_BLOOM_VERSION) { |
| 1587 | LOCK(cs_main); |
| 1588 | Misbehaving(pfrom->GetId(), 100); |
| 1589 | return false; |
| 1590 | } else { |
| 1591 | pfrom->fDisconnect = true; |
| 1592 | return false; |
| 1593 | } |
| 1594 | } |
| 1595 | |
| 1596 | if (strCommand == NetMsgType::REJECT) |
| 1597 | { |
| 1598 | if (LogAcceptCategory(BCLog::NET)) { |
| 1599 | try { |
| 1600 | std::string strMsg; unsigned char ccode; std::string strReason; |
| 1601 | vRecv >> LIMITED_STRING(strMsg, CMessageHeader::COMMAND_SIZE) >> ccode >> LIMITED_STRING(strReason, MAX_REJECT_MESSAGE_LENGTH); |
| 1602 | |
| 1603 | std::ostringstream ss; |
| 1604 | ss << strMsg << " code " << itostr(ccode) << ": " << strReason; |
| 1605 | |
| 1606 | if (strMsg == NetMsgType::BLOCK || strMsg == NetMsgType::TX) |
| 1607 | { |
| 1608 | uint256 hash; |
| 1609 | vRecv >> hash; |
| 1610 | ss << ": hash " << hash.ToString(); |
| 1611 | } |
| 1612 | LogPrint(BCLog::NET, "Reject %s\n", SanitizeString(ss.str())); |
| 1613 | } catch (const std::ios_base::failure&) { |
| 1614 | // Avoid feedback loops by preventing reject messages from triggering a new reject message. |
| 1615 | LogPrint(BCLog::NET, "Unparseable reject message received\n"); |
| 1616 | } |
| 1617 | } |
| 1618 | return true; |
| 1619 | } |
| 1620 | |
| 1621 | else if (strCommand == NetMsgType::VERSION) |
| 1622 | { |
| 1623 | // Each connection can only send one version message |
| 1624 | if (pfrom->nVersion != 0) |
| 1625 | { |
| 1626 | if (enable_bip61) { |
| 1627 | connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_DUPLICATE, std::string("Duplicate version message"))); |
| 1628 | } |
| 1629 | LOCK(cs_main); |
no test coverage detected