Skip to content

Commit a6b9534

Browse files
committed
update docs
1 parent 346aa4b commit a6b9534

File tree

3 files changed

+44
-39
lines changed

3 files changed

+44
-39
lines changed

docs/src/api.md

+12-27
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,16 @@ APIs should not be exposed directly to the internet, they are intended for inter
99

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

12-
- Listing Torrents
13-
14-
This can be useful if you want to see which torrents are currently registered in any of the tracking modes.
15-
16-
`GET /t?offset=0&limit=1000&token=... HTTP/1.0`
17-
18-
Optional Parameters:
19-
- `offset` - Offset of the torrent list to return. Default: 0.
20-
- `limit` - Limit of torrents to output. Between 1 and 4096. Default 1000.
21-
22-
- Getting a torrent's stats
12+
| Method | Route | Description |
13+
| -- | -- | -- |
14+
| `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). |
15+
| `GET` | /t/_infohash_ | get information about a specific torrent: connected peers & stats |
16+
| `DELETE` | /t/_infohash_ | drop a torrent from the database. |
17+
| `POST` | /t/_infohash_ | add/flag/unflag torrent |
2318

24-
Allows collection of stats from active torrents.
25-
26-
`GET /t/<info_hash>?token=... HTTP/1.0`
27-
28-
This request will return information about the torrent, such as:
29-
- if the torrent is flagged
30-
- seeders & leechers
31-
- times the torrent's download was completed
32-
33-
- Performing actions on torrents
34-
35-
`POST /t/<info_hash>?action=<action>&token=... HTTP/1.0`
36-
37-
Valid actions are: `flag`, `unflag`, `add` & `remove`.
38-
39-
`add` & `remove` are only valid for non-dynamic tracking modes.
19+
The payload expected for adding a torrent can be empty, flagging or unflagging a torrent has the following payload:
20+
```json
21+
{
22+
"is_flagged": false
23+
}
24+
```

src/webserver.rs

+31-12
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,37 @@ use std::sync::Arc;
66
use warp::{filters, reply, reply::Reply, serve, Filter, Server};
77

88
fn view_root() -> impl Reply {
9-
reply::html(concat!(
10-
r#"<html>
11-
<head>
12-
<title>udpt/"#,
13-
env!("CARGO_PKG_VERSION"),
14-
r#"</title>
15-
</head>
16-
<body>
17-
This is your <a href="https://github.com/naim94a/udpt">udpt</a> torrent tracker.
18-
</body>
19-
</html>"#
20-
))
9+
warp::http::Response::builder()
10+
.header("Content-Type", "text/html; charset=utf-8")
11+
.header("Server", concat!("udpt/", env!("CARGO_PKG_VERSION"), "; https://abda.nl/"))
12+
.body(concat!(r#"<html>
13+
<head>
14+
<title>udpt server</title>
15+
<style>
16+
body {
17+
background-color: #222;
18+
color: #eee;
19+
margin-left: auto;
20+
margin-right: auto;
21+
margin-top: 20%;
22+
max-width: 750px;
23+
}
24+
a, a:active, a:visited {
25+
color: lightpink;
26+
}
27+
</style>
28+
</head>
29+
<body>
30+
<p>
31+
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.
32+
</p>
33+
<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">
34+
udpt/"#, env!("CARGO_PKG_VERSION"), r#"<br />
35+
<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>
36+
</div>
37+
</body>
38+
</html>"#))
39+
.unwrap()
2140
}
2241

2342
#[derive(Deserialize, Debug)]

udpt.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
mode = "dynamic"
22
db_path = "database.json.bz2"
3+
log_level = "trace"
34

45
[udp]
56
announce_interval = 120 # Two minutes

0 commit comments

Comments
 (0)