Stulle, on 14 August 2012 - 06:54 PM, said:
Nope,
see yourself: http://update.neoloa.../MuleClient.cpp










Posted 14 August 2012 - 06:36 PM
Stulle, on 14 August 2012 - 06:54 PM, said:

Posted 14 August 2012 - 07:34 PM
Quote
This post has been edited by Stulle: 14 August 2012 - 07:35 PM

Posted 14 August 2012 - 07:37 PM
Posted 14 August 2012 - 07:39 PM
This post has been edited by Stulle: 14 August 2012 - 07:45 PM

Posted 14 August 2012 - 07:44 PM
Posted 14 August 2012 - 07:46 PM

Posted 14 August 2012 - 07:51 PM
This post has been edited by Tuxman: 14 August 2012 - 07:52 PM
Posted 14 August 2012 - 07:55 PM
Quote

Posted 14 August 2012 - 07:58 PM
This post has been edited by Stulle: 14 August 2012 - 07:59 PM

Posted 14 August 2012 - 08:07 PM
Stulle, on 14 August 2012 - 08:58 PM, said:
void CMuleClient::ReadHelloInfo(const CBuffer& Packet)
{
QVariantMap Tags = CMuleTags::ReadTags(&Packet, true);
foreach(const QString& Name, Tags.keys())
{
const QVariant& Value = Tags.value(Name);
// Note: Mule does here always a type test of the tags,
// as variants dont fail on any conversions we dont need to do that
// if an invlid conversion is performed the value remains 0 or empty.
switch(FROM_NUM(Name))
{
case CT_NAME: m_NickName = Value.toString(); break;
case CT_VERSION: m_Ed2kVersion = Value.toUInt(); break;
case CT_EMULE_VERSION: m_MuleProtocol = true; // even if version is 0 enable the protocol mule support
m_MuleVersion.Bits = Value.toUInt(); break;
case CT_EMULE_MISCOPTIONS1: m_MiscOptions1.Bits = Value.toUInt(); break;
case CT_EMULE_MISCOPTIONS2: m_MiscOptions2.Bits = Value.toUInt();
m_Mule.SetConOpts(m_MiscOptions2); break;
case CT_NEOMULE_MISCOPTIONS:m_MiscOptionsN.Bits = Value.toUInt(); break;
case CT_EMULE_UDPPORTS: m_Mule.UDPPort = (uint16)(Value.toUInt() >> 0);
m_Mule.KadPort = (uint16)(Value.toUInt() >> 16); break;
case CT_EMULE_BUDDYIP: m_Mule.BuddyAddress = QHostAddress(ntohl(Value.toUInt())); break;
case CT_EMULE_BUDDYUDP: m_Mule.BuddyPort = Value.toUInt(); break;
case CT_EMULE_BUDDYID:
{
CMuleHash BuddyID = Value.value<CMuleHash>();
m_Mule.BuddyID = QByteArray((char*)BuddyID.GetData(), BuddyID.GetSize());
break;
}
default:
LogLine(LOG_DEBUG, tr("Recived unknwon Ed2kMule hello tag"));
}
}
// we don't supprot servers skip the data
/*Mule.ServerAddress = ntohl(*/ Packet.ReadValue<uint32>();
/*Mule.ServerPort =*/ Packet.ReadValue<uint16>();
// atempt to bootstrap from clients we encounter
if(m_Mule.KadPort && KadVersion() > 1 && theCore->m_MuleManager->GetKad()->IsEnabled())
theCore->m_MuleManager->GetKad()->AddNode(m_Mule.Address, m_Mule.KadPort);
if(theCore->m_MuleManager->GrantIPRequest())
SendPublicIPRequest();
// Notify the source object(s) that we are connected
emit HelloRecived();
}
bool CUpDownClient::ProcessHelloTypePacket(CSafeMemFile* data)
{
bool bDbgInfo = thePrefs.GetUseDebugDevice();
m_strHelloInfo.Empty();
// clear hello properties which can be changed _only_ on receiving OP_Hello/OP_HelloAnswer
m_bIsHybrid = false;
m_bIsML = false;
m_fNoViewSharedFiles = 0;
m_bUnicodeSupport = false;
data->ReadHash16(m_achUserHash);
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("Hash=%s (%s)"), md4str(m_achUserHash), DbgGetHashTypeString(m_achUserHash));
m_nUserIDHybrid = data->ReadUInt32();
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T(" UserID=%u (%s)"), m_nUserIDHybrid, ipstr(m_nUserIDHybrid));
uint16 nUserPort = data->ReadUInt16(); // hmm clientport is sent twice - why?
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T(" Port=%u"), nUserPort);
DWORD dwEmuleTags = 0;
bool bPrTag = false;
uint32 tagcount = data->ReadUInt32();
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T(" Tags=%u"), tagcount);
for (uint32 i = 0; i < tagcount; i++)
{
CTag temptag(data, true);
switch (temptag.GetNameID())
{
case CT_NAME:
if (temptag.IsStr()) {
free(m_pszUsername);
m_pszUsername = _tcsdup(temptag.GetStr());
if (bDbgInfo) {
if (m_pszUsername) {//filter username for bad chars
TCHAR* psz = m_pszUsername;
while (*psz != _T('\0')) {
if (*psz == _T('\n') || *psz == _T('\r'))
*psz = _T(' ');
psz++;
}
}
m_strHelloInfo.AppendFormat(_T("\n Name='%s'"), m_pszUsername);
}
}
else if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ***UnkType=%s"), temptag.GetFullInfo());
break;
case CT_VERSION:
if (temptag.IsInt()) {
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n Version=%u"), temptag.GetInt());
m_nClientVersion = temptag.GetInt();
}
else if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ***UnkType=%s"), temptag.GetFullInfo());
break;
case CT_PORT:
if (temptag.IsInt()) {
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n Port=%u"), temptag.GetInt());
nUserPort = (uint16)temptag.GetInt();
}
else if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ***UnkType=%s"), temptag.GetFullInfo());
break;
case CT_MOD_VERSION:
if (temptag.IsStr())
m_strModVersion = temptag.GetStr();
else if (temptag.IsInt())
m_strModVersion.Format(_T("ModID=%u"), temptag.GetInt());
else
m_strModVersion = _T("ModID=<Unknown>");
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ModID=%s"), m_strModVersion);
CheckForGPLEvilDoer();
break;
case CT_EMULE_UDPPORTS:
// 16 KAD Port
// 16 UDP Port
if (temptag.IsInt()) {
m_nKadPort = (uint16)(temptag.GetInt() >> 16);
m_nUDPPort = (uint16)temptag.GetInt();
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n KadPort=%u UDPPort=%u"), m_nKadPort, m_nUDPPort);
dwEmuleTags |= 1;
}
else if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ***UnkType=%s"), temptag.GetFullInfo());
break;
case CT_EMULE_BUDDYUDP:
// 16 --Reserved for future use--
// 16 BUDDY Port
if (temptag.IsInt()) {
m_nBuddyPort = (uint16)temptag.GetInt();
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n BuddyPort=%u"), m_nBuddyPort);
}
else if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ***UnkType=%s"), temptag.GetFullInfo());
break;
case CT_EMULE_BUDDYIP:
// 32 BUDDY IP
if (temptag.IsInt()) {
m_nBuddyIP = temptag.GetInt();
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n BuddyIP=%s"), ipstr(m_nBuddyIP));
}
else if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ***UnkType=%s"), temptag.GetFullInfo());
break;
case CT_EMULE_MISCOPTIONS1:
// 3 AICH Version (0 = not supported)
// 1 Unicode
// 4 UDP version
// 4 Data compression version
// 4 Secure Ident
// 4 Source Exchange - deprecated
// 4 Ext. Requests
// 4 Comments
// 1 PeerChache supported
// 1 No 'View Shared Files' supported
// 1 MultiPacket - deprecated with FileIdentifiers/MultipacketExt2
// 1 Preview
if (temptag.IsInt()) {
m_fSupportsAICH = (temptag.GetInt() >> 29) & 0x07;
m_bUnicodeSupport = (temptag.GetInt() >> 28) & 0x01;
m_byUDPVer = (uint8)((temptag.GetInt() >> 24) & 0x0f);
m_byDataCompVer = (uint8)((temptag.GetInt() >> 20) & 0x0f);
m_bySupportSecIdent = (uint8)((temptag.GetInt() >> 16) & 0x0f);
m_bySourceExchange1Ver = (uint8)((temptag.GetInt() >> 12) & 0x0f);
m_byExtendedRequestsVer = (uint8)((temptag.GetInt() >> 8) & 0x0f);
m_byAcceptCommentVer = (uint8)((temptag.GetInt() >> 4) & 0x0f);
m_fPeerCache = (temptag.GetInt() >> 3) & 0x01;
m_fNoViewSharedFiles = (temptag.GetInt() >> 2) & 0x01;
m_bMultiPacket = (temptag.GetInt() >> 1) & 0x01;
m_fSupportsPreview = (temptag.GetInt() >> 0) & 0x01;
dwEmuleTags |= 2;
if (bDbgInfo) {
m_strHelloInfo.AppendFormat(_T("\n PeerCache=%u UDPVer=%u DataComp=%u SecIdent=%u SrcExchg=%u")
_T(" ExtReq=%u Commnt=%u Preview=%u NoViewFiles=%u Unicode=%u"),
m_fPeerCache, m_byUDPVer, m_byDataCompVer, m_bySupportSecIdent, m_bySourceExchange1Ver,
m_byExtendedRequestsVer, m_byAcceptCommentVer, m_fSupportsPreview, m_fNoViewSharedFiles, m_bUnicodeSupport);
}
}
else if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ***UnkType=%s"), temptag.GetFullInfo());
break;
case CT_EMULE_MISCOPTIONS2:
// 18 Reserved
// 1 Supports new FileIdentifiers/MultipacketExt2
// 1 Direct UDP Callback supported and available
// 1 Supports ChatCaptchas
// 1 Supports SourceExachnge2 Packets, ignores SX1 Packet Version
// 1 Requires CryptLayer
// 1 Requests CryptLayer
// 1 Supports CryptLayer
// 1 Reserved (ModBit)
// 1 Ext Multipacket (Hash+Size instead of Hash) - deprecated with FileIdentifiers/MultipacketExt2
// 1 Large Files (includes support for 64bit tags)
// 4 Kad Version - will go up to version 15 only (may need to add another field at some point in the future)
if (temptag.IsInt()) {
m_fSupportsFileIdent = (temptag.GetInt() >> 13) & 0x01;
m_fDirectUDPCallback = (temptag.GetInt() >> 12) & 0x01;
m_fSupportsCaptcha = (temptag.GetInt() >> 11) & 0x01;
m_fSupportsSourceEx2 = (temptag.GetInt() >> 10) & 0x01;
m_fRequiresCryptLayer = (temptag.GetInt() >> 9) & 0x01;
m_fRequestsCryptLayer = (temptag.GetInt() >> 8) & 0x01;
m_fSupportsCryptLayer = (temptag.GetInt() >> 7) & 0x01;
// reserved 1
m_fExtMultiPacket = (temptag.GetInt() >> 5) & 0x01;
m_fSupportsLargeFiles = (temptag.GetInt() >> 4) & 0x01;
m_byKadVersion = (uint8)((temptag.GetInt() >> 0) & 0x0f);
dwEmuleTags |= 8;
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n KadVersion=%u, LargeFiles=%u ExtMultiPacket=%u CryptLayerSupport=%u CryptLayerRequest=%u CryptLayerRequires=%u SupportsSourceEx2=%u SupportsCaptcha=%u DirectUDPCallback=%u"), m_byKadVersion, m_fSupportsLargeFiles, m_fExtMultiPacket, m_fSupportsCryptLayer, m_fRequestsCryptLayer, m_fRequiresCryptLayer, m_fSupportsSourceEx2, m_fSupportsCaptcha, m_fDirectUDPCallback);
m_fRequestsCryptLayer &= m_fSupportsCryptLayer;
m_fRequiresCryptLayer &= m_fRequestsCryptLayer;
}
else if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ***UnkType=%s"), temptag.GetFullInfo());
break;
case CT_EMULE_VERSION:
// 8 Compatible Client ID
// 7 Mjr Version (Doesn't really matter..)
// 7 Min Version (Only need 0-99)
// 3 Upd Version (Only need 0-5)
// 7 Bld Version (Only need 0-99) -- currently not used
if (temptag.IsInt()) {
m_byCompatibleClient = (uint8)((temptag.GetInt() >> 24));
m_nClientVersion = temptag.GetInt() & 0x00ffffff;
m_byEmuleVersion = 0x99;
m_fSharedDirectories = 1;
dwEmuleTags |= 4;
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ClientVer=%u.%u.%u.%u Comptbl=%u"), (m_nClientVersion >> 17) & 0x7f, (m_nClientVersion >> 10) & 0x7f, (m_nClientVersion >> 7) & 0x07, m_nClientVersion & 0x7f, m_byCompatibleClient);
}
else if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ***UnkType=%s"), temptag.GetFullInfo());
break;
default:
// Since eDonkeyHybrid 1.3 is no longer sending the additional Int32 at the end of the Hello packet,
// we use the "pr=1" tag to determine them.
if (temptag.GetName() && temptag.GetName()[0]=='p' && temptag.GetName()[1]=='r') {
bPrTag = true;
}
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ***UnkTag=%s"), temptag.GetFullInfo());
}
}
m_nUserPort = nUserPort;
m_dwServerIP = data->ReadUInt32();
m_nServerPort = data->ReadUInt16();
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n Server=%s:%u"), ipstr(m_dwServerIP), m_nServerPort);
// Check for additional data in Hello packet to determine client's software version.
//
// *) eDonkeyHybrid 0.40 - 1.2 sends an additional Int32. (Since 1.3 they don't send it any longer.)
// *) MLdonkey sends an additional Int32
//
if (data->GetLength() - data->GetPosition() == sizeof(uint32)){
uint32 test = data->ReadUInt32();
if (test == 'KDLM'){
m_bIsML = true;
if (bDbgInfo)
m_strHelloInfo += _T("\n ***AddData: \"MLDK\"");
}
else{
m_bIsHybrid = true;
if (bDbgInfo)
m_strHelloInfo.AppendFormat(_T("\n ***AddData: uint32=%u (0x%08x)"), test, test);
}
}
else if (bDbgInfo && data->GetPosition() < data->GetLength()){
UINT uAddHelloDataSize = (UINT)(data->GetLength() - data->GetPosition());
if (uAddHelloDataSize == sizeof(uint32)){
DWORD dwAddHelloInt32 = data->ReadUInt32();
m_strHelloInfo.AppendFormat(_T("\n ***AddData: uint32=%u (0x%08x)"), dwAddHelloInt32, dwAddHelloInt32);
}
else if (uAddHelloDataSize == sizeof(uint32)+sizeof(uint16)){
DWORD dwAddHelloInt32 = data->ReadUInt32();
WORD w = data->ReadUInt16();
m_strHelloInfo.AppendFormat(_T("\n ***AddData: uint32=%u (0x%08x), uint16=%u (0x%04x)"), dwAddHelloInt32, dwAddHelloInt32, w, w);
}
else
m_strHelloInfo.AppendFormat(_T("\n ***AddData: %u bytes"), uAddHelloDataSize);
}
SOCKADDR_IN sockAddr = {0};
int nSockAddrLen = sizeof(sockAddr);
socket->GetPeerName((SOCKADDR*)&sockAddr, &nSockAddrLen);
SetIP(sockAddr.sin_addr.S_un.S_addr);
if (thePrefs.GetAddServersFromClients() && m_dwServerIP && m_nServerPort){
CServer* addsrv = new CServer(m_nServerPort, ipstr(m_dwServerIP));
addsrv->SetListName(addsrv->GetAddress());
addsrv->SetPreference(SRV_PR_LOW);
if (!theApp.emuledlg->serverwnd->serverlistctrl.AddServer(addsrv, true))
delete addsrv;
}
//(a)If this is a highID user, store the ID in the Hybrid format.
//(b)Some older clients will not send a ID, these client are HighID users that are not connected to a server.
//(c)Kad users with a *.*.*.0 IPs will look like a lowID user they are actually a highID user.. They can be detected easily
//because they will send a ID that is the same as their IP..
if(!HasLowID() || m_nUserIDHybrid == 0 || m_nUserIDHybrid == m_dwUserIP )
m_nUserIDHybrid = ntohl(m_dwUserIP);
CClientCredits* pFoundCredits = theApp.clientcredits->GetCredit(m_achUserHash);
if (credits == NULL){
credits = pFoundCredits;
if (!theApp.clientlist->ComparePriorUserhash(m_dwUserIP, m_nUserPort, pFoundCredits)){
if (thePrefs.GetLogBannedClients())
AddDebugLogLine(false, _T("Clients: %s (%s), Banreason: Userhash changed (Found in TrackedClientsList)"), GetUserName(), ipstr(GetConnectIP()));
Ban();
}
}
else if (credits != pFoundCredits){
// userhash change ok, however two hours "waittime" before it can be used
credits = pFoundCredits;
if (thePrefs.GetLogBannedClients())
AddDebugLogLine(false, _T("Clients: %s (%s), Banreason: Userhash changed"), GetUserName(), ipstr(GetConnectIP()));
Ban();
}
if (GetFriend() != NULL && GetFriend()->HasUserhash() && md4cmp(GetFriend()->m_abyUserhash, m_achUserHash) != 0)
{
// this isnt our friend anymore and it will be removed/replaced, tell our friendobject about it
if (GetFriend()->IsTryingToConnect())
GetFriend()->UpdateFriendConnectionState(FCR_USERHASHFAILED); // this will remove our linked friend
else
GetFriend()->SetLinkedClient(NULL);
}
// do not replace friendobjects which have no userhash, but the fitting ip with another friend object with the
// fitting userhash (both objects would fit to this instance), as this could lead to unwanted results
if (GetFriend() == NULL || GetFriend()->HasUserhash() || GetFriend()->m_dwLastUsedIP != GetConnectIP()
|| GetFriend()->m_nLastUsedPort != GetUserPort())
{
if ((m_Friend = theApp.friendlist->SearchFriend(m_achUserHash, m_dwUserIP, m_nUserPort)) != NULL){
// Link the friend to that client
m_Friend->SetLinkedClient(this);
}
else{
// avoid that an unwanted client instance keeps a friend slot
SetFriendSlot(false);
}
}
else{
// however, copy over our userhash in this case
md4cpy(GetFriend()->m_abyUserhash, m_achUserHash);
}
// check for known major gpl breaker
CString strBuffer = m_pszUsername;
strBuffer.MakeUpper();
strBuffer.Remove(_T(' '));
if (strBuffer.Find(_T("EMULE-CLIENT")) != -1 || strBuffer.Find(_T("POWERMULE")) != -1 ){
m_bGPLEvildoer = true;
}
m_byInfopacketsReceived |= IP_EDONKEYPROTPACK;
// check if at least CT_EMULEVERSION was received, all other tags are optional
bool bIsMule = (dwEmuleTags & 0x04) == 0x04;
if (bIsMule){
m_bEmuleProtocol = true;
m_byInfopacketsReceived |= IP_EMULEPROTPACK;
}
else if (bPrTag){
m_bIsHybrid = true;
}
InitClientSoftwareVersion();
if (m_bIsHybrid)
m_fSharedDirectories = 1;
if (thePrefs.GetVerbose() && GetServerIP() == INADDR_NONE)
AddDebugLogLine(false, _T("Received invalid server IP %s from %s"), ipstr(GetServerIP()), DbgGetClientInfo());
return bIsMule;
}

Posted 14 August 2012 - 08:11 PM
This post has been edited by Stulle: 14 August 2012 - 08:14 PM

Posted 14 August 2012 - 08:59 PM
Stulle, on 14 August 2012 - 09:11 PM, said:

Posted 14 August 2012 - 09:03 PM
DavidXanatos, on 14 August 2012 - 08:55 PM, said:
Quote
