| 3601 | } |
| 3602 | |
| 3603 | void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string& msg_type, DataStream& vRecv, |
| 3604 | const NodeClock::time_point time_received, |
| 3605 | const std::atomic<bool>& interruptMsgProc) |
| 3606 | { |
| 3607 | AssertLockHeld(g_msgproc_mutex); |
| 3608 | |
| 3609 | LogDebug(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(msg_type), vRecv.size(), pfrom.GetId()); |
| 3610 | |
| 3611 | |
| 3612 | if (msg_type == NetMsgType::VERSION) { |
| 3613 | if (pfrom.nVersion != 0) { |
| 3614 | LogDebug(BCLog::NET, "redundant version message from peer=%d\n", pfrom.GetId()); |
| 3615 | return; |
| 3616 | } |
| 3617 | |
| 3618 | int64_t nTime; |
| 3619 | CService addrMe; |
| 3620 | uint64_t nNonce = 1; |
| 3621 | ServiceFlags nServices; |
| 3622 | int nVersion; |
| 3623 | std::string cleanSubVer; |
| 3624 | int starting_height = -1; |
| 3625 | bool fRelay = true; |
| 3626 | |
| 3627 | vRecv >> nVersion >> Using<CustomUintFormatter<8>>(nServices) >> nTime; |
| 3628 | if (nTime < 0) { |
| 3629 | nTime = 0; |
| 3630 | } |
| 3631 | vRecv.ignore(8); // Ignore the addrMe service bits sent by the peer |
| 3632 | vRecv >> CNetAddr::V1(addrMe); |
| 3633 | if (!pfrom.IsInboundConn() && !pfrom.IsPrivateBroadcastConn()) |
| 3634 | { |
| 3635 | // Overwrites potentially existing services. In contrast to this, |
| 3636 | // unvalidated services received via gossip relay in ADDR/ADDRV2 |
| 3637 | // messages are only ever added but cannot replace existing ones. |
| 3638 | m_addrman.SetServices(pfrom.addr, nServices); |
| 3639 | } |
| 3640 | if (pfrom.ExpectServicesFromConn() && !HasAllDesirableServiceFlags(nServices)) |
| 3641 | { |
| 3642 | LogDebug(BCLog::NET, "peer does not offer the expected services (%08x offered, %08x expected), %s", |
| 3643 | nServices, |
| 3644 | GetDesirableServiceFlags(nServices), |
| 3645 | pfrom.DisconnectMsg()); |
| 3646 | pfrom.fDisconnect = true; |
| 3647 | return; |
| 3648 | } |
| 3649 | |
| 3650 | if (nVersion < MIN_PEER_PROTO_VERSION) { |
| 3651 | // disconnect from peers older than this proto version |
| 3652 | LogDebug(BCLog::NET, "peer using obsolete version %i, %s", nVersion, pfrom.DisconnectMsg()); |
| 3653 | pfrom.fDisconnect = true; |
| 3654 | return; |
| 3655 | } |
| 3656 | |
| 3657 | if (!vRecv.empty()) { |
| 3658 | // The version message includes information about the sending node which we don't use: |
| 3659 | // - 8 bytes (service bits) |
| 3660 | // - 16 bytes (ipv6 address) |
nothing calls this directly
no test coverage detected