Gnutella Forums

Gnutella Forums (https://www.gnutellaforums.com/)
-   Qtella (Linux/Unix) (https://www.gnutellaforums.com/qtella-linux-unix/)
-   -   Your right to block $$ clients (https://www.gnutellaforums.com/qtella-linux-unix/9075-your-right-block-clients.html)

Unregistered March 12th, 2002 05:45 PM

Your right to block $$ clients
 
If you don't want to contribute any $$ to commercial clients, or clients that block XoloX without reason, or clients that have guntella domination in mind, apply the following patches so you don't connect or share files with them.
It's now your choice.

Unregistered March 12th, 2002 05:49 PM

for the file "Upload.cpp" modify "Upload::initUpload()" and recompile, the mod is only a few lines
see "/////////// THIS IS THE MOD!!!!"

Code:

void Upload::initUpload()
{
  StringManipulation sm(_data);

  if(_data.substr(0,3) != "GET")
    {
      setState(Closed);
      return;
    }

  std::string::size_type  idx = sm.to_lower().find("/get/");

  if(idx == std::string::npos)
    {
      _socket->close();
      setState(Closed);
      return;
    }

  idx += 5;
  std::string::size_type  idx2 = _data.find("/", idx);

  if(idx == std::string::npos)
    {
      _socket->close();
      setState(Closed);
      return;
    }

  std::string sindex = _data.substr(idx, idx2-idx);

  std::strstream a;
  a << sindex << std::ends;
  a >> index;


  idx = sm.to_lower().find(" http", idx2);

  if(idx == std::string::npos)
    {
      _socket->close();
      setState(Closed);
      return;
    }

  filename = _data.substr(idx2+1, idx-idx2-1);



/////////// THIS IS THE MOD!!!!

  // keep this BS off my screen
  if( (idx = sm.to_lower().find("bearshare")) != std::string::npos )
    {
      _socket->close();
      setState(Closed);
      return;
    }




  if( (idx = sm.to_lower().find("user-agent:")) != std::string::npos )
    {
      idx = _data.find_first_not_of(" ", idx+11);
      idx2 = _data.find("\r\n", idx);
      client = _data.substr(idx, idx2-idx);
    }
  else
    client = "";


  if( (idx = sm.to_lower().find("range:")) != std::string::npos )
    {
      idx = _data.find_first_of("1234567890", idx+6);
      idx2 = _data.find("-", idx);
      std::string srange_start = _data.substr(idx, idx2-idx);
     
      std::strstream c;
      c << srange_start << std::ends;
      c >> range_start;

      idx = _data.find("\r\n", idx2);
      std::string s = _data.substr(idx2, idx - idx2 - 1);

//      if( (idx = _data.find_first_of("0123456789", idx2+1)) != std::string::npos )
      if( (idx = s.find_first_of("0123456789")) != std::string::npos )
        {
          idx2 = s.find_first_not_of("0123456789", idx);
          std::string srange_end = s.substr(idx, idx2 - idx - 1);

          std::strstream b;
          b << srange_end << std::ends;
          b >> range_end;
        }
      else range_end = 0;
    }
  else
    {
      range_start = 0;
      range_end = 0;
    }

  if(index < _parent->_parent->vSharedFiles.size())
    if( _parent->_parent->vSharedFiles[index]->file == filename )
      {
        _parent->_parent->vSharedFiles[index]->requests++;
        std::strstream str;
        str << _parent->_parent->vSharedFiles[index]->requests << std::ends;
        _parent->_parent->vSharedFiles[index]->item->setText(2, str.str());
        str.freeze(false);
      }

  if(_parent->numberUploads() >= _parent->_parent->ui_spinbox_maxuploads->value())
    {
      std::strstream str;
      std::string    s;
      str << "HTTP/1.0 503 Busy\r\nServer: Qtella " << VERSION << "\r\n\r\n" << std::ends;
      s = str.str();
      str.freeze(false);
      _socket->writeBlock(s.c_str(), s.size());
      _socket->close();
      _state = Busy;
      return;
    }

  //
  std::string f = _parent->_parent->vSharedFiles[index]->directory;

  if(f.size() > 0) if( f[f.size()-1] != '/' ) f += '/';
  f += _parent->_parent->vSharedFiles[index]->file;

  item = new QListViewItem(_parent->_parent->ui_listview_uploads, _parent->_parent->vSharedFiles[index]->file.c_str());
  item->setText(2, _socket->peerAddress().toString());

  _file.setName(f.c_str());

  if( !_file.exists() )
    {
      std::string s;
      s = "HTTP/1.0 404 NOT FOUND\r\nServer: Qtella "+std::string(VERSION)+"\r\n\r\n";
      _socket->writeBlock(s.data(), s.size());
      _socket->close();
      setState(NotFound);
      return;
    }

  setState(Connected);

  if(range_end == 0) range_end = _file.size() - 1;

  _towrite = range_end - range_start + 1;

  std::string s("HTTP/1.0 200 OK\r\nContent-Length: ");
  std::strstream str;
  str << _file.size() << std::ends;  // must be file.size() !!
  s += std::string(str.str());
  str.freeze(false);
  s += std::string("\r\nContent-Type: application/binary\r\nServer: Qtella "+std::string(VERSION)+"\r\n\r\n");

  _socket->writeBlock(s.c_str(), s.size());

  if( !_file.open(IO_ReadOnly|IO_Raw) )
    {
      setState(Error);
      _socket->close();
      return;
    }

  _file.at(range_start);
  _written = 0;
}


Unregistered March 12th, 2002 05:53 PM

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;
      }
}


verwilst April 5th, 2002 03:25 AM

wtf?

Gamer June 7th, 2002 02:28 AM

Zip is a wonderful format you know.. So are text files

tshdos June 8th, 2002 12:30 AM

Quote:

Originally posted by Gamer
Zip is a wonderful format you know.. So are text files
Unregistered users cannot post attachments.

This thread has been dead for over 2 months. Let it go.

Unregistered June 8th, 2002 12:50 AM

Has this been added to the latest release?

Taliban June 8th, 2002 09:43 AM

of course not!

Unregistered June 8th, 2002 11:18 AM

why not?


All times are GMT -7. The time now is 03:59 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 ©2011, Crawlability, Inc.

Copyright © 2020 Gnutella Forums.
All Rights Reserved.