| 874 | } |
| 875 | |
| 876 | void CClientList::RequestBuddy(Kademlia::CContact* contact, uint8_t connectOptions) |
| 877 | { |
| 878 | uint32_t nContactIP = wxUINT32_SWAP_ALWAYS(contact->GetIPAddress()); |
| 879 | // Don't connect to ourself |
| 880 | if (theApp->GetPublicIP() == nContactIP && thePrefs::GetPort() == contact->GetTCPPort()) { |
| 881 | return; |
| 882 | } |
| 883 | |
| 884 | CUpDownClient* pNewClient = FindClientByIP(nContactIP, contact->GetTCPPort()); |
| 885 | if (!pNewClient) { |
| 886 | pNewClient = new CUpDownClient(contact->GetTCPPort(), contact->GetIPAddress(), 0, 0, NULL, false, true ); |
| 887 | } else if (pNewClient->GetKadState() != KS_NONE) { |
| 888 | return; // already busy with this client in some way (probably fw stuff), don't mess with it |
| 889 | } else if (IsKadFirewallCheckIP(nContactIP)) { // doing a kad firewall check with this IP, abort |
| 890 | AddDebugLogLineN(logKadMain, "Kad TCP firewallcheck / Buddy request collision for IP " + Uint32toStringIP(nContactIP)); |
| 891 | return; |
| 892 | } |
| 893 | |
| 894 | //Add client to the lists to be processed. |
| 895 | pNewClient->SetKadPort(contact->GetUDPPort()); |
| 896 | pNewClient->SetKadState(KS_QUEUED_BUDDY); |
| 897 | uint8_t ID[16]; |
| 898 | contact->GetClientID().ToByteArray(ID); |
| 899 | pNewClient->SetUserHash(CMD4Hash(ID)); |
| 900 | pNewClient->SetConnectOptions(connectOptions, true, false); |
| 901 | AddToKadList(pNewClient); |
| 902 | //This method checks if this is a dup already. |
| 903 | AddClient(pNewClient); |
| 904 | } |
| 905 | |
| 906 | bool CClientList::IncomingBuddy(Kademlia::CContact* contact, Kademlia::CUInt128* buddyID) |
| 907 | { |
no test coverage detected