UDPT

UDPT is a lightweight torrent tracker that uses the UDP protocol for tracking and fully implements BEP-15. This project was developed with security & simplicity in mind, so it shouldn't be difficult to get a server started.

Unlike most HTTP torrent-trackers, you can save about 50% bandwidth using a UDP tracker.

Features

  • UDP tracking protocol
  • Simple TOML configuration
  • HTTP REST API
  • Logging
  • Choice to run in static or dynamic modes
  • Blacklist torrents using the REST API
  • Can be built/run on many platforms
  • (Re)written in Rust

Licenses

UDPT available under the MIT license.

About

Originally written in C++ by @naim94a in 2012 for fun.

Building UDPT

If you're reading this, you're probably interested in using UDPT - so first, thanks for your interest!

UDPT used to be harder to build, especially on Windows due to it's dependencies. Thanks to Rust, it's much simpler now.

Required tools

  • Git - Version Control
  • Rust - Compiler toolchain & Package Manager (cargo)

Getting the sources

git clone https://github.com/naim94a/udpt.git

If you prefer to just download the code, you can get the latest codebase here.

Building

This step will download all required dependencies (from crates.io) and build them as well.

Building should always be done with the latest Rust compiler.

cd udpt
cargo build --release

Once cargo is done building, udpt will be built at target/release/udpt.

Running Tests

UDPT comes with unit tests, they can be run with the following command:

cargo test

If a build or test fails, please submit Issues to UDPT's issue tracker.

Configuring UDPT

UDPT's configuration is a simple TOML file.

Configuration

At the root level, the following options are configurable: mode - Specifies which mode the tracker will operate in. Values can be static, dynamic or private.

Root Level

  • mode - Required. Possbile Values: private, static or dynamic.
  • log_level - Default: info. Possible Values: off, error, warning, info, debug, trace.
  • db_path - Database path. If not set, database will be volatile.
  • cleanup_interval - Default: 600. Interval to run cleanup in seconds. Cleanup also saves the Database.

[udp] section

This section must exist.

  • bind_address - Required. This is where the UDP port will bind to. Example: 0.0.0.0:6969.
  • announce_interval - Required. Sets the announce_interval that will be sent to peers (in seconds).

[http] section

This section is optional.

  • bind_address - Required (if section exists). The HTTP REST API will be bound to this address. It's best not to expose this address publically. Example: 127.0.0.1:1234.

[http.access_tokens] section

Section is required if [http] section exists.

In this section you can make up keys that would be user ids, and values that would be their access token. If this section is empty, the REST API will not be very useful.

Sample Configuration

mode = "dynamic"
db_path = "database.json.bz2"

[udp]
announce_interval = 120         # Two minutes
bind_address = "0.0.0.0:1212"

[http]
bind_address = "127.0.0.1:1212"

[http.access_tokens]
someone = "MyAccessToken"

Tracking Modes

UDPT currently supports Static & Dynamic tracking modes. Private tracking is planned, but isn't yet completely implemented.

Dynamic Mode

In this mode a tracker allows any torrent, even if unknown to be tracked. Trackers that run in this mode usually don't know about the contents of the tracked torrent. In addition, trackers don't usually know anything about the peers.

UDPT supports dynamic mode, and allows blacklisting torrents to avoid copyright infringement. Torrents can be blacklisted (or "flagged") using the REST API.

Static Mode

In static mode, anyone can use the tracker like in dynamic mode. Except that torrents must be registered ahead of time.

UDPT supports static mode, and torrents can be added or removed using the REST API.

Private Mode

Private tracking requires all peers to be authenticated. Some implementations require torrents to be registered, and some do not. This mode can be either static or dynamic with peer authentication.

UDPT doesn't currently implement private mode, although there are plans to implement private tracking in the future.

Usage

At the moment, udpt doesn't have many options. Once you've modified the configuration file, you could start udpt:

udpt -c configuration.toml 

REST API

The REST API can help you manage UDPT with your own scripts.

Notice: The API should only be used in trusted networks. APIs should not be exposed directly to the internet, they are intended for internal use only.

Endpoints

All Endpoints require a authorization token which must be set in the configuration before running the tracker.

MethodRouteDescription
GET/tlist all tracked torrents. Possible query parameters are:
offset - The offset in the db where to start listing torrents from.
limit - Maximum amount of records to retrieve (max. 1000).
GET/t/infohashget information about a specific torrent: connected peers & stats
DELETE/t/infohashdrop a torrent from the database.
POST/t/infohashadd/flag/unflag torrent

The payload expected for adding a torrent can be empty, flagging or unflagging a torrent has the following payload:

{
    "is_flagged": false
}

Examples

Listing all tracked torrents

$ curl http://127.0.0.1:1212/t/?token=MyAccessToken
[{"info_hash":"1234567890123456789012345678901234567890","is_flagged":true,"completed":0,"seeders":0,"leechers":0}]

Getting information for a specific torrent

$ curl http://127.0.0.1:1212/t/1234567890123456789012345678901234567890?token=MyAccessToken
{"info_hash":"1234567890123456789012345678901234567890","is_flagged":false,"completed":0,"seeders":0,"leechers":1,"peers":[[{"id":"2d7142343235302d3458295942396f5334af686b","client":"qBittorrent"},{"ip":"192.168.1.6:52391","uploaded":0,"downloaded":0,"left":0,"event":"Started","updated":672}]]}

Adding a torrent (non-dynamic trackers) or Unflagging a torrent:

$ curl -X POST http://127.0.0.1:1212/t/1234567890123456789012345678901234567890?token=MyAccessToken -d "{\"is_flagged\": false}" -H "Content-Type: application/json"
{"status":"ok"}

Removing a torrent:

$ curl -X DELETE http://127.0.0.1:1212/t/1234567890123456789012345678901234567890?token=MyAccessToken
{"status":"ok"}

Flagging a torrent:

$ curl -X POST http://127.0.0.1:1212/t/1234567890123456789012345678901234567890?token=MyAccessToken -d "{\"is_flagged\": true}" -H "Content-Type: application/json"
{"info_hash":"1234567890123456789012345678901234567890","is_flagged":true,"completed":0,"seeders":0,"leechers":0,"peers":[]}