Skip to content

Commit 49c0f43

Browse files
committed
Merge #1081: Extract console clients into a new package
3398024 fix: tracker checker execution in CI (Jose Celano) 3267bc7 fix: add missing package in deployment workflow (Jose Celano) e966ae4 refactor!: remove tracker console client from tracker lib client (Jose Celano) 9d81624 feat: extract console clients into a new package (Jose Celano) Pull request description: Extract console clients into a new package. Console clients will be available in a new independent crate `torrust-tracker-client`. ACKs for top commit: josecelano: ACK 3398024 Tree-SHA512: 80237020c37614c4022fd8d38729ee7550692f72201a621c7232d275584ce8ebc614d2de4e38e8c458edfcb8277cf231c025a279d5c054fab6d1927cc5137e76
2 parents 5ce46ed + 3398024 commit 49c0f43

File tree

37 files changed

+308
-43
lines changed

37 files changed

+308
-43
lines changed

.github/workflows/deployment.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ jobs:
5555
env:
5656
CARGO_REGISTRY_TOKEN: "${{ secrets.TORRUST_UPDATE_CARGO_REGISTRY_TOKEN }}"
5757
run: |
58+
cargo publish -p bittorrent-tracker-client
59+
cargo publish -p torrust-tracker
60+
cargo publish -p torrust-tracker-client
61+
cargo publish -p torrust-tracker-clock
62+
cargo publish -p torrust-tracker-configuration
5863
cargo publish -p torrust-tracker-contrib-bencode
5964
cargo publish -p torrust-tracker-located-error
6065
cargo publish -p torrust-tracker-primitives
61-
cargo publish -p torrust-tracker-clock
62-
cargo publish -p torrust-tracker-configuration
63-
cargo publish -p torrust-tracker-torrent-repository
6466
cargo publish -p torrust-tracker-test-helpers
65-
cargo publish -p torrust-tracker
67+
cargo publish -p torrust-tracker-torrent-repository

Cargo.lock

Lines changed: 25 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ torrust-tracker-test-helpers = { version = "3.0.0-develop", path = "packages/tes
9494

9595
[workspace]
9696
members = [
97+
"console/tracker-client",
9798
"contrib/bencode",
9899
"packages/configuration",
99100
"packages/located-error",

console/tracker-client/Cargo.toml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[package]
2+
description = "A collection of console clients to make requests to BitTorrent trackers."
3+
keywords = ["bittorrent", "client", "tracker"]
4+
license = "LGPL-3.0"
5+
name = "torrust-tracker-client"
6+
readme = "README.md"
7+
8+
authors.workspace = true
9+
documentation.workspace = true
10+
edition.workspace = true
11+
homepage.workspace = true
12+
publish.workspace = true
13+
repository.workspace = true
14+
rust-version.workspace = true
15+
version.workspace = true
16+
17+
[dependencies]
18+
anyhow = "1"
19+
aquatic_udp_protocol = "0"
20+
bittorrent-primitives = "0.1.0"
21+
bittorrent-tracker-client = { version = "3.0.0-develop", path = "../../packages/tracker-client" }
22+
clap = { version = "4", features = ["derive", "env"] }
23+
futures = "0"
24+
hex-literal = "0"
25+
hyper = "1"
26+
reqwest = { version = "0", features = ["json"] }
27+
serde = { version = "1", features = ["derive"] }
28+
serde_bencode = "0"
29+
serde_bytes = "0"
30+
serde_json = { version = "1", features = ["preserve_order"] }
31+
thiserror = "1"
32+
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread", "signal", "sync"] }
33+
torrust-tracker-configuration = { version = "3.0.0-develop", path = "../../packages/configuration" }
34+
tracing = "0"
35+
tracing-subscriber = { version = "0", features = ["json"] }
36+
url = { version = "2", features = ["serde"] }
37+
38+
[package.metadata.cargo-machete]
39+
ignored = ["serde_bytes"]

console/tracker-client/README.md

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
# Torrust Tracker Client
2+
3+
A collection of console clients to make requests to BitTorrent trackers.
4+
5+
> **Disclaimer**: This project is actively under development. We’re currently extracting and refining common functionality from the[Torrust Tracker](https://github.com/torrust/torrust-tracker) to make it available to the BitTorrent community in Rust. While these tools are functional, they are not yet ready for use in production or third-party projects.
6+
7+
There are currently three console clients available:
8+
9+
- UDP Client
10+
- HTTP Client
11+
- Tracker Checker
12+
13+
> **Notice**: [Console apps are planned to be merge into a single tracker client in the short-term](https://github.com/torrust/torrust-tracker/discussions/660).
14+
15+
## UDP Client
16+
17+
`Announce` request:
18+
19+
```text
20+
cargo run --bin udp_tracker_client announce udp://127.0.0.1:6969 9c38422213e30bff212b30c360d26f9a02136422 | jq
21+
```
22+
23+
`Announce` response:
24+
25+
```json
26+
{
27+
"AnnounceIpv4": {
28+
"transaction_id": -888840697,
29+
"announce_interval": 120,
30+
"leechers": 0,
31+
"seeders": 1,
32+
"peers": []
33+
}
34+
}
35+
```
36+
37+
`Scrape` request:
38+
39+
```text
40+
cargo run --bin udp_tracker_client scrape udp://127.0.0.1:6969 9c38422213e30bff212b30c360d26f9a02136422 | jq
41+
```
42+
43+
`Scrape` response:
44+
45+
```json
46+
{
47+
"Scrape": {
48+
"transaction_id": -888840697,
49+
"torrent_stats": [
50+
{
51+
"seeders": 1,
52+
"completed": 0,
53+
"leechers": 0
54+
}
55+
]
56+
}
57+
}
58+
```
59+
60+
## HTTP Client
61+
62+
`Announce` request:
63+
64+
```text
65+
cargo run --bin http_tracker_client announce http://127.0.0.1:7070 9c38422213e30bff212b30c360d26f9a02136422 | jq
66+
```
67+
68+
`Announce` response:
69+
70+
```json
71+
{
72+
"complete": 1,
73+
"incomplete": 0,
74+
"interval": 120,
75+
"min interval": 120,
76+
"peers": []
77+
}
78+
```
79+
80+
`Scrape` request:
81+
82+
```text
83+
cargo run --bin http_tracker_client scrape http://127.0.0.1:7070 9c38422213e30bff212b30c360d26f9a02136422 | jq
84+
```
85+
86+
`Scrape` response:
87+
88+
```json
89+
{
90+
"9c38422213e30bff212b30c360d26f9a02136422": {
91+
"complete": 1,
92+
"downloaded": 1,
93+
"incomplete": 0
94+
}
95+
}
96+
```
97+
98+
## Tracker Checker
99+
100+
The Tracker Checker is a tool to check the health of a list of trackers.
101+
102+
```console
103+
TORRUST_CHECKER_CONFIG='{
104+
"udp_trackers": ["127.0.0.1:6969"],
105+
"http_trackers": ["http://127.0.0.1:7070"],
106+
"health_checks": ["http://127.0.0.1:1212/api/health_check"]
107+
}' cargo run --bin tracker_checker
108+
```
109+
110+
Output:
111+
112+
```json
113+
[
114+
{
115+
"Udp": {
116+
"Ok": {
117+
"remote_addr": "127.0.0.1:6969",
118+
"results": [
119+
[
120+
"Setup",
121+
{
122+
"Ok": null
123+
}
124+
],
125+
[
126+
"Connect",
127+
{
128+
"Ok": null
129+
}
130+
],
131+
[
132+
"Announce",
133+
{
134+
"Ok": null
135+
}
136+
],
137+
[
138+
"Scrape",
139+
{
140+
"Ok": null
141+
}
142+
]
143+
]
144+
}
145+
}
146+
},
147+
{
148+
"Health": {
149+
"Ok": {
150+
"url": "http://127.0.0.1:1212/api/health_check",
151+
"result": {
152+
"Ok": "200 OK"
153+
}
154+
}
155+
}
156+
},
157+
{
158+
"Http": {
159+
"Ok": {
160+
"url": "http://127.0.0.1:7070/",
161+
"results": [
162+
[
163+
"Announce",
164+
{
165+
"Ok": null
166+
}
167+
],
168+
[
169+
"Scrape",
170+
{
171+
"Ok": null
172+
}
173+
]
174+
]
175+
}
176+
}
177+
}
178+
]
179+
```
180+
181+
## License
182+
183+
**Copyright (c) 2024 The Torrust Developers.**
184+
185+
This program is free software: you can redistribute it and/or modify it under the terms of the [GNU Lesser General Public License][LGPL_3_0] as published by the [Free Software Foundation][FSF], version 3.
186+
187+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the [GNU Lesser General Public License][LGPL_3_0] for more details.
188+
189+
You should have received a copy of the *GNU Lesser General Public License* along with this program. If not, see <https://www.gnu.org/licenses/>.
190+
191+
Some files include explicit copyright notices and/or license notices.
192+
193+
### Legacy Exception
194+
195+
For prosperity, versions of Torrust BitTorrent Tracker Client that are older than five years are automatically granted the [MIT-0][MIT_0] license in addition to the existing [LGPL-3.0-only][LGPL_3_0] license.
196+
197+
[LGPL_3_0]: ./LICENSE
198+
[MIT_0]: ./docs/licenses/LICENSE-MIT_0
199+
[FSF]: https://www.fsf.org/
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
MIT No Attribution
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
4+
software and associated documentation files (the "Software"), to deal in the Software
5+
without restriction, including without limitation the rights to use, copy, modify,
6+
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7+
permit persons to whom the Software is furnished to do so.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
10+
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
11+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
12+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
13+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
14+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

packages/tracker-client/src/bin/http_tracker_client.rs renamed to console/tracker-client/src/bin/http_tracker_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Program to make request to HTTP trackers.
2-
use bittorrent_tracker_client::console::clients::http::app;
2+
use torrust_tracker_client::console::clients::http::app;
33

44
#[tokio::main]
55
async fn main() -> anyhow::Result<()> {

packages/tracker-client/src/bin/tracker_checker.rs renamed to console/tracker-client/src/bin/tracker_checker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Program to check running trackers.
2-
use bittorrent_tracker_client::console::clients::checker::app;
2+
use torrust_tracker_client::console::clients::checker::app;
33

44
#[tokio::main]
55
async fn main() {

packages/tracker-client/src/bin/udp_tracker_client.rs renamed to console/tracker-client/src/bin/udp_tracker_client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Program to make request to UDP trackers.
2-
use bittorrent_tracker_client::console::clients::udp::app;
2+
use torrust_tracker_client::console::clients::udp::app;
33

44
#[tokio::main]
55
async fn main() -> anyhow::Result<()> {

0 commit comments

Comments
 (0)