Here it is, simply replace CGnuNode::ParseHandshake in the file "GnuNode.cpp" with the following and recompile! Add as many checks as you like for each $$$ client you would like to block. (4 total lines, two places to check the connect strings, added to the original code, see below)
Code:
/////////////////////////////////////////////////////////////////////////////
// New connections
bool CGnuNode::ParseHandshake(CString Data, byte* Stream, int StreamLength)
{
int i;
CString Handshake;
CString NetworkName = m_pDoc->ModeNetwork;
bool Guerilla = false;
// Making an inbound connect
if(m_Inbound)
{
// Version 6
if(Data.Find("\r\n\r\n") != -1)
{
Handshake = Data.Mid(0, Data.Find("\r\n\r\n") + 4);
m_Handshake += Handshake;
if(m_Handshake.Find("GUERILLA ") != -1)
{
NetworkName = "GUERILLA";
Guerilla = true;
}
// keep any BS off my screen
if(Handshake.Find("BearShare") != -1) { Close(); return true; }
// Connect string, GNUTELLA CONNECT/0.6\r\n
if(Handshake.Find(NetworkName + " CONNECT/") != -1)
{
if(m_pPrefs->m_NetworkModel == NETWORK_PRIVATE && m_pPrefs->m_Lan)
if(Handshake.Find("LAN: " + m_pPrefs->m_LanName + "\r\n") == -1)
{
Close();
return true;
}
Send_ConnectOK(true, false, Guerilla);
return true;
}
// Ok string, GNUTELLA/0.6 200 OK\r\n
else if(Handshake.Find(" 200 OK\r\n") != -1)
{
SetConnected();
// Stream begins
for(i = 0; i < StreamLength - 4; i++)
if(strncmp((char*) &Stream[i], "\r\n\r\n", 4) == 0)
{
m_dwExtraLength = StreamLength - (i + 4);
memcpy(m_pExtra, &Stream[i + 4], m_dwExtraLength);
}
return true;
}
}
// Version 4
else if(Data.Find(VERSION_4_CONNECT) != -1 && !m_pPrefs->m_Lan)
{
m_Handshake += "GNUTELLA CONNECT/0.4\r\n";
Send_ConnectOK(false, false, false);
SetConnected();
return true;
}
}
// Making an outbound connect
else
{
if((m_pDoc->ModeVersion6 || m_pPrefs->m_NetworkModel == NETWORK_PRIVATE) && Data.Find("\r\n\r\n") != -1)
{
Handshake = Data.Mid(0, Data.Find("\r\n\r\n") + 4);
m_Handshake += Handshake;
// Ok string, GNUTELLA/0.6 200 OK\r\n
if(Handshake.Find(" 200 OK\r\n") != -1)
{
// keep any BS off my screen
if(Handshake.Find("BearShare") != -1) { Close(); return true; }
// Check if remote host has our IP
int ipPos = Handshake.Find("Remote-IP: ");
if(ipPos != -1)
{
ipPos += 11;
int ipBack = Handshake.Find("\r\n", ipPos);
m_pPrefs->m_LocalHost = StrtoIP( Handshake.Mid(ipPos, ipBack - ipPos));
}
if(m_pPrefs->m_NetworkModel == NETWORK_PRIVATE && m_pPrefs->m_Lan)
if(Handshake.Find("LAN: " + m_pPrefs->m_LanName + "\r\n") == -1)
{
Close();
return true;
}
Send_ConnectOK(true, true, false);
SetConnected();
}
else
Close();
return true;
}
else if(Data.Find(VERSION_4_CONNECT_OK) != -1)
{
m_Handshake += "GNUTELLA OK\r\n";
// Stream begins
for(i = 0; i < StreamLength - 2; i++)
if(strncmp((char*) &Stream[i], "\n\n", 2) == 0)
{
m_dwExtraLength = StreamLength - (i + 2);
memcpy(m_pExtra, &Stream[i + 2], m_dwExtraLength);
}
SetConnected();
return true;
}
}
return false;
}