| 4806 | } |
| 4807 | |
| 4808 | bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived) |
| 4809 | { |
| 4810 | RandAddSeedPerfmon(); |
| 4811 | LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id); |
| 4812 | if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) |
| 4813 | { |
| 4814 | LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n"); |
| 4815 | return true; |
| 4816 | } |
| 4817 | |
| 4818 | |
| 4819 | |
| 4820 | |
| 4821 | if (strCommand == "version") |
| 4822 | { |
| 4823 | // Each connection can only send one version message |
| 4824 | if (pfrom->nVersion != 0) |
| 4825 | { |
| 4826 | pfrom->PushMessage("reject", strCommand, REJECT_DUPLICATE, string("Duplicate version message")); |
| 4827 | Misbehaving(pfrom->GetId(), 1); |
| 4828 | return false; |
| 4829 | } |
| 4830 | |
| 4831 | int64_t nTime; |
| 4832 | CAddress addrMe; |
| 4833 | CAddress addrFrom; |
| 4834 | uint64_t nNonce = 1; |
| 4835 | vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; |
| 4836 | if (pfrom->nVersion < MIN_PEER_PROTO_VERSION) |
| 4837 | { |
| 4838 | // disconnect from peers older than this proto version |
| 4839 | LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion); |
| 4840 | pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE, |
| 4841 | strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)); |
| 4842 | pfrom->fDisconnect = true; |
| 4843 | return false; |
| 4844 | } |
| 4845 | |
| 4846 | if (pfrom->nVersion == 10300) |
| 4847 | pfrom->nVersion = 300; |
| 4848 | if (!vRecv.empty()) |
| 4849 | vRecv >> addrFrom >> nNonce; |
| 4850 | if (!vRecv.empty()) { |
| 4851 | vRecv >> LIMITED_STRING(pfrom->strSubVer, MAX_SUBVERSION_LENGTH); |
| 4852 | pfrom->cleanSubVer = SanitizeString(pfrom->strSubVer); |
| 4853 | } |
| 4854 | if (!vRecv.empty()) |
| 4855 | vRecv >> pfrom->nStartingHeight; |
| 4856 | if (!vRecv.empty()) |
| 4857 | vRecv >> pfrom->fRelayTxes; // set to true after we get the first filter* message |
| 4858 | else |
| 4859 | pfrom->fRelayTxes = true; |
| 4860 | |
| 4861 | // Disconnect if we connected to ourself |
| 4862 | if (nNonce == nLocalHostNonce && nNonce > 1) |
| 4863 | { |
| 4864 | LogPrintf("connected to self at %s, disconnecting\n", pfrom->addr.ToString()); |
| 4865 | pfrom->fDisconnect = true; |