Power2All / torrust-actix

A multi-functional lightweight BitTorrent Tracker
MIT License
89 stars 6 forks source link
axum bittorrent bittorrent-tracker http p2p peer-to-peer rust server torrent torrent-indexer tracker udp

Torrust-Actix Tracker

Test

Project Description

Torrust-Actix 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 200+ 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

Implemented BEPs

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-actix.git
    cd torrust-actix
  2. 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

[[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" db_users = "users" table_users_uuid = "uuid" table_users_key = "key" table_users_uploaded = "uploaded" table_users_downloaded = "downloaded" table_users_completed = "completed" table_users_updated = "updated" table_users_active = "active"


* Run the torrust-actix again after finishing the configuration:
```bash
./target/release/torrust-actix

Tracker URL

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

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

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

Users

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

This will return all the users in an array, including which torrents are being used actively by the user.

[
  {
    "uuid": "cbeca840-e9f7-44d5-a1e4-51e9aef864a7",
    "key": "1234567890123456789012345678901234567890",
    "uploaded": 0,
    "downloaded": 0,
    "completed": 0,
    "updated": 1686302997,
    "active": 1,
    "torrents_active": [
      [
        "1234567890123456789012345678901234567890",
        1686302997
      ]
    ]
  }
]

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

This will return the user containing hashed key (not the uuid) in an array, including which torrents are being used actively by the user.

{
  "uuid":"cbeca840-e9f7-44d5-a1e4-51e9aef864a7",
  "key":"1234567890123456789012345678901234567890",
  "uploaded":0,
  "downloaded":0,
  "completed":0,
  "updated":1686302997,
  "active":1,
  "torrents_active":[
    [
      "1234567890123456789012345678901234567890",
      1686302997
    ]
  ]
}

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

This will insert a user in the user memory database, and returns status if successful. Body data must be in valid JSON as shown below, otherwise it will return a error.

Send:

{
  "uuid":"cbeca840-e9f7-44d5-a1e4-51e9aef864a7",
  "key":"1234567890123456789012345678901234567890",
  "uploaded":0,
  "downloaded":0,
  "completed":0,
  "updated":1686302997,
  "active":1
}

Response:

{
  "status":"ok"
}

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

This will remove the user from the memory.

{
  "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.2.1

v3.2.0

v3.1.2

v3.1.1

v3.1.0

v3.0.1

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-Actix) is built from scratch by Power2All.