MCPcopy Create free account
hub / github.com/amule-project/amule / RequestBuddy

Method RequestBuddy

src/ClientList.cpp:876–904  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

874}
875
876void 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
906bool CClientList::IncomingBuddy(Kademlia::CContact* contact, Kademlia::CUInt128* buddyID)
907{

Callers 1

Calls 13

Uint32toStringIPFunction · 0.85
GetTCPPortMethod · 0.80
SetKadPortMethod · 0.80
SetKadStateMethod · 0.80
ToByteArrayMethod · 0.80
SetConnectOptionsMethod · 0.80
CMD4HashClass · 0.70
GetIPAddressMethod · 0.45
GetPublicIPMethod · 0.45
GetKadStateMethod · 0.45
GetUDPPortMethod · 0.45
GetClientIDMethod · 0.45

Tested by

no test coverage detected