User Tools

Site Tools


var:ktorrent_trick

KTorrent - trick client identity

01.11.2009

(Note: this will not modify your ratio or so)

If you use KTorrent as a preferred application for torrents, you might be in need at some point to trick client identification to tracker, in order to still connect to those trackers who have a “whitelist” applications (without Ktorrent, of course :) )

Because KTorrent doesn't have an inside option for this, you'll need to modify the sources and reinstall from them.
This howto assumes you already downloaded the ktorrent sources and unpack them in a directory of choice (at time time, ktorrent stable is 3.2.5).
Below is the solution (not necessarily elegant but a working one)

1. Files to be modified

ktorrent/main.cpp
(add new options to command line)

inside main function, around line 81, find out the following line and comment it out:

// bt::SetClientInfo("KTorrent",kt::MAJOR,kt::MINOR,kt::RELEASE,kt::VERSION_TYPE,"KT");

then, a little bit below that, look for:

KCmdLineOptions options;
	options.add("+[Url]", ki18n("Document to open"));
	options.add("silent", ki18n("Silently open torrent given on URL"));

and add right after (and before the KCmdLineArgs::addCmdLineOptions(options); line ) the following:

        options.add("client <clientString>",ki18n("Indentify application string sent to the tracker (e.g:UTorrent)"), "KTorrent");
        options.add("clientcode <clientCode>",ki18n("Indentify application code sent to the tracker (e.g:UT)"),"KT");
        options.add("clientver <clientVersion>",ki18n("Put here client version as major:minor:release (e.g. 1:8:0)"),"3:5:2");

ktorrent/app.cpp
(process the new options)

Inside int App::newInstance() between
kt::GUI *widget = 0;
and
if (!main_widget)
add the following code:

                // here is the part that trick the client identification to tracker
                QString clientStr = args->getOption("client");
                QString clientCode = args->getOption("clientcode");
                QString version = args->getOption("clientver");
                QStringList mmr = version.split(":");
 
                bool ok;
 
                bt::SetClientInfo(  clientStr, 
                                    mmr[0].toInt(&ok),
                                    mmr[1].toInt(&ok),
                                    mmr[2].toInt(&ok),
                                    kt::VERSION_TYPE,
                                    clientCode);

2. Compile the modified code and install as usual

cd directory_where_ktorrent_source_code_is
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..
make
sudo make install

3. Call the Ktorrent with the new args

If you installed successfully the new ktorrent, then it's time to fire it up like this:

ktorrent --client UTorrent --clientcode UT --clientver 1:8:0

This will report to tracker as UTorrent (code UT) and version 1.8.0. Pretty nice, huh?

Check here for a list with client names and codes.
Check also how to DELUGE - trick client identity

var/ktorrent_trick.txt · Last modified: 2013/03/16 17:41 (external edit)