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

Method IsFiltered

src/IPFilter.cpp:419–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417
418
419bool CIPFilter::IsFiltered(uint32 IPTest, bool isServer)
420{
421 if ((!thePrefs::IsFilteringClients() && !isServer) || (!thePrefs::IsFilteringServers() && isServer)) {
422 return false;
423 }
424 if (!m_ready) {
425 // Somebody connected before we even started the networks.
426 // Filter is not up yet, so block him.
427 AddDebugLogLineN(logIPFilter, CFormat("Filtered IP %s because filter isn't ready yet.") % Uint32toStringIP(IPTest));
428 if (isServer) {
429 theStats::AddFilteredServer();
430 } else {
431 theStats::AddFilteredClient();
432 }
433 return true;
434 }
435 wxMutexLocker lock(m_mutex);
436 // The IP needs to be in host order
437 uint32 ip = wxUINT32_SWAP_ALWAYS(IPTest);
438 int imin = 0;
439 int imax = m_rangeIPs.size() - 1;
440 int i;
441 bool found = false;
442 while (imin <= imax) {
443 i = (imin + imax) / 2;
444 uint32 curIP = m_rangeIPs[i];
445 if (curIP <= ip) {
446 uint32 curLength = m_rangeLengths[i];
447 if (curLength >= 0x8000) {
448 curLength = ((curLength & 0x7fff) << 12) + 0xfff;
449 }
450 if (curIP + curLength >= ip) {
451 found = true;
452 break;
453 }
454 }
455 if (curIP > ip) {
456 imax = i - 1;
457 } else {
458 imin = i + 1;
459 }
460 }
461 if (found) {
462 AddDebugLogLineN(logIPFilter, CFormat("Filtered IP %s%s") % Uint32toStringIP(IPTest)
463 % (i < (int)m_rangeNames.size() ? (" (" + wxString(char2unicode(m_rangeNames[i].c_str())) + ")")
464 : wxString("")));
465 if (isServer) {
466 theStats::AddFilteredServer();
467 } else {
468 theStats::AddFilteredClient();
469 }
470 return true;
471 }
472 return false;
473}
474
475
476void CIPFilter::Update(const wxString& strURL)

Callers 15

FilterQueuesMethod · 0.45
AddServerMethod · 0.45
FilterServersMethod · 0.45
OnHostnameResolvedMethod · 0.45
InitNetworkDataMethod · 0.45
ProcessPacketMethod · 0.45
OnReceiveMethod · 0.45
SendHelloPacketMethod · 0.45
TryToConnectMethod · 0.45
KademliaSearchFileMethod · 0.45
AddSourcesMethod · 0.45
AddClientSourcesMethod · 0.45

Calls 5

CFormatClass · 0.85
Uint32toStringIPFunction · 0.85
char2unicodeFunction · 0.85
wxStringClass · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected