| 904 | } |
| 905 | |
| 906 | bool CClientList::IncomingBuddy(Kademlia::CContact* contact, Kademlia::CUInt128* buddyID) |
| 907 | { |
| 908 | uint32_t nContactIP = wxUINT32_SWAP_ALWAYS(contact->GetIPAddress()); |
| 909 | //If aMule already knows this client, abort this.. It could cause conflicts. |
| 910 | //Although the odds of this happening is very small, it could still happen. |
| 911 | if (FindClientByIP(nContactIP, contact->GetTCPPort())) { |
| 912 | return false; |
| 913 | } else if (IsKadFirewallCheckIP(nContactIP)) { // doing a kad firewall check with this IP, abort |
| 914 | AddDebugLogLineN(logKadMain, "Kad TCP firewallcheck / Buddy request collision for IP " + Uint32toStringIP(nContactIP)); |
| 915 | return false; |
| 916 | } |
| 917 | |
| 918 | if (theApp->GetPublicIP() == nContactIP && thePrefs::GetPort() == contact->GetTCPPort()) { |
| 919 | return false; // don't connect ourself |
| 920 | } |
| 921 | |
| 922 | //Add client to the lists to be processed. |
| 923 | CUpDownClient* pNewClient = new CUpDownClient(contact->GetTCPPort(), contact->GetIPAddress(), 0, 0, NULL, false, true ); |
| 924 | pNewClient->SetKadPort(contact->GetUDPPort()); |
| 925 | pNewClient->SetKadState(KS_INCOMING_BUDDY); |
| 926 | uint8_t ID[16]; |
| 927 | contact->GetClientID().ToByteArray(ID); |
| 928 | pNewClient->SetUserHash(CMD4Hash(ID)); |
| 929 | buddyID->ToByteArray(ID); |
| 930 | pNewClient->SetBuddyID(ID); |
| 931 | AddToKadList(pNewClient); |
| 932 | AddClient(pNewClient); |
| 933 | return true; |
| 934 | } |
| 935 | |
| 936 | void CClientList::RemoveFromKadList(CUpDownClient* torem) |
| 937 | { |
no test coverage detected