View Single Post
  #3 (permalink)  
Old March 12th, 2002
Unregistered
Guest
 
Posts: n/a
Default

For uploads, modify CGnuUpload::OnReceive in the file GnuUpload.cpp, two lines added for one header check, works for push or normal uploads.

Code:
void CGnuUpload::OnReceive(int nErrorCode)
{
	byte* pBuff = new byte[6000];

	DWORD dwBuffLength = Receive(pBuff, 4096);

	switch (dwBuffLength)
	{
	case 0:
		m_pShell->m_Error = "Bad Push";
		Close();
		delete [] pBuff;
		return;
		break;
	case SOCKET_ERROR:
		m_pShell->m_Error = "Bad Push";
		Close();
		delete [] pBuff;
		return;
		break;
	}

	pBuff[dwBuffLength] = 0;
	CString Header(pBuff);
	m_pShell->m_Handshake += Header;
	m_pShell->m_GetRequest += Header;

	// New Upload
	if(m_pShell->m_GetRequest.Find("\r\n\r\n") != -1)
	{
		CString Handshake = m_pShell->m_GetRequest;

		// keep any BS off my screen
		if(Handshake.Find("BearShare") != -1) Close();

		if(Handshake.Find("GET /get/") == 0)
		{
			// Get Node info
			CString Host;
			UINT    nPort;
			GetPeerName(Host, nPort);

			// Set Variables
			m_pShell->m_Host = StrtoIP(Host);
			m_pShell->m_Port = 0;

			m_pShell->VerifyFile(Handshake);
		}
		else
		{
			m_pShell->m_Error = "Bad Push";
			Close();
		}
	}

	delete [] pBuff;

	CAsyncSocket::OnReceive(nErrorCode);
}
Reply With Quote