Official eMule-Board: Utp Based Nat-Traversal Reference Implemetation For Emule - Official eMule-Board

Jump to content


  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

Utp Based Nat-Traversal Reference Implemetation For Emule Neo(Mule/Loader) NatTraversal v3

#41 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 18 August 2013 - 04:02 PM

Alright, now the changes appeared :confused:
I have a crash in ClientUDPSocket in WSAStringToAddressA - you should check if thePrefs.GetBindAddrA() != NULL before calling it.
This is used on several occasions, so it should be changed everywhere :angelnot:

Also, in CAsyncSocketEx::Bind, there seems to be a problem:

Quote

struct sockaddr_storage ss;
int sslen = sizeof(ss);
if(lpszSocketAddress != NULL && WSAStringToAddressA((char*)lpszSocketAddress, AF_INET6, NULL, (struct sockaddr*)&sockAddr, &iSockAddrLen) == 0)
sockAddr.sin6_addr = ((struct sockaddr_in6 *)&ss)->sin6_addr;

Shouldn't you pass in ss instead of sockAddr and sslen instead of iSockAddrLen?
0

#42 User is offline   DavidXanatos 

  • Neo Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1469
  • Joined: 23-April 04

Posted 18 August 2013 - 05:04 PM

View PosttHeWiZaRdOfDoS, on 18 August 2013 - 05:02 PM, said:

Shouldn't you pass in ss instead of sockAddr and sslen instead of iSockAddrLen?


yup you are right thx.
I have committed a fix.

Cheers
David X.
NeoLoader is a new file sharing client, supporting ed2k/eMule, Bittorent and one click hosters,
it is the first client to be able to download form multiple networks the same file.
NL provides the first fully decentralized scalable torrent and DDL keyword search,
it implements an own novel anonymous file sharing network, providing anonymity and deniability to its users,
as well as many other new features.
It is written in C++ with Qt and is available for Windows, Linux and MacOS.
0

#43 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 20 August 2013 - 03:18 PM

C&P bug in BaseClient.cpp:

Quote

CTag tagMisOptionsN(CT_NEOMULE_MISCOPTIONS, NeoMisc.Bits);
tagMisOptions2.WriteTagToFile(data);

1

#44 User is offline   DavidXanatos 

  • Neo Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1469
  • Joined: 23-April 04

Posted 20 August 2013 - 03:46 PM

View PosttHeWiZaRdOfDoS, on 20 August 2013 - 04:18 PM, said:

C&P bug in BaseClient.cpp:

Quote

CTag tagMisOptionsN(CT_NEOMULE_MISCOPTIONS, NeoMisc.Bits);
tagMisOptions2.WriteTagToFile(data);


good catch, thx.
NeoLoader is a new file sharing client, supporting ed2k/eMule, Bittorent and one click hosters,
it is the first client to be able to download form multiple networks the same file.
NL provides the first fully decentralized scalable torrent and DDL keyword search,
it implements an own novel anonymous file sharing network, providing anonymity and deniability to its users,
as well as many other new features.
It is written in C++ with Qt and is available for Windows, Linux and MacOS.
0

#45 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 16 October 2013 - 04:06 PM

Any news?
I found some bugs, e.g. the missing hash code in packets.cpp and pClient may be NULL in CPartFile::AddClientSources which may cause a crash on various codeparts.
0

#46 User is offline   DavidXanatos 

  • Neo Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1469
  • Joined: 23-April 04

Posted 16 October 2013 - 06:46 PM

I don't think i changed anything in packets.cpp ?
What updates do you need to be able to add the code to your mod?

Cheers
David X.
NeoLoader is a new file sharing client, supporting ed2k/eMule, Bittorent and one click hosters,
it is the first client to be able to download form multiple networks the same file.
NL provides the first fully decentralized scalable torrent and DDL keyword search,
it implements an own novel anonymous file sharing network, providing anonymity and deniability to its users,
as well as many other new features.
It is written in C++ with Qt and is available for Windows, Linux and MacOS.
0

#47 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 17 October 2013 - 06:42 AM

Yes you did, allowing the Hash type to be processed in CTag::WriteTagToFile.
I had to add this:

Quote

else if (IsBlob())
{
// NOTE: This will break backward compatibility with met files for eMule versions prior to 0.44a
file->WriteUInt32(m_nBlobSize);
file->Write(m_pData, m_nBlobSize);
}
//>>> WiZaRd::ExtendedXS [Xanatos]
else if(IsHash())
{
file->WriteHash16(m_pData);
}
//<<< WiZaRd::ExtendedXS [Xanatos]
//TODO: Support more tag types


In PartFile.cpp, several checks for pClient != NULL are missing or the client may crash.
That aside, I think it's usable :flowers:
0

#48 User is offline   DavidXanatos 

  • Neo Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1469
  • Joined: 23-April 04

Posted 17 October 2013 - 08:22 PM

ach right, this change. (I forgot that one :flowers:)

Can you submit the patches on git hub I think one can fork it somehow and than approve the changes to the master branche.
Or post them here and I will add them asap.

Cheers
David
NeoLoader is a new file sharing client, supporting ed2k/eMule, Bittorent and one click hosters,
it is the first client to be able to download form multiple networks the same file.
NL provides the first fully decentralized scalable torrent and DDL keyword search,
it implements an own novel anonymous file sharing network, providing anonymity and deniability to its users,
as well as many other new features.
It is written in C++ with Qt and is available for Windows, Linux and MacOS.
0

#49 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 18 October 2013 - 06:31 AM

I applied my changes to your code... hope I got all of them :)
Packet* CPartFile::CreateSrcInfoPacket(const CUpDownClient* forClient, uint8 byRequestedVersion, uint16 nRequestedOptions) const
{
	if (!IsPartFile() || srclist.IsEmpty())
		return CKnownFile::CreateSrcInfoPacket(forClient, byRequestedVersion, nRequestedOptions);

	if (md4cmp(forClient->GetUploadFileID(), GetFileHash()) != 0) {
		// should never happen
		DEBUG_ONLY( DebugLogError(_T("*** %hs - client (%s) upload file \"%s\" does not match file \"%s\""), __FUNCTION__, forClient->DbgGetClientInfo(), DbgGetFileInfo(forClient->GetUploadFileID()), GetFileName()) );
		ASSERT(0);
		return NULL;
	}

	// check whether client has either no download status at all or a download status which is valid for this file
	if (!(forClient->GetUpPartCount() == 0 && forClient->GetUpPartStatus() == NULL)
		&& !(forClient->GetUpPartCount() == GetPartCount() && forClient->GetUpPartStatus() != NULL))
	{
		// should never happen
		DEBUG_ONLY( DebugLogError(_T("*** %hs - part count (%u) of client (%s) does not match part count (%u) of file \"%s\""), __FUNCTION__, forClient->GetUpPartCount(), forClient->DbgGetClientInfo(), GetPartCount(), GetFileName()) );
		ASSERT(0);
		return NULL;
	}

	if (!(GetStatus() == PS_READY || GetStatus() == PS_EMPTY))
		return NULL;

	CSafeMemFile data(1024);
	
	uint8 byUsedVersion;
	bool bIsSX2Packet;
	if (forClient->SupportsSourceExchange2() && byRequestedVersion > 0){
		// the client uses SourceExchange2 and requested the highest version he knows
		// and we send the highest version we know, but of course not higher than his request
#ifdef USE_NEO_SX // NEO: NSX - [NeoSoruceExchange]
		byUsedVersion = min(byRequestedVersion, (uint8)(forClient->SupportsSourceExchangeExt() ? SOURCEEXCHANGEEXT_VERSION : SOURCEEXCHANGE2_VERSION));
#else // NEO: NSX END
		byUsedVersion = min(byRequestedVersion, (uint8)SOURCEEXCHANGE2_VERSION);
#endif
		bIsSX2Packet = true;
		data.WriteUInt8(byUsedVersion);

		// we don't support any special SX2 options yet, reserved for later use
		if (nRequestedOptions != 0)
			DebugLogWarning(_T("Client requested unknown options for SourceExchange2: %u (%s)"), nRequestedOptions, forClient->DbgGetClientInfo());
	}
	else{
		byUsedVersion = forClient->GetSourceExchange1Version();
		bIsSX2Packet = false;
		if (forClient->SupportsSourceExchange2())
			DebugLogWarning(_T("Client which announced to support SX2 sent SX1 packet instead (%s)"), forClient->DbgGetClientInfo());
	}

	UINT nCount = 0;
	data.WriteHash16(m_FileIdentifier.GetMD4Hash());
	data.WriteUInt16((uint16)nCount);
	
	bool bNeeded;
	const uint8* reqstatus = forClient->GetUpPartStatus();
	for (POSITION pos = srclist.GetHeadPosition();pos != 0;){
		bNeeded = false;
		const CUpDownClient* cur_src = srclist.GetNext(pos);
#ifdef USE_NAT_T // NEO: NAT - [NatTraversal]
		if ((cur_src->HasLowID() && !cur_src->SupportsNatTraversal()) || !cur_src->IsValidSource())
#else // NEO: NAT END
		if (cur_src->HasLowID() || !cur_src->IsValidSource())
#endif
			continue;
		const uint8* srcstatus = cur_src->GetPartStatus();
		if (srcstatus){
			if (cur_src->GetPartCount() == GetPartCount()){
				if (reqstatus){
					ASSERT( forClient->GetUpPartCount() == GetPartCount() );
					// only send sources which have needed parts for this client
					for (UINT x = 0; x < GetPartCount(); x++){
						if (srcstatus[x] && !reqstatus[x]){
							bNeeded = true;
							break;
						}
					}
				}
				else{
					// We know this client is valid. But don't know the part count status.. So, currently we just send them.
					for (UINT x = 0; x < GetPartCount(); x++){
						if (srcstatus[x]){
							bNeeded = true;
							break;
						}
					}
				}
			}
			else{
				// should never happen
				if (thePrefs.GetVerbose())
					DEBUG_ONLY(DebugLogError(_T("*** %hs - found source (%s) with wrong partcount (%u) attached to partfile \"%s\" (partcount=%u)"), __FUNCTION__, cur_src->DbgGetClientInfo(), cur_src->GetPartCount(), GetFileName(), GetPartCount()));
			}
		}

		if (bNeeded){
			nCount++;
			uint32 dwID;
#ifdef USE_NAT_T // NEO: NAT - [NatTraversal]
			if (byUsedVersion >= 3 && ! cur_src->HasLowID())
#else // NEO: NAT END
			if (byUsedVersion >= 3)
#endif 
				dwID = cur_src->GetUserIDHybrid();
			else
				dwID = ntohl(cur_src->GetUserIDHybrid());
			data.WriteUInt32(dwID);
			data.WriteUInt16(cur_src->GetUserPort());
#ifdef USE_NEO_SX // NEO: NSX - [NeoSoruceExchange]
			if(forClient->SupportsSourceExchangeExt())
			{
				ULONGLONG pos = data.GetPosition();
				uint32 tagcount = 0;
				data.WriteUInt8(tagcount);

#ifdef USE_NAT_T // NEO: NAT - [NatTraversal]
				if (cur_src->HasLowID())
				{
					if(cur_src->SupportsDirectUDPCallback())
					{
						tagcount += 2;

#ifdef USE_IP_6 // NEO: IP6 - [IPv6]
						CTag tagIPv4(CT_EMULE_ADDRESS, _ntohl(cur_src->GetIPv4().ToIPv4())); 
#else // NEO: IP6 END
						CTag tagIPv4(CT_EMULE_ADDRESS, cur_src->GetIP()); 
#endif
						tagIPv4.WriteNewEd2kTag(&data);
					
						CTag tagUdpPorts(CT_EMULE_UDPPORTS, 
									((uint32)cur_src->GetKadPort() << 16) |
									((uint32)cur_src->GetUDPPort() <<  0)
									); 
						tagUdpPorts.WriteNewEd2kTag(&data);
					}

					if(cur_src->GetBuddyIP())
					{
						tagcount += 2;

						CTag tagBuddyIP(CT_EMULE_BUDDYIP, cur_src->GetBuddyIP() ); 
						tagBuddyIP.WriteNewEd2kTag(&data);
					
						CTag tagBuddyPort(CT_EMULE_BUDDYUDP, 
								//	( RESERVED						 )
									((uint32)cur_src->GetBuddyPort() ) 
									);
						tagBuddyPort.WriteNewEd2kTag(&data);
					}

					if(!isnulmd4(cur_src->GetBuddyID()))
					{
						tagcount += 1;

						CTag tagBuddyID(CT_EMULE_BUDDYID, cur_src->GetBuddyID()); 
						tagBuddyID.WriteNewEd2kTag(&data);
					}
				}
#endif // NEO: NAT END

				if(cur_src->GetServerIP() != 0)
				{
					tagcount += 2;

					CTag tagServerIP(CT_EMULE_SERVERIP, cur_src->GetServerIP()); 
					tagServerIP.WriteNewEd2kTag(&data);
				
					CTag tagServerPorts(CT_EMULE_SERVERTCP, 
							//	( RESERVED						  )
								((uint32)cur_src->GetServerPort() )
								); 
					tagServerPorts.WriteNewEd2kTag(&data);
				}

#ifdef USE_IP_6 // NEO: IP6 - [IPv6]
				if(!cur_src->IsIPv6Open())
				{
					tagcount += 1;

					CTag tagIPv6(CT_NEOMULE_IP_V6, cur_src->GetIPv6().Data());
					tagIPv6.WriteNewEd2kTag(&data);
				}
#endif // NEO: IP6 END	
				
				data.Seek(pos, CFile::begin);
				data.WriteUInt8(tagcount);
				data.SeekToEnd();
			}
			else
#endif  // NEO: NSX END
			{
				data.WriteUInt32(cur_src->GetServerIP());
				data.WriteUInt16(cur_src->GetServerPort());
			}
			if (byUsedVersion >= 2)
				data.WriteHash16(cur_src->GetUserHash());
			if (byUsedVersion >= 4){
				// ConnectSettings - SourceExchange V4
				// 4 Reserved (!)
				// 1 DirectCallback Supported/Available 
				// 1 CryptLayer Required
				// 1 CryptLayer Requested
				// 1 CryptLayer Supported
				const uint8 uSupportsCryptLayer	= cur_src->SupportsCryptLayer() ? 1 : 0;
				const uint8 uRequestsCryptLayer	= cur_src->RequestsCryptLayer() ? 1 : 0;
				const uint8 uRequiresCryptLayer	= cur_src->RequiresCryptLayer() ? 1 : 0;
#ifdef USE_NAT_T // NEO: NAT - [NatTraversal]
				uint8 byCryptOptions = (uRequiresCryptLayer << 2) | (uRequestsCryptLayer << 1) | (uSupportsCryptLayer << 0);
				//if(forClient->SupportsSourceExchangeExt())
				//{
				const uint8 uDirectUDPCallback		= cur_src->SupportsDirectUDPCallback() ? 1 : 0;
				const uint8 uSupportsNatTraversal	= cur_src->SupportsNatTraversal() ? 1 : 0;
				byCryptOptions |= (uSupportsNatTraversal << 7) | (uDirectUDPCallback << 3);
				//}
#else // NEO: NAT END
				//const uint8 uDirectUDPCallback	= cur_src->SupportsDirectUDPCallback() ? 1 : 0;
				const uint8 byCryptOptions = /*(uDirectUDPCallback << 3) |*/ (uRequiresCryptLayer << 2) | (uRequestsCryptLayer << 1) | (uSupportsCryptLayer << 0);
#endif
				data.WriteUInt8(byCryptOptions);
			}
			if (nCount > 500)
				break;
		}
	}
	if (!nCount)
		return 0;
	data.Seek(bIsSX2Packet ? 17 : 16, SEEK_SET);
	data.WriteUInt16((uint16)nCount);

	Packet* result = new Packet(&data, OP_EMULEPROT);
	result->opcode = bIsSX2Packet ? OP_ANSWERSOURCES2 : OP_ANSWERSOURCES;
	// (1+)16+2+501*(4+2+4+2+16+1) = 14547 (14548) bytes max.
	if (result->size > 354)
		result->PackPacket();
	if (thePrefs.GetDebugSourceExchange())
		AddDebugLogLine(false, _T("SXSend: Client source response SX2=%s, Version=%u; Count=%u, %s, File=\"%s\""), bIsSX2Packet ? _T("Yes") : _T("No"), byUsedVersion, nCount, forClient->DbgGetClientInfo(), GetFileName());
	return result;
}

void CPartFile::AddClientSources(CSafeMemFile* sources, uint8 uClientSXVersion, bool bSourceExchange2, const CUpDownClient* pClient)
{
	if (stopped)
		return;

	UINT nCount = 0;

	if (thePrefs.GetDebugSourceExchange()) {
		CString strDbgClientInfo;
		if (pClient)
			strDbgClientInfo.Format(_T("%s, "), pClient->DbgGetClientInfo());
		AddDebugLogLine(false, _T("SXRecv: Client source response; SX2=%s, Ver=%u, %sFile=\"%s\""), bSourceExchange2 ? _T("Yes") : _T("No"), uClientSXVersion, strDbgClientInfo, GetFileName());
	}

	UINT uPacketSXVersion = 0;
	if (!bSourceExchange2){
		// for SX1 (deprecated):
		// Check if the data size matches the 'nCount' for v1 or v2 and eventually correct the source
		// exchange version while reading the packet data. Otherwise we could experience a higher
		// chance in dealing with wrong source data, userhashs and finally duplicate sources.
		nCount = sources->ReadUInt16();
		UINT uDataSize = (UINT)(sources->GetLength() - sources->GetPosition());
		// Checks if version 1 packet is correct size
		if (nCount*(4+2+4+2) == uDataSize)
		{
			// Received v1 packet: Check if remote client supports at least v1
			if (uClientSXVersion < 1) {
				if (thePrefs.GetVerbose()) {
					CString strDbgClientInfo;
					if (pClient)
						strDbgClientInfo.Format(_T("%s, "), pClient->DbgGetClientInfo());
					DebugLogWarning(_T("Received invalid SX packet (v%u, count=%u, size=%u), %sFile=\"%s\""), uClientSXVersion, nCount, uDataSize, strDbgClientInfo, GetFileName());
				}
				return;
			}
			uPacketSXVersion = 1;
		}
		// Checks if version 2&3 packet is correct size
		else if (nCount*(4+2+4+2+16) == uDataSize)
		{
			// Received v2,v3 packet: Check if remote client supports at least v2
			if (uClientSXVersion < 2) {
				if (thePrefs.GetVerbose()) {
					CString strDbgClientInfo;
					if (pClient)
						strDbgClientInfo.Format(_T("%s, "), pClient->DbgGetClientInfo());
					DebugLogWarning(_T("Received invalid SX packet (v%u, count=%u, size=%u), %sFile=\"%s\""), uClientSXVersion, nCount, uDataSize, strDbgClientInfo, GetFileName());
				}
				return;
			}
			if (uClientSXVersion == 2)
				uPacketSXVersion = 2;
			else
				uPacketSXVersion = 3;
		}
		// v4 packets
		else if (nCount*(4+2+4+2+16+1) == uDataSize)
		{
			// Received v4 packet: Check if remote client supports at least v4
			if (uClientSXVersion < 4) {
				if (thePrefs.GetVerbose()) {
					CString strDbgClientInfo;
					if (pClient)
						strDbgClientInfo.Format(_T("%s, "), pClient->DbgGetClientInfo());
					DebugLogWarning(_T("Received invalid SX packet (v%u, count=%u, size=%u), %sFile=\"%s\""), uClientSXVersion, nCount, uDataSize, strDbgClientInfo, GetFileName());
				}
				return;
			}
			uPacketSXVersion = 4;
		}
		else
		{
			// If v5+ inserts additional data (like v2), the above code will correctly filter those packets.
			// If v5+ appends additional data after <count>(<Sources>)[count], we are in trouble with the 
			// above code. Though a client which does not understand v5+ should never receive such a packet.
			if (thePrefs.GetVerbose()) {
				CString strDbgClientInfo;
				if (pClient)
					strDbgClientInfo.Format(_T("%s, "), pClient->DbgGetClientInfo());
				DebugLogWarning(_T("Received invalid SX packet (v%u, count=%u, size=%u), %sFile=\"%s\""), uClientSXVersion, nCount, uDataSize, strDbgClientInfo, GetFileName());
			}
			return;
		}
		ASSERT( uPacketSXVersion != 0 );
	}
	else{
		// for SX2:
		// We only check if the version is known by us and do a quick sanitize check on known version
		// other then SX1, the packet will be ignored if any error appears, since it can't be a "misunderstanding" anymore
#ifdef USE_NEO_SX // NEO: NSX - [NeoSoruceExchange]
		if ((pClient && uClientSXVersion > (pClient->SupportsSourceExchangeExt() ? SOURCEEXCHANGEEXT_VERSION : SOURCEEXCHANGE2_VERSION)) || uClientSXVersion == 0){
#else // NEO: NSX END
		if (uClientSXVersion > SOURCEEXCHANGE2_VERSION || uClientSXVersion == 0){
#endif
			if (thePrefs.GetVerbose()) {
				CString strDbgClientInfo;
				if (pClient)
					strDbgClientInfo.Format(_T("%s, "), pClient->DbgGetClientInfo());

				DebugLogWarning(_T("Received invalid SX2 packet - Version unknown (v%u), %sFile=\"%s\""), uClientSXVersion, strDbgClientInfo, GetFileName());
			}
			return;
		}
		// all known versions use the first 2 bytes as count and unknown version are already filtered above
		nCount = sources->ReadUInt16();
#ifdef USE_NEO_SX // NEO: NSX - [NeoSoruceExchange]
		if(pClient && pClient->SupportsSourceExchangeExt())
			uPacketSXVersion = 4;
		else // Note: Since the extended Format has variable length entries such a simpole integrity test can not be performed
#endif  // NEO: NSX END
		{
			UINT uDataSize = (UINT)(sources->GetLength() - sources->GetPosition());	
			bool bError = false;
			switch (uClientSXVersion){
				case 1:
					bError = nCount*(4+2+4+2) != uDataSize;
					break;
				case 2:
				case 3:
					bError = nCount*(4+2+4+2+16) != uDataSize;
					break;
				case 4:
					bError = nCount*(4+2+4+2+16+1) != uDataSize;
					break;
				default:
					ASSERT( false );
			}

			if (bError){
				ASSERT( false );
				if (thePrefs.GetVerbose()) {
					CString strDbgClientInfo;
					if (pClient)
						strDbgClientInfo.Format(_T("%s, "), pClient->DbgGetClientInfo());
					DebugLogWarning(_T("Received invalid/corrupt SX2 packet (v%u, count=%u, size=%u), %sFile=\"%s\""), uClientSXVersion, nCount, uDataSize, strDbgClientInfo, GetFileName());
				}
				return;
			}
			uPacketSXVersion = uClientSXVersion;
		}
	}

	for (UINT i = 0; i < nCount; i++)
	{
		uint32 dwID = sources->ReadUInt32();
		uint16 nPort = sources->ReadUInt16();
		uint32 dwServerIP = 0; // sources->ReadUInt32();
		uint16 nServerPort = 0; // sources->ReadUInt16();
#ifdef USE_NEO_SX // NEO: NSX - [NeoSoruceExchange]
		uint32 dwIP = 0;
#ifdef USE_IP_6 // NEO: IP6 - [IPv6]
		CAddress IPv6;
#endif // NEO: IP6 END
		uint16 nUDPPort = 0;
		uint16 nKadPort = 0;
		uint32 dwBuddyIP = 0;
		uint16 nBuddyPort = 0;
		byte BuddyID[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
		if(pClient && pClient->SupportsSourceExchangeExt())
		{
			uint8 tagcount = sources->ReadUInt8();
			for (uint8 i = 0; i < tagcount; i++)
			{
				CTag temptag(sources, true);
				switch (temptag.GetNameID())
				{
#ifdef USE_NAT_T // NEO: NAT - [NatTraversal]
					case CT_EMULE_ADDRESS:
						if(temptag.IsInt())
							dwIP = temptag.GetInt();
						break;
					case CT_EMULE_UDPPORTS:
						if(temptag.IsInt())
						{
							nKadPort = (uint16)(temptag.GetInt() >> 16);
							nUDPPort = (uint16)temptag.GetInt();
						}
						break;

					case CT_EMULE_BUDDYIP:
						if(temptag.IsInt())
							dwBuddyIP = temptag.GetInt();
						break;
					case CT_EMULE_BUDDYUDP:
						if(temptag.IsInt())
							nBuddyPort = (uint16)temptag.GetInt();
						break;
					case CT_EMULE_BUDDYID:
						if(temptag.IsHash())
							md4cpy(BuddyID, temptag.GetHash());
						break;
#endif // NEO: NAT END				

					case CT_EMULE_SERVERIP:
						if(temptag.IsInt())
							dwServerIP = temptag.GetInt();
						break;
					case CT_EMULE_SERVERTCP:
						if(temptag.IsInt())
							dwServerIP = (uint16)temptag.GetInt();
						break;

#ifdef USE_IP_6 // NEO: IP6 - [IPv6]
					case CT_NEOMULE_IP_V6:
					{
						byte uIP[16];
						md4cpy(uIP, temptag.GetHash());
						IPv6 = CAddress(uIP);
						break;
					}
#endif // NEO: IP6 END	

					default:
						AddDebugLogLine(false, _T("Ignoring unknown ExtSX Tag from: %s"), pClient->DbgGetClientInfo());
				}
			}
		}
		else
#endif  // NEO: NSX END
		{
			dwServerIP = sources->ReadUInt32();
			nServerPort = sources->ReadUInt16();
		}

		uchar achUserHash[16];
		if (uPacketSXVersion >= 2)
			sources->ReadHash16(achUserHash);

		uint8 byCryptOptions = 0;
		if (uPacketSXVersion >= 4)
			byCryptOptions = sources->ReadUInt8();

		// Clients send ID's in the Hyrbid format so highID clients with *.*.*.0 won't be falsely switched to a lowID..
		if (uPacketSXVersion >= 3)
		{
			uint32 dwIDED2K = ntohl(dwID);

			// check the HighID(IP) - "Filter LAN IPs" and "IPfilter" the received sources IP addresses
			if (!IsLowID(dwID))
			{
				if (!IsGoodIP(dwIDED2K))
				{
					// check for 0-IP, localhost and optionally for LAN addresses
					//if (thePrefs.GetLogFilteredIPs())
					//	AddDebugLogLine(false, _T("Ignored source (IP=%s) received via source exchange - bad IP"), ipstr(dwIDED2K));
					continue;
				}
				if (theApp.ipfilter->IsFiltered(dwIDED2K))
				{
					if (thePrefs.GetLogFilteredIPs())
						AddDebugLogLine(false, _T("Ignored source (IP=%s) received via source exchange - IP filter (%s)"), ipstr(dwIDED2K), theApp.ipfilter->GetLastHit());
					continue;
				}
				if (theApp.clientlist->IsBannedClient(dwIDED2K)){
#ifdef _DEBUG
					if (thePrefs.GetLogBannedClients()){
						CString strDbgClientInfo;
#ifdef USE_IP_6 // NEO: IP6 - [IPv6]
						CUpDownClient* pClient = theApp.clientlist->FindClientByIP(CAddress(_ntohl(dwIDED2K)));
#else // NEO: IP6 END
						CUpDownClient* pClient = theApp.clientlist->FindClientByIP(dwIDED2K);
#endif
						if (pClient)
							strDbgClientInfo.Format(L" - banned client %s", pClient->DbgGetClientInfo());
                        AddDebugLogLine(false, L"Ignored source (IP=%s) received via source exchange%s", ipstr(dwIDED2K), strDbgClientInfo);
					}
#endif
					continue;
				}
			}

			// additionally check for LowID and own IP
			if (!CanAddSource(dwID, nPort, dwServerIP, nServerPort, NULL, false))
			{
				//if (thePrefs.GetLogFilteredIPs())
				//	AddDebugLogLine(false, _T("Ignored source (IP=%s) received via source exchange"), ipstr(dwIDED2K));
				continue;
			}
		}
		else
		{
			// check the HighID(IP) - "Filter LAN IPs" and "IPfilter" the received sources IP addresses
			if (!IsLowID(dwID))
			{
				if (!IsGoodIP(dwID))
				{ 
					// check for 0-IP, localhost and optionally for LAN addresses
					//if (thePrefs.GetLogFilteredIPs())
					//	AddDebugLogLine(false, _T("Ignored source (IP=%s) received via source exchange - bad IP"), ipstr(dwID));
					continue;
				}
				if (theApp.ipfilter->IsFiltered(dwID))
				{
					if (thePrefs.GetLogFilteredIPs())
						AddDebugLogLine(false, _T("Ignored source (IP=%s) received via source exchange - IP filter (%s)"), ipstr(dwID), theApp.ipfilter->GetLastHit());
					continue;
				}
				if (theApp.clientlist->IsBannedClient(dwID)){
#ifdef _DEBUG
						CString strDbgClientInfo;
					if (thePrefs.GetLogBannedClients()){
#ifdef USE_IP_6 // NEO: IP6 - [IPv6]
						CUpDownClient* pClient = theApp.clientlist->FindClientByIP(CAddress(_ntohl(dwID)));
#else // NEO: IP6 END
						CUpDownClient* pClient = theApp.clientlist->FindClientByIP(dwID);
#endif
						if (pClient)
							strDbgClientInfo.Format(L" - banned client %s", pClient->DbgGetClientInfo());
                        AddDebugLogLine(false, L"Ignored source (IP=%s) received via source exchange%s", ipstr(dwID), strDbgClientInfo);
					}
#endif
					continue;
				}
			}

			// additionally check for LowID and own IP
			if (!CanAddSource(dwID, nPort, dwServerIP, nServerPort))
			{
				//if (thePrefs.GetLogFilteredIPs())
				//	AddDebugLogLine(false, _T("Ignored source (IP=%s) received via source exchange"), ipstr(dwID));
				continue;
			}
		}

		if (GetMaxSources() > GetSourceCount())
		{
			CUpDownClient* newsource;
			if (uPacketSXVersion >= 3)
				newsource = new CUpDownClient(this, nPort, dwID, dwServerIP, nServerPort, false);
			else
				newsource = new CUpDownClient(this, nPort, dwID, dwServerIP, nServerPort, true);

#ifdef USE_NEO_SX // NEO: NSX - [NeoSoruceExchange]
			if(pClient && pClient->SupportsSourceExchangeExt())
			{
#ifdef USE_NAT_T // NEO: NAT - [NatTraversal]
#ifdef USE_IP_6 // NEO: IP6 - [IPv6]
				if(dwIP)
					newsource->SetIP(CAddress(_ntohl(dwIP)));
				if(!IPv6.IsNull())
					newsource->SetIPv6(IPv6);
#else // NEO: IP6 END
				if(dwIP)
					newsource->SetIP(dwIP);
#endif
				if(nUDPPort)
					newsource->SetUDPPort(nUDPPort);
				if(nKadPort)
					newsource->SetKadPort(nKadPort);

				if(dwBuddyIP)
					newsource->SetBuddyIP(dwBuddyIP);
				if(nBuddyPort)
					newsource->SetBuddyPort(nBuddyPort);
				if(!isnulmd4(BuddyID))
					newsource->SetBuddyID(BuddyID);
#endif // NEO: NAT END	
			}
#endif  // NEO: NSX END

			if (uPacketSXVersion >= 2)
				newsource->SetUserHash(achUserHash);
			if (uPacketSXVersion >= 4) {
#ifdef USE_NAT_T // NEO: NAT - [NatTraversal]
				newsource->SetConnectOptions(byCryptOptions, true, pClient->SupportsSourceExchangeExt());
#else // NEO: NAT END
				newsource->SetConnectOptions(byCryptOptions, true, false);
#endif
				//if (thePrefs.GetDebugSourceExchange()) // remove this log later
				//	AddDebugLogLine(false, _T("Received CryptLayer aware (%u) source from V4 Sourceexchange (%s)"), byCryptOptions, newsource->DbgGetClientInfo());
			}
			newsource->SetSourceFrom(SF_SOURCE_EXCHANGE);
			theApp.downloadqueue->CheckAndAddSource(this, newsource);
		} 
		else
			break;
	}
}

0

#50 User is offline   DavidXanatos 

  • Neo Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1469
  • Joined: 23-April 04

Posted 26 October 2013 - 08:02 AM

Sorry for the delay head a really busy week,
fixes are now committed to the repository.
NeoLoader is a new file sharing client, supporting ed2k/eMule, Bittorent and one click hosters,
it is the first client to be able to download form multiple networks the same file.
NL provides the first fully decentralized scalable torrent and DDL keyword search,
it implements an own novel anonymous file sharing network, providing anonymity and deniability to its users,
as well as many other new features.
It is written in C++ with Qt and is available for Windows, Linux and MacOS.
0

#51 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 14 November 2013 - 02:41 PM

David, I found more issues.
I just noticed I didn't enable OP_RENDEZVOUS in clientudpsocket and I remembered why: it's not sent anywhere. Is there some code missing?

Also, my testers have problem connecting to each other and we think it's NAT-T related. One tester has 2 highID clients but when connecting, they show up as firewalled.
I have my doubts about that codepart in CUpDownClient::TryToConnect

Quote

if (m_UserIPv4.IsNull())
m_UserIPv4 = CAddress(m_nUserIDHybrid);

bool bUseIPv6 = m_bOpenIPv6 && !theApp.GetPublicIPv6().IsNull();
if (bUseIPv6)
UpdateIP(m_UserIPv6);
else
UpdateIP(m_UserIPv4);

The UpdateIP() calls overwrite the connectIP, is that intended?

Finally, I posted a bug in CPartFile::AddClientSources:
if ((pClient && uClientSXVersion > (pClient->SupportsSourceExchangeExt() ? SOURCEEXCHANGEEXT_VERSION : SOURCEEXCHANGE2_VERSION)) || uClientSXVersion == 0){

should be:
if (uClientSXVersion > (pClient && pClient->SupportsExtendedSourceExchange() ? SOURCEEXCHANGEEXT_VERSION : SOURCEEXCHANGE2_VERSION) || uClientSXVersion == 0)

0

#52 User is offline   DavidXanatos 

  • Neo Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1469
  • Joined: 23-April 04

Posted 14 November 2013 - 09:22 PM

Yea I missed a line in baseclient.cpp

				CSafeMemFile data(128);
				data.WriteHash16(GetBuddyID());
				uchar hash[16]; 
				md4clr(hash);
				data.WriteHash16(hash); // a invalid NULL hash indicates that this is a Custom Packet, not a file reask

				data.WriteUInt8(OP_RENDEZVOUS); // <-- here it goes ------------------------
				data.WriteHash16(thePrefs.GetUserHash());
				data.WriteUInt8(GetMyConnectOptions(true, true));

				if (thePrefs.GetDebugClientUDPLevel() > 0)
					DebugSend("OP__ReaskCallbackUDP", this, reqfile->GetFileHash());
				Packet* response = new Packet(&data, OP_EMULEPROT);
				response->opcode = OP_REASKCALLBACKUDP;
				theStats.AddUpDataOverheadFileRequest(response->size);
				theApp.downloadqueue->AddUDPFileReasks();


>I have my doubts about that codepart in CUpDownClient::TryToConnect
hmm....
first if we dont have a v4 address we make one form the hybrid id that should be ok

and than we select if we want to go with IP v4 or v6 should also be fine :/

although I'm not sure about the m_nUserIDHybrid may be i should have a ntohl someware inthere

>The UpdateIP() calls overwrite the connectIP, is that intended?
yes Update IP is used to select the IP to be used for a connection attempt, respectivly it is called for a incomming connection and updates the connect ip.

>Finally,
yes thx
NeoLoader is a new file sharing client, supporting ed2k/eMule, Bittorent and one click hosters,
it is the first client to be able to download form multiple networks the same file.
NL provides the first fully decentralized scalable torrent and DDL keyword search,
it implements an own novel anonymous file sharing network, providing anonymity and deniability to its users,
as well as many other new features.
It is written in C++ with Qt and is available for Windows, Linux and MacOS.
0

#53 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 15 November 2013 - 01:25 PM

Thx... for the callback in OP_RENDEZVOUS... IMHO we should set the connect options, too:
callback->SetConnectOptions(byConnectOptions, true, true);
callback->SetNatTraversalSupport(true);

0

#54 User is offline   DavidXanatos 

  • Neo Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1469
  • Joined: 23-April 04

Posted 17 November 2013 - 09:57 AM

View PosttHeWiZaRdOfDoS, on 15 November 2013 - 01:25 PM, said:

Thx... for the callback in OP_RENDEZVOUS... IMHO we should set the connect options, too:
callback->SetConnectOptions(byConnectOptions, true, true);
callback->SetNatTraversalSupport(true);


yea you are right, fix commited
NeoLoader is a new file sharing client, supporting ed2k/eMule, Bittorent and one click hosters,
it is the first client to be able to download form multiple networks the same file.
NL provides the first fully decentralized scalable torrent and DDL keyword search,
it implements an own novel anonymous file sharing network, providing anonymity and deniability to its users,
as well as many other new features.
It is written in C++ with Qt and is available for Windows, Linux and MacOS.
0

#55 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 18 November 2013 - 07:18 AM

David, I'm pretty sure IPv6 support is NOT working properly. A lot of my testers have strange connection problems and it seems they have IPv6 addresses (at least my client reports they have one). I changed your local IPv6 detection code to log ALL possible IPv6 addresses and voilà:
Additional possible IPv6 address: 2002:4f2f:e552:0:0:0:4f2f:e552
Additional possible IPv6 address: 2001:0:5ef5:79fd:4af:2df6:b0d0:1aad

Your code always pics the first available one but that seems to be wrong.
One tester - Neo26 - reported that your own client tells him that he doesn't have an IPv6 but the code posted here does. Can you check that again?
0

#56 User is offline   DavidXanatos 

  • Neo Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1469
  • Joined: 23-April 04

Posted 18 November 2013 - 09:44 AM

My client uses a platform independent Qt provided interface to obtain IPv6 addresses.
The code in the sample implementation is custom and uses windows API's its possible that there is a bug some ware.

The system should drop all local link addresses and loop back addresses, the remaining addresses should be public IPv6 addresses or none.

I will check it out asap.
NeoLoader is a new file sharing client, supporting ed2k/eMule, Bittorent and one click hosters,
it is the first client to be able to download form multiple networks the same file.
NL provides the first fully decentralized scalable torrent and DDL keyword search,
it implements an own novel anonymous file sharing network, providing anonymity and deniability to its users,
as well as many other new features.
It is written in C++ with Qt and is available for Windows, Linux and MacOS.
0

#57 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 18 November 2013 - 10:17 AM

ThX. I think it may be a good idea to tweak the flags parameter of the GetAdaptersAddresses function. GAA_FLAG_SKIP_MULTICAST|GAA_FLAG_SKIP_DNS_SERVER and maybe GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER sound sensible. We could also cross-check the chosen IPv6 to the IPv4 (if present).
0

#58 User is offline   DavidXanatos 

  • Neo Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1469
  • Joined: 23-April 04

Posted 18 November 2013 - 10:20 AM

OK!

you have a IPv6 address, or at least something like that
2001:0:: is Teredo and http://en.wikipedia....eredo_tunneling
2002:: is a 6to4 tunnel http://en.wikipedia.org/wiki/6to4

On my machine Qt does not return the torredo address.

Added code to filter torredo addresses.
Should I also filter the

Not sure about 6to4 though, usually if you have this you should be able to use IPv6 over it.

Do you have a working 6to4 tunnel?

David X.
NeoLoader is a new file sharing client, supporting ed2k/eMule, Bittorent and one click hosters,
it is the first client to be able to download form multiple networks the same file.
NL provides the first fully decentralized scalable torrent and DDL keyword search,
it implements an own novel anonymous file sharing network, providing anonymity and deniability to its users,
as well as many other new features.
It is written in C++ with Qt and is available for Windows, Linux and MacOS.
0

#59 User is offline   tHeWiZaRdOfDoS 

  • Man, what a bunch of jokers...
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 5630
  • Joined: 28-December 02

Posted 18 November 2013 - 10:23 AM

Unfortunately, I don't have IPv6 myself and also disabled IPv6 protocol in windows which is why I didn't notice this earlier, it's just one of my testers.
IMHO, I agree with you and think that the tunnel should be fine
0

#60 User is offline   DavidXanatos 

  • Neo Dev
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1469
  • Joined: 23-April 04

Posted 18 November 2013 - 10:25 AM

ok, than lets hope it will work now.
updated code again with the suggested flags
NeoLoader is a new file sharing client, supporting ed2k/eMule, Bittorent and one click hosters,
it is the first client to be able to download form multiple networks the same file.
NL provides the first fully decentralized scalable torrent and DDL keyword search,
it implements an own novel anonymous file sharing network, providing anonymity and deniability to its users,
as well as many other new features.
It is written in C++ with Qt and is available for Windows, Linux and MacOS.
0

  • Member Options

  • (4 Pages)
  • +
  • 1
  • 2
  • 3
  • 4

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users