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

Method Compare

src/DownloadClient.cpp:58–135  ·  view source on GitHub ↗

This function is left as a reminder. Changes here _must_ be reflected in CClientList::FindMatchingClient.

Source from the content-addressed store, hash-verified

56// This function is left as a reminder.
57// Changes here _must_ be reflected in CClientList::FindMatchingClient.
58bool CUpDownClient::Compare(const CUpDownClient* tocomp, bool bIgnoreUserhash) const
59{
60 if (!tocomp) {
61 // should we wxASSERT here?
62 return false;
63 }
64
65 //Compare only the user hash..
66 if(!bIgnoreUserhash && HasValidHash() && tocomp->HasValidHash()) {
67 return GetUserHash() == tocomp->GetUserHash();
68 }
69
70 if (HasLowID()) {
71 //User is firewalled.. Must do two checks..
72 if (GetIP()!=0 && GetIP() == tocomp->GetIP()) {
73 //The IP of both match
74 if (GetUserPort()!=0 && GetUserPort() == tocomp->GetUserPort()) {
75 //IP-UserPort matches
76 return true;
77 }
78 if (GetKadPort()!=0 && GetKadPort() == tocomp->GetKadPort()) {
79 //IP-KadPort Matches
80 return true;
81 }
82 }
83
84 if (GetUserIDHybrid()!=0
85 && GetUserIDHybrid() == tocomp->GetUserIDHybrid()
86 && GetServerIP()!=0
87 && GetServerIP() == tocomp->GetServerIP()
88 && GetServerPort()!=0
89 && GetServerPort() == tocomp->GetServerPort()) {
90 //Both have the same lowID, Same serverIP and Port..
91 return true;
92 }
93
94 //Both IP, and Server do not match..
95 return false;
96 }
97
98 //User is not firewalled.
99 if (GetUserPort()!=0) {
100 //User has a Port, lets check the rest.
101 if (GetIP() != 0 && tocomp->GetIP() != 0) {
102 //Both clients have a verified IP..
103 if(GetIP() == tocomp->GetIP() && GetUserPort() == tocomp->GetUserPort()) {
104 //IP and UserPort match..
105 return true;
106 }
107 } else {
108 //One of the two clients do not have a verified IP
109 if (GetUserIDHybrid() == tocomp->GetUserIDHybrid() && GetUserPort() == tocomp->GetUserPort()) {
110 //ID and Port Match..
111 return true;
112 }
113 }
114 }
115

Callers

nothing calls this directly

Calls 7

HasValidHashMethod · 0.80
GetIPMethod · 0.45
GetUserPortMethod · 0.45
GetKadPortMethod · 0.45
GetUserIDHybridMethod · 0.45
GetServerIPMethod · 0.45
GetServerPortMethod · 0.45

Tested by

no test coverage detected