A multi-functional lightweight BitTorrent Tracker

Overview

Torrust-Axum Tracker

Test

Project Description

Torrust-Axum Tracker is a lightweight but incredibly powerful and feature-rich BitTorrent Tracker made using Rust.

Currently, it's being actively used at https://www.gbitt.info/ which as of current writing has 100 million torrent hashes loaded and hitting 5 million peers.

This project originated from Torrust Tracker code originally developed by Mick van Dijke, further developed by Power2All as alternative for OpenTracker and other tracker code available on GitHub.

Features

  • Multiple UDP server and HTTP(S) server blocks for socket binding possibilities
  • Full IPv4 and IPv6 support for both UDP and HTTP(S)
  • Built-in API on a separate port in HTTP
  • Toggle maintenance mode through API and WebGUI
  • Persistence saving supported using SQLite3, MySQL or PostgresSQL database
  • Customize table and database names in the configuration file for persistence
  • Whitelist system, which can be used to make the tracker private
  • Blacklist system, to block and ban hashes
  • Web Interface (through API) to control the tracker software
  • Torrent key support, for private tracking support
  • Dockerfile to build an image for Docker, and pushed to Docker Hub

Implemented BEPs

  • BEP 3: The BitTorrent Protocol
  • BEP 7: IPv6 Support
  • BEP 15: UDP Tracker Protocol for BitTorrent
  • BEP 23: Tracker Returns Compact Peer Lists
  • BEP 41: UDP Tracker Protocol Extensions
  • BEP 48: Tracker Protocol Extension: Scrape

Getting Started

You can get the latest binaries from releases or follow the install from scratch instructions below.

Install From Scratch

  1. Clone the repository:
git clone https://github.com/Power2All/torrust-axum.git
cd torrust-axum
  1. Build the source code using Rust (make sure you have installed rustup with stable branch)

Using build script

chmod +x build.sh && ./build.sh

Manual Building (/webgui/index.htm needs to be modified)

cargo build --release

Usage

  • Running the code will create a config.toml file when it doesn't exist yet. The configuration will be filled with default values, and will use SQLite3 in memory as default persistence. Persistence is turned OFF by default, so you need to activate that manually:
./target/release/torrust-axum
  • Modify the newly created config.toml file according to your liking. (ToDo: Create extended documentation)
log_level = "info"
log_console_interval = 60
statistics_enabled = true
db_driver = "SQLite3"
db_path = "sqlite://:memory:"
persistence = false
persistence_interval = 60
api_key = "MyAccessToken"
whitelist = false
blacklist = false
keys = true
keys_cleanup_interval = 10
maintenance_mode_enabled = false
interval = 1800
interval_minimum = 1800
interval_cleanup = 900
peer_timeout = 2700
peers_returned = 200

[[udp_server]]
enabled = true
bind_address = "127.0.0.1:6969"

[[http_server]]
enabled = true
bind_address = "127.0.0.1:6969"
ssl = false
ssl_key = ""
ssl_cert = ""

[[api_server]]
enabled = true
bind_address = "127.0.0.1:8080"
ssl = false
ssl_key = ""
ssl_cert = ""

[db_structure]
db_torrents = "torrents"
table_torrents_info_hash = "info_hash"
table_torrents_completed = "completed"
db_whitelist = "whitelist"
table_whitelist_info_hash = "info_hash"
db_blacklist = "blacklist"
table_blacklist_info_hash = "info_hash"
db_keys = "keys"
table_keys_hash = "hash"
table_keys_timeout = "timeout"
  • Run the torrust-axum again after finishing the configuration:
./target/release/torrust-axum

Tracker URL

Your tracker announce URL will be the following, depending on what blocks you have enabled:

  • udp://127.0.0.1:6969/announce
  • http://127.0.0.1:6969/announce
  • https://127.0.0.1:6969/announce

When Keys system is enabled, following announce URLs should be used:

  • udp://127.0.0.1:6969/announce/1234567890123456789012345678901234567890
  • http://127.0.0.1:6969/announce/1234567890123456789012345678901234567890
  • https://127.0.0.1:6969/announce/1234567890123456789012345678901234567890

Built-in API

The following URLs are available if you have enabled the API block. Also, the following URL is enabled for the Web Interface: http(s)://127.0.0.1:8080/webgui/ Replace [TOKENID] with the token set in the configuration file. Replace [TORRENT_HASH] with a hex 40 character info_hash. Also depends on if you have HTTP and/or HTTPS enabled. If an error occurred for whatever reason, the status key will not contain "ok", but the reason:

{
  "status":"FAILURE REASON"
}

Statistics

GET http(s)://127.0.0.1:8080/api/stats?token=[TOKENID]

This will show statistics of the tracker in JSON format.

{
  "started":1234567890,
  "timestamp_run_save":1234567890,
  "timestamp_run_timeout":1234567890,
  "timestamp_run_console":1234567890,
  "torrents":0,
  "torrents_updates":0,
  "torrents_shadow":0,
  "maintenance_mode":false,
  "seeds":0,
  "peers":0,
  "completed":0,
  "whitelist_enabled":true,
  "whitelist":0,
  "blacklist_enabled":true,
  "blacklist":0,
  "keys_enabled":true,
  "keys":0,
  "tcp4_connections_handled":0,
  "tcp4_api_handled":0,
  "tcp4_announces_handled":0,
  "tcp4_scrapes_handled":0,
  "tcp6_connections_handled":0,
  "tcp6_api_handled":0,
  "tcp6_announces_handled":0,
  "tcp6_scrapes_handled":0,
  "udp4_connections_handled":0,
  "udp4_announces_handled":0,
  "udp4_scrapes_handled":0,
  "udp6_connections_handled":0,
  "udp6_announces_handled":0,
  "udp6_scrapes_handled":0
}

Torrents

GET http(s)://127.0.0.1:8080/api/torrent/[TORRENT_HASH]?token=[TOKENID]

This will show the content of the torrent, including peers.

{
  "info_hash":"1234567890123456789012345678901234567890",
  "completed":0,
  "seeders":1,
  "leechers":0,
  "peers": [
    [
      {
        "client":"",
        "id":"1234567890123456789012345678901234567890"
      },
      {
        "downloaded":0,
        "event":"Started",
        "ip":"127.0.0.1:1234",
        "left":0,
        "updated":0,
        "uploaded":0
      }
    ]
  ]
}

DELETE http(s)://127.0.0.1:8080/api/torrent/[TORRENT_HASH]?token=[TOKENID]

This will remove the torrent and it's peers from the memory.

{
  "status":"ok"
}

Whitelist

GET http(s)://127.0.0.1:8080/api/whitelist?token=[TOKENID]

This will get the whole whitelist in list format.

[
  "1234567890123456789012345678901234567890",
  "0987654321098765432109876543210987654321"
]

GET http(s)://127.0.0.1:8080/api/whitelist/[TORRENT_HASH]?token=[TOKENID]

This will check if an info_hash exists in the whitelist, and returns if true.

{
  "status":"ok"
}

POST http(s)://127.0.0.1:8080/api/whitelist/[TORRENT_HASH]?token=[TOKENID]

This will insert an info_hash in the whitelist, and returns status if successful.

{
  "status":"ok"
}

DELETE http(s)://127.0.0.1:8080/api/whitelist/[TORRENT_HASH]?token=[TOKENID]

This will remove an info_hash from the whitelist, and returns status if successful or failure reason.

{
  "status":"ok"
}

Blacklist

GET http(s)://127.0.0.1:8080/api/blacklist?token=[TOKENID]

This will get the whole blacklist in list format.

[
  "1234567890123456789012345678901234567890",
  "0987654321098765432109876543210987654321"
]

GET http(s)://127.0.0.1:8080/api/blacklist/[TORRENT_HASH]?token=[TOKENID]

This will check if an info_hash exists in the blacklist, and returns if true.

{
  "status":"ok"
}

POST http(s)://127.0.0.1:8080/api/blacklist/[TORRENT_HASH]?token=[TOKENID]

This will insert an info_hash in the blacklist, and returns status if successful.

{
  "status":"ok"
}

DELETE http(s)://127.0.0.1:8080/api/blacklist/[TORRENT_HASH]?token=[TOKENID]

This will remove an info_hash from the blacklist, and returns status if successful or failure reason.

{
  "status":"ok"
}

Keys

GET http(s)://127.0.0.1:8080/api/keys?token=[TOKENID]

This will get the whole keys in list format. 1st value is the key itself, 2nd value is the timestamp in UNIX format (seconds).

[
  [
    "1234567890123456789012345678901234567890",
    "1234567890"
  ]
]

GET http(s)://127.0.0.1:8080/api/keys/[KEY]?token=[TOKENID]

This will check if a key exists in the keys list, and returns if true.

{
  "status":"ok"
}

POST http(s)://127.0.0.1:8080/api/keys/[KEY]/[TIMEOUT]?token=[TOKENID]

This will insert or update a key in the keys list, and returns status if successful. The [TIMEOUT] is a number in seconds. Make this 0 to keep the key permanent.

{
  "status":"ok"
}

DELETE http(s)://127.0.0.1:8080/api/keys/[KEY]?token=[TOKENID]

This will remove a key from the keys list, and returns status if successful or failure reason.

{
  "status":"ok"
}

GET http(s)://127.0.0.1:8080/api/maintenance/enable?token=[TOKENID]

This will enable the maintenance mode.

{
  "status":"ok"
}

GET http(s)://127.0.0.1:8080/api/maintenance/disable?token=[TOKENID]

This will disable the maintenance mode.

{
  "status":"ok"
}

ChangeLog

v3.1.2

  • Bumped library versions.
  • Added a Code of Conduct file, as some open source projects need this.
  • Added a Maintenance toggle function to API and WebGUI.
  • Configuration file is not generated when it doesn't exist, or has invalid data, unless forced with a '--create-config' argument.
  • Fixed various small bugs.

v3.1.1

  • Bumped library versions.
  • Database for SQLite3, MySQL and PostgreSQL now works properly with all the tables, and will be used if enabled.
  • UDP had a problem in IPv4, fixed the code for correctly parsing byte array.
  • Cleanup and refactoring of some redundant code.
  • Added some small checks where needed to prevent errors.

v3.1.0

  • Whitelist System: You can enable this to only allow torrent hashes to be used you specify in the database, or add them through the API.
  • Blacklist System: You can enable this to disallow torrent hashes to be used you specify in the database, or add them through the API.
  • Keys System: You can enable this to only allow tracking when an activated "key" hash (same as an info_hash, 20 bytes or 40 characters hex) is given. Keys with a timeout of zero "0" will be permanent and won't be purged by the cleanup.
  • WebGUI: The API has an available web interface, which can be accessed through https://your.api:8080/webgui/ and giving the correct API Key, which you configure in the configuration file.
  • Customizable database structure can be given in the configuration file.
  • The system is also now available through Docker Hub at https://hub.docker.com/r/power2all/torrust-axum

v3.0.1

  • Bugfixes
  • SQLite3 support added
  • MySQL support added
  • PostgresSQL support added

v3.0.0

Initial version of Torrust-Axum.

Credits

This Torrust-Tracker was a joint effort by Nautilus Cyberneering GmbH, Dutch Bits and Power2All. Also thanks to Naim A. and greatest-ape for some parts in the Torrust-Tracker code. This project (Torrust-Axum) is built from scratch by Power2All.

Comments
  • Defragmentation of BTreeMaps

    Defragmentation of BTreeMaps

    I noticed a high memory usage after a while, and this is because the BTreeMap get fragmented after a while. Going to work on a custom block system for the BTreeMap, so that I can make a thread that will clean up the fragmentation every often, without locking up the system too much. A proof of concept will be worked on for version 3.1.2

    enhancement 
    opened by Power2All 4
  • Broken UDP IPv4 handling

    Broken UDP IPv4 handling

    I noticed UDP IPv4 is not working as expected. Probably found the typo, but will be testing first before I release a 3.1.1, also trying to fix the duplicate code to improve readability.

    bug 
    opened by Power2All 1
  • Refactoring

    Refactoring

    For version v3.1.1 I will be doing some refactoring of code. Lot's of duplicate blocks need to be solved into their own little functions, but I was lazy with writing so I noticed :)

    enhancement 
    opened by Power2All 1
  • Improving the dead peers scanner

    Improving the dead peers scanner

    As title says. Need to divide up the torrents metadata and the peer data in their own separate btreemap. This would increase the scanning of dead peers, since torrents that are not "alive" with peers, will not need to be scanned anyway, but only retain their completed downloaded number.

    enhancement 
    opened by Power2All 1
  • v3.1.0 Release

    v3.1.0 Release

    New Torrust-Axum release version done. This version is production ready, and has some exploit fixes applied to it.

    The new features for this version are:

    • Whitelist System: You can enable this to only allow torrent hashes to be used you specify in the database, or add them through the API.
    • Blacklist System: You can enable this to disallow torrent hashes to be used you specify in the database, or add them through the API.
    • Keys System: You can enable this to only allow tracking when a activated "key" hash (same as an info_hash, 20 bytes or 40 characters hex) is given. Keys with a timeout of zero "0" will be permanent and won't be purged by the cleanup.
    • WebGUI: The API has an available web interface, which can be accessed through https://your.api:8080/webgui/ and giving the correct API Key, which you configurate in the configuration file.
    • Customizable database structure can be given in the configuration file.
    • The system is also now available through Docker Hub at https://hub.docker.com/r/power2all/torrust-axum
    opened by Power2All 0
  • Bump axum-core from 0.2.7 to 0.2.8

    Bump axum-core from 0.2.7 to 0.2.8

    Bumps axum-core from 0.2.7 to 0.2.8.

    Release notes

    Sourced from axum-core's releases.

    axum-core - v0.2.8

    Security

    • breaking: Added default limit to how much data Bytes::from_request will consume. Previously it would attempt to consume the entire request body without checking its length. This meant if a malicious peer sent an large (or infinite) request body your server might run out of memory and crash.

      The default limit is at 2 MB and can be disabled by adding the new DefaultBodyLimit::disable() middleware. See its documentation for more details.

      This also applies to String which used Bytes::from_request internally.

      (#1346)

    #1346: tokio-rs/axum#1346

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • [v3.2.0] Adding a conversion code, to switch things between database engines

    [v3.2.0] Adding a conversion code, to switch things between database engines

    Just some simple code is needed, to be able to switch from MySQL, SQLite3 or PostgreSQL to any of the other engines, while keeping the data preserved.

    enhancement 
    opened by Power2All 1
  • [v3.2.0] Adding a plugin for handling user accounts

    [v3.2.0] Adding a plugin for handling user accounts

    A simple module that will allow a torrent announcement to have a extra variable, that can be linked with a user account. We will then "track" the user it's uploaded and downloaded traffic.

    enhancement 
    opened by Power2All 0
  • [v3.2.0] Adding support for

    [v3.2.0] Adding support for "plugins"

    Working out the first iteration of a plugin system. A new 'plugin' folder will be available, where you could put in your own 3rd party code for the tracker. More documentation will be written how this could be used for your preferences, and would be helpful for trackers used with private sites and such.

    enhancement 
    opened by Power2All 0
  • [v3.2.0] Adding memory efficiency

    [v3.2.0] Adding memory efficiency

    Using some crates which help improving memory usage. Noticed most of the memory leakage, comes from the pushing of data to SQL for persistency. Also, some other improvements could be done with the btreemaps, using 3rd party crates.

    enhancement 
    opened by Power2All 0
Releases(v3.1.2)
  • v3.1.2(Dec 22, 2022)

  • v3.1.1(Sep 21, 2022)

    Fixed a lot of problems I found out after v3.1.0 release. The fixes are:

    • Database for SQLite3, MySQL and PostgreSQL now works properly with all the tables, and will be used if enabled.
    • UDP had a problem in IPv4, fixed the code for correctly parsing byte array.
    • Cleanup and refactoring of some redundant code.
    • Added some small checks where needed to prevent errors.
    Source code(tar.gz)
    Source code(zip)
    torrust-axum-v3.1.1.zip(9.86 MB)
  • v3.1.0(Sep 19, 2022)

    New Torrust-Axum release version done. This version is production ready, and has some exploit fixes applied to it.

    The new features for this version are:

    • Whitelist System: You can enable this to only allow torrent hashes to be used you specify in the database, or add them through the API.
    • Blacklist System: You can enable this to disallow torrent hashes to be used you specify in the database, or add them through the API.
    • Keys System: You can enable this to only allow tracking when a activated "key" hash (same as an info_hash, 20 bytes or 40 characters hex) is given. Keys with a timeout of zero "0" will be permanent and won't be purged by the cleanup.
    • WebGUI: The API has an available web interface, which can be accessed through https://your.api:8080/webgui/ and giving the correct API Key, which you configurate in the configuration file.
    • Customizable database structure can be given in the configuration file.
    • The system is also now available through Docker Hub at https://hub.docker.com/r/power2all/torrust-axum
    Source code(tar.gz)
    Source code(zip)
    torrust-axum-v3.1.0.zip(9.85 MB)
  • v3.0.1(Jul 27, 2022)

    Torrust-Axum is now released as a working project. It's production ready, as far as I'm using it right now.

    Torrust-Axum can run with or without a persistency database as alternative for OpenTracker and other public tracker software. Private Tracking using a Whitelist and Blacklist will be implemented for version 3.1.0

    Torrust-Axum supports:

    • SQLite3
    • MySQL
    • PostgreSQL
    Source code(tar.gz)
    Source code(zip)
    torrust-axum-v3.0.1.zip(8.22 MB)
  • v3.0.0(Jul 26, 2022)

    This is a simple release with 2 binaries pre-compiled (Release and Debug), with a MySQL structure you can use. Simply, start the binary ones to make it generate a default config.toml file, modify it to your needs, and run the system. You don't need MySQL, by disabling persistency, but you can use MySQL for persistency saving.

    A more enhanced README will be made later, SQLite3 and PostgreSQL support will be also added on a new release version. For now, you can use this as a alternative to OpenTracker.

    A actively used version of Torrust-Axum, can be found at https://www.gbitt.info/

    Source code(tar.gz)
    Source code(zip)
    torrust-axum.zip(8.78 MB)
Owner
Jasper
PHP/GO/Rust Programmer, DJ (Trance, Hardcore, Gabber, Hardstyle), Producer, Dance Dance Revolution player, Gamer, DnD player, Airsoft player, Asian fan, etc..
Jasper
A BitTorrent V1 engine library for Rust (and currently Linux)

cratetorrent Cratetorrent is a Rust crate implementing the BitTorrent version 1 protocol. It can be used as a library and also provides a simple examp

null 401 Dec 28, 2022
BitTorrent peer ID registry/parser/(soon) encoder for Rust

BitTorrent peer ID registry/parser/(soon) encoder By convention, BitTorrent clients identify themselves and their versions in peer IDs they send to tr

TORRENTDYNE 3 Oct 16, 2023
Privaxy Next generation tracker and advertisement blocker

Privaxy is a MITM HTTP(s) proxy that sits in between HTTP(s) talking applications, such as a web browser and HTTP servers, such as those serving websites.

Pierre Barre 752 Jan 7, 2023
A multi-protocol network relay

A multi-protocol network relay

zephyr 43 Dec 13, 2022
An end-to-end encrypted, anonymous IP-hiding, decentralized, audio/video/file sharing/offline messaging multi-device platform built for both communications and application security and performance.

An end-to-end encrypted, anonymous IP-hiding, decentralized, audio/video/file sharing/offline messaging multi-device platform built for both communications and application security and performance.

null 2 Apr 27, 2022
A set of cryptographic primitives for building a multi-hop Proxy Re-encryption scheme, known as Transform Encryption.

recrypt A pure-Rust library that implements a set of cryptographic primitives for building a multi-hop Proxy Re-encryption scheme, known as Transform

IronCore Labs 122 Dec 30, 2022
A tool for defining and running multi-container Docker applications

Ikki Ikki is a tool for defining and running multi-container Docker applications. It is similar to Docker Compose but comes with some differences. Goa

Kirill Vasiltsov 39 Dec 21, 2022
A multi-connection TCP reverse proxy server and client.

tprox A multi-connection TCP reverse proxy. The tprox server is able to proxy multiple incoming connections to the tprox client over a single TCP conn

Mohammed Ajmal Siddiqui 4 Sep 21, 2022
A multi-targets ping tool and library, which supports 10,000 packets/second, accurate latency

mping-rs a multi-targets ping tool, which supports 10,000 packets/second, accurate latency. 一个高频ping工具,支持多个目标。 正常的ping一般用来做探测工具,mping还可以用来做压测工具。 Go版本:

smallnest 25 Oct 29, 2023
A prettier lightweight colored ping utility written in Rust

rustyping A prettier lightweight colored ping utility written in Rust. Installation There are three installation options: From the releases page From

K4YT3X 29 Dec 31, 2022
A fast, stable, efficient, and lightweight intranet penetration, port forwarding tool supports multiple connections, cascading proxy, and transmission encryption

A fast, stable, efficient, and lightweight intranet penetration, port forwarding tool supports multiple connections, cascading proxy, and transmission encryption

editso 1.3k Dec 30, 2022
Lightweight p2p library. Support build robust stable connection on p2p/distributed network.

Chamomile Build a robust stable connection on p2p network features Support build a robust stable connection between two peers on the p2p network. Supp

CympleTech 94 Jan 6, 2023
RCProxy - a lightweight, fast but powerful Redis Cluster Proxy written in Rust

RCProxy - a lightweight, fast but powerful Redis Cluster Proxy written in Rust

Cris Liao 16 Dec 4, 2022
Lightweight proxy that allows redirect HTTP(S) traffic through a proxy.

Proxyswarm Proxyswarm is a lightweight proxy that allows redirect HTTP(S) traffic through a proxy. WARNING: This app isn't recomended for download lar

Jorge Alejandro Jimenez Luna 4 Apr 16, 2022
A lightweight Rust reverse proxy.

Brachyura A reverse proxy, which I am primarily using as a Rust / Hyper learning project. I utilize Nginx as part of my home lab providing reverse pro

William Howard 8 Jan 8, 2023
A library-first, lightweight, high-performance, cloud-native supported API gateway🪐 by RUST

Preview version, will not guarantee the stability of the API! Do NOT use in production environment! A library-first, lightweight, high-performance, cl

Ideal World 4 May 7, 2023
Hopper - Fast, configurable, lightweight Reverse Proxy for Minecraft

Hopper Hopper is a lightweight reverse proxy for minecraft. It allows you to connect multiple servers under the same IP and port, with additional func

Pietro 174 Jun 29, 2023
A high-performance, lightweight, and cross-platform QUIC library

TQUIC English | 中文 TQUIC is a high-performance, lightweight, and cross-platform library for the IETF QUIC protocol. Advantages High performance: TQUIC

Tencent 11 Oct 27, 2023
A lightweight but incredibly powerful and feature-rich BitTorrent tracker. Supports UDP + HTTP(S) and a private tracker mode.

Torrust Tracker Project Description Torrust Tracker is a lightweight but incredibly powerful and feature-rich BitTorrent tracker made using Rust. Feat

Torrust 162 Dec 31, 2022
High-performance BitTorrent tracker compatible with UNIT3D tracker software

UNIT3D-Announce High-performance backend BitTorrent tracker compatible with UNIT3D tracker software. Usage # Clone this repository $ git clone https:/

HDInnovations 4 Feb 6, 2023