I did changed into the following codes
void CSearch::ProcessResultKeyword(const CUInt128 &uAnswer, TagList *plistInfo, uint32 uFromIP, uint16 uFromPort) { // Find the contact who sent the answer - we need to know its protocol version // Special publish answer tags need to be filtered based on its remote protocol version, because if an old node is not aware // of those special tags, it doesn't knows it is not supposed accept and store such tags on publish request, so a malicious // publisher could fake them and our remote node would relay them on answers uint8 uFromKadVersion = 0; CContact* pFromContact = NULL; for (ContactMap::const_iterator itContactMap = m_mapTried.begin(); itContactMap != m_mapTried.end(); ++itContactMap) { CContact* pTmpContact = itContactMap->second; if (pTmpContact->GetIPAddress() == uFromIP) { pFromContact = pTmpContact; if (pTmpContact->GetUDPPort() == uFromPort) break; } } //Enig123::Only process tags with sender if (pFromContact == NULL) { DebugLogWarning(_T("Unable to find answering contact in ProcessResultKeyword - %s"), (LPCTSTR)ipstr(ntohl(uFromIP))); deleteTagListEntries(plistInfo); delete plistInfo; return; } else { //if (pFromContact != NULL) uFromKadVersion = pFromContact->GetVersion(); if (pFromContact->GetUDPPort() != uFromPort) DebugLogWarning(_T("Unable to find answering contact in ProcessResultKeyword with same port - %s"), (LPCTSTR)ipstr(ntohl(uFromIP))); }
to resolve it.
Today when I tried with similar situation in CSearch::ProcessResponse, the result logs show this is a quite common situation. I am suggesting similar changes of code there too:
void CSearch::ProcessResponse(uint32 uFromIP, uint16 uFromPort, ContactList *plistResults, uint32 uNumContacts) { // Remember the contacts to be deleted when finished m_listDelete.insert(m_listDelete.end(), plistResults->begin(), plistResults->end()); m_uLastResponse = time(NULL); //Find contact that is responding. CUInt128 uFromDistance((ULONG)0); CContact* pFromContact = NULL; for (ContactMap::const_iterator itContactMap = m_mapTried.begin(); itContactMap != m_mapTried.end(); ++itContactMap) { CContact* pTmpContact = itContactMap->second; if (pTmpContact->GetIPAddress() == uFromIP) { uFromDistance = itContactMap->first; pFromContact = pTmpContact; if (pTmpContact->GetUDPPort() == uFromPort) break; } } //Enig123::Only process results with sender if (pFromContact == NULL) { DebugLogWarning(_T("Unable to find answering contact in ProcessResponse - %s"), (LPCTSTR)ipstr(ntohl(uFromIP))); delete plistResults; return; } else { // this part can be commented out after confirming the situation is commonly seen if (pFromContact->GetUDPPort() != uFromPort) DebugLogWarning(_T("Unable to find answering contact in ProcessResponse with same port - %s"), (LPCTSTR)ipstr(ntohl(uFromIP))); }
What are your thoughts on this?