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

Method ProcessFirewallCheckUDPRequest

src/BaseClient.cpp:2923–2963  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2921}
2922
2923void CUpDownClient::ProcessFirewallCheckUDPRequest(CMemFile* data)
2924{
2925 if (!Kademlia::CKademlia::IsRunning() || Kademlia::CKademlia::GetUDPListener() == NULL) {
2926 //DebugLogWarning(_T("Ignored Kad Firewallrequest UDP because Kad is not running (%s)"), GetClientFullInfo());
2927 return;
2928 }
2929
2930 // first search if we know this IP already, if so the result might be biased and we need tell the requester
2931 bool errorAlreadyKnown = false;
2932 if (GetUploadState() != US_NONE || GetDownloadState() != DS_NONE || GetChatState() != MS_NONE) {
2933 errorAlreadyKnown = true;
2934 } else if (Kademlia::CKademlia::GetRoutingZone()->GetContact(wxUINT32_SWAP_ALWAYS(GetConnectIP()), 0, false) != NULL) {
2935 errorAlreadyKnown = true;
2936 }
2937
2938 uint16_t remoteInternPort = data->ReadUInt16();
2939 uint16_t remoteExternPort = data->ReadUInt16();
2940 uint32_t senderKey = data->ReadUInt32();
2941 if (remoteInternPort == 0) {
2942 //DebugLogError(_T("UDP Firewallcheck requested with Intern Port == 0 (%s)"), GetClientFullInfo());
2943 return;
2944 }
2945// if (senderKey == 0)
2946// DebugLogWarning(_T("UDP Firewallcheck requested with SenderKey == 0 (%s)"), GetClientFullInfo());
2947
2948 CMemFile testPacket1;
2949 testPacket1.WriteUInt8(errorAlreadyKnown ? 1 : 0);
2950 testPacket1.WriteUInt16(remoteInternPort);
2951 DebugSend(Kad2FirewallUDP, wxUINT32_SWAP_ALWAYS(GetConnectIP()), remoteInternPort);
2952 Kademlia::CKademlia::GetUDPListener()->SendPacket(testPacket1, KADEMLIA2_FIREWALLUDP, wxUINT32_SWAP_ALWAYS(GetConnectIP()), remoteInternPort, Kademlia::CKadUDPKey(senderKey, theApp->GetPublicIP(false)), NULL);
2953
2954 // if the client has a router with PAT (and therefore a different extern port than intern), test this port too
2955 if (remoteExternPort != 0 && remoteExternPort != remoteInternPort) {
2956 CMemFile testPacket2;
2957 testPacket2.WriteUInt8(errorAlreadyKnown ? 1 : 0);
2958 testPacket2.WriteUInt16(remoteExternPort);
2959 DebugSend(Kad2FirewalledUDP, wxUINT32_SWAP_ALWAYS(GetConnectIP()), remoteExternPort);
2960 Kademlia::CKademlia::GetUDPListener()->SendPacket(testPacket2, KADEMLIA2_FIREWALLUDP, wxUINT32_SWAP_ALWAYS(GetConnectIP()), remoteExternPort, Kademlia::CKadUDPKey(senderKey, theApp->GetPublicIP(false)), NULL);
2961 }
2962 //DebugLog(_T("Answered UDP Firewallcheck request (%s)"), GetClientFullInfo());
2963}
2964
2965void CUpDownClient::SetConnectOptions(uint8_t options, bool encryption, bool callback)
2966{

Callers 1

ProcessExtPacketMethod · 0.80

Calls 8

ReadUInt16Method · 0.80
ReadUInt32Method · 0.80
WriteUInt8Method · 0.80
WriteUInt16Method · 0.80
CKadUDPKeyClass · 0.50
GetContactMethod · 0.45
SendPacketMethod · 0.45
GetPublicIPMethod · 0.45

Tested by

no test coverage detected