QDebug operator<<(QDebug debug, const PacketType& type) { debug.nospace() << (uint8_t) type << " (" << qPrintable(nameForPacketType(type)) << ")"; return debug.space(); }
bool LimitedNodeList::packetSourceAndHashMatch(const NLPacket& packet, SharedNodePointer& matchingNode) { if (NON_SOURCED_PACKETS.contains(packet.getType())) { return true; } else { // figure out which node this is from matchingNode = nodeWithUUID(packet.getSourceID()); if (matchingNode) { if (!NON_VERIFIED_PACKETS.contains(packet.getType())) { // check if the md5 hash in the header matches the hash we would expect if (packet.getVerificationHash() != packet.payloadHashWithConnectionUUID(matchingNode->getConnectionSecret())) { static QMultiMap<QUuid, PacketType::Value> hashDebugSuppressMap; const QUuid& senderID = packet.getSourceID(); if (!hashDebugSuppressMap.contains(senderID, packet.getType())) { qCDebug(networking) << "Packet hash mismatch on" << packet.getType() << "- Sender" << senderID; hashDebugSuppressMap.insert(senderID, packet.getType()); } return false; } } return true; } else { static QString repeatedMessage = LogHandler::getInstance().addRepeatedMessageRegex("Packet of type \\d+ \\([\\sa-zA-Z]+\\) received from unknown node with UUID"); qCDebug(networking) << "Packet of type" << packet.getType() << "(" << qPrintable(nameForPacketType(packet.getType())) << ")" << "received from unknown node with UUID" << qPrintable(uuidStringWithoutCurlyBraces(packet.getSourceID())); } } return false; }