Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
naim94a committed May 13, 2020
1 parent 346aa4b commit a6b9534
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 39 deletions.
39 changes: 12 additions & 27 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,16 @@ APIs should not be exposed directly to the internet, they are intended for inter

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

- Listing Torrents

This can be useful if you want to see which torrents are currently registered in any of the tracking modes.

`GET /t?offset=0&limit=1000&token=... HTTP/1.0`

Optional Parameters:
- `offset` - Offset of the torrent list to return. Default: 0.
- `limit` - Limit of torrents to output. Between 1 and 4096. Default 1000.

- Getting a torrent's stats
| Method | Route | Description |
| -- | -- | -- |
| `GET` | /t | list all tracked torrents. Possible query parameters are: <br /> _offset_ - The offset in the db where to start listing torrents from.<br />_limit_ - Maximum amount of records to retrieve (max. 1000). |
| `GET` | /t/_infohash_ | get information about a specific torrent: connected peers & stats |
| `DELETE` | /t/_infohash_ | drop a torrent from the database. |
| `POST` | /t/_infohash_ | add/flag/unflag torrent |

Allows collection of stats from active torrents.

`GET /t/<info_hash>?token=... HTTP/1.0`

This request will return information about the torrent, such as:
- if the torrent is flagged
- seeders & leechers
- times the torrent's download was completed

- Performing actions on torrents

`POST /t/<info_hash>?action=<action>&token=... HTTP/1.0`

Valid actions are: `flag`, `unflag`, `add` & `remove`.

`add` & `remove` are only valid for non-dynamic tracking modes.
The payload expected for adding a torrent can be empty, flagging or unflagging a torrent has the following payload:
```json
{
"is_flagged": false
}
```
43 changes: 31 additions & 12 deletions src/webserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,37 @@ use std::sync::Arc;
use warp::{filters, reply, reply::Reply, serve, Filter, Server};

fn view_root() -> impl Reply {
reply::html(concat!(
r#"<html>
<head>
<title>udpt/"#,
env!("CARGO_PKG_VERSION"),
r#"</title>
</head>
<body>
This is your <a href="https://github.com/naim94a/udpt">udpt</a> torrent tracker.
</body>
</html>"#
))
warp::http::Response::builder()
.header("Content-Type", "text/html; charset=utf-8")
.header("Server", concat!("udpt/", env!("CARGO_PKG_VERSION"), "; https://abda.nl/"))
.body(concat!(r#"<html>
<head>
<title>udpt server</title>
<style>
body {
background-color: #222;
color: #eee;
margin-left: auto;
margin-right: auto;
margin-top: 20%;
max-width: 750px;
}
a, a:active, a:visited {
color: lightpink;
}
</style>
</head>
<body>
<p>
This server is running <a style="font-weight: bold; font-size: large" href="https://github.com/naim94a/udpt"><code>udpt</code></a>, a <a href="https://en.wikipedia.org/wiki/BitTorrent_tracker" rel="nofollow" target="_blank">BitTorrent tracker</a> based on the <a href="https://en.wikipedia.org/wiki/User_Datagram_Protocol" rel="nofollow" target="_blank">UDP</a> protocol.
</p>
<div style="color: grey; font-size: small; border-top: 1px solid grey; width: 75%; max-width: 300px; margin-left: auto; margin-right: auto; text-align: center; padding-top: 5px">
udpt/"#, env!("CARGO_PKG_VERSION"), r#"<br />
<a href="https://naim94a.github.com/udpt/">docs</a> &middot; <a href="https://github.com/naim94a/udpt/issues">issues &amp; PRs</a> &middot; <a href="https://paypal.me/naim94a">donate</a>
</div>
</body>
</html>"#))
.unwrap()
}

#[derive(Deserialize, Debug)]
Expand Down
1 change: 1 addition & 0 deletions udpt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mode = "dynamic"
db_path = "database.json.bz2"
log_level = "trace"

[udp]
announce_interval = 120 # Two minutes
Expand Down

0 comments on commit a6b9534

Please sign in to comment.