in the file "Servent.cpp" change "Servent::slotReadyRead()" as below:
Code:
void Servent::slotReadyRead()
{
char cbuff[4096+10];
_last_input = time(NULL);
do
{
int rd = _socket->readBlock(cbuff, 4096);
_buffer.append(cbuff, rd);
}
while(_socket->bytesAvailable() > 0);
if( (state() == Waiting) && (_buffer.find("\r\n\r\n") != std::string::npos) )
{
_header = _buffer.substr(0, _buffer.find("\r\b\r\n"));
std::string b = _buffer;
if( _buffer.substr(0, 9) != "GNUTELLA/" )
{
slotError(-1);
return;
}
_buffer.erase(0, 9);
// get version
std::string::size_type idx = _buffer.find(" ");
if( idx == std::string::npos )
{
slotError(-1);
return;
}
_version = _buffer.substr(0, idx);
_buffer.erase(0, idx + 1); // delete version number with space from buffer
// get status code
idx = _buffer.find(" ");
if( idx == std::string::npos )
{
slotError(-1);
return;
}
std::string status = _buffer.substr(0, idx);
_buffer.erase(0, idx + 1); // delete status code with space from buffer
/////////////////////// THIS IS THE MOD !!!!!!
// keep that BS off my screen!
idx = _buffer.find("BearShare");
if( idx != std::string::npos )
{
slotError(-1);
return;
}
// get user agent information
idx = _buffer.find("User-Agent:");
if( idx != std::string::npos )
{
_buffer.erase(0, idx + 11);
idx = _buffer.find_first_not_of(" ");
_buffer.erase(0, idx);
idx = _buffer.find("\r\n");
_user_agent = _buffer.substr(0, idx);
}
if( status != "200")
{
slotError(-1);
return;
}
// status code is 200 ok
idx = _buffer.find("\r\n\r\n"); // find end of header
_buffer.erase(0, idx + 4); // delete header from buffer
setState(Connected);
std::string r("GNUTELLA/0.6 200 OK\r\n\r\n");
sendMessageDirect(r);
int ttl = _parent->_parent->ui_spinbox_ttl->value();
Ping p(1, 0, _id);
sendMessageDirect(p._data); // send initial ping
_parent->_statistic.out_ping_n++;
_parent->_statistic.out_ping_b += p._data.size();
return;
}
else
while( _buffer.size() >= HEADER_SIZE )
{
Q_UINT32 payload = Message::str_uint32(_buffer.substr(19, 4).data());
if(payload > 20000)
{
_buffer.erase();
slotError(-1);
return;
}
if( _buffer.size() >= (HEADER_SIZE + payload) )
{
_input++;
if(_message_buffer.size() < 30)
_message_buffer.push_back(_buffer.substr(0, HEADER_SIZE + payload));
_buffer.erase(0, HEADER_SIZE + payload);
_bytes_in += HEADER_SIZE + payload;
}
else
return;
}
}