Development

MooPolice is based on the Rasterbar libtorrent BitTorrent client library.

The library source code is slightly modified so that it can be used within a Visual Studio 2005 project (VC8 compiler). Extra code for tcp/ethernet bandwith estimation and filename modification is added too.

MooPolice uses a svn repository.
anonymous read access http://139.30.204.73:83/mp-svn/MooPolice
Browse the repository


Here is a short description of the extensions used in MooPolice.
It might give you some hints about how to implement those extensions yourself.


The following text is only a short description of the extensions used in MooPolice. All extensions are implemented using the BitTorrent extension transport protocol as described here: Extension Protocol.
There is no fixed message index value for the different extensions. The actual number is decided within the extension handshake though MooPolice will always request the same numbers for the same extensions (at least for the same client version). Any kinds of message format errors will lead to an instant disconnect.
Up to now MooPolice will not send further handshake message to disable/enable specific extensions later. Btw, if you are not going to use an extension, for example: pex because the torrent is private - then don't announce it.
Utf-8 encoding is mandatory.

mp_db_query The mp_db_query extension allows performing of a query in another's peers database. If the peer does not have a local database an empty query result message will be returned. Queries can be done by info hash and/or torrent name. Currently the info hash must be empty or a valid 40 characters string. Wildcards are not allowed within the info hash. The name entry is not restricted. Furthermore is the number of query results limited.

A query message consists of a bencoded dictionary with two string entries: name and info hash.
The query result message consists of a bencoded dictionary with two string entries (name, info hash) and a dictionary named result. Entry result contains a string named comment and might contain two more list entries, named names and info hashs. These two lists have same number of entries.
The existence of the result entry marks this message as a response.


Examples in terms of libtorrent syntax

msg["info hash"] = "F3D13A0F05FC1ACCAF4FAE6F459307AA1437D770";
msg["name"] = "dump_torrent.exe";

msg["info hash"] = "";
msg["name"] = "*dump*";

x = msg["result"];
c = x["comment"];
ihl = x["info hashs"];
nl = x["names"];
tl = x["trackers"];

In the future you might be able to start a search for files and a possible result could be a list of torrents which include matching files. Basically, the functionality to be is not yet determined.
With the current experimental implementation you can search for torrent name for a given info hash or vice versa.
MP_peer_exchange The MooPolice peer exchange is request based. A peer can request a peer list with specific number entries from other peers. Messages are binary encoded except the peer list itself. There are three different message:
  1. [0] Peer list request
  2. [1] Peer list response
  3. [2] Have no peers
The first byte represents the message type. In case of a request the next 4 bytes represent a 32 bits unsigned integer number. This is the number of requested peers. It must be greater than zero.
In case of a have no peers response the message is only one byte long (type value 2).

If the message type byte's value is one the following bytes represent a bencoded list. Each list entry is a dictionary that consists of two entries. These entries are ip of type string and port of type integer. Entry ip can be a dotted numbers or a url. This address can be ip v4 or v6.

MooPolice itself will request 20 peers every 5 minutes.


Example in terms of libtorrent syntax

adr["ip"] = "10.10.11.12";
adr["port"] = 9045;

In case there is more than one pex extension available (i.e. ut_pex) only MooPolice's native pex extension MP_peer_exchange is used.
LT_chat This extension is based on the former libtorrent chat extension (therefore the name). A simple text message can be send to a peer via this extension.
A chat message consists of a bencoded dictionary which contains a single string entry named msg.


Example in terms of libtorrent syntax

msg["msg"] = "Moooo";


MassaRoddel, September 2008 - May 2013