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

Method IncomingBuddy

src/ClientList.cpp:906–934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

904}
905
906bool 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
936void CClientList::RemoveFromKadList(CUpDownClient* torem)
937{

Callers 1

Calls 12

Uint32toStringIPFunction · 0.85
GetTCPPortMethod · 0.80
SetKadPortMethod · 0.80
SetKadStateMethod · 0.80
ToByteArrayMethod · 0.80
SetBuddyIDMethod · 0.80
CMD4HashClass · 0.70
GetIPAddressMethod · 0.45
GetPublicIPMethod · 0.45
GetUDPPortMethod · 0.45
GetClientIDMethod · 0.45
SetUserHashMethod · 0.45

Tested by

no test coverage detected