-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
37 changed files
with
308 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[package] | ||
description = "A collection of console clients to make requests to BitTorrent trackers." | ||
keywords = ["bittorrent", "client", "tracker"] | ||
license = "LGPL-3.0" | ||
name = "torrust-tracker-client" | ||
readme = "README.md" | ||
|
||
authors.workspace = true | ||
documentation.workspace = true | ||
edition.workspace = true | ||
homepage.workspace = true | ||
publish.workspace = true | ||
repository.workspace = true | ||
rust-version.workspace = true | ||
version.workspace = true | ||
|
||
[dependencies] | ||
anyhow = "1" | ||
aquatic_udp_protocol = "0" | ||
bittorrent-primitives = "0.1.0" | ||
bittorrent-tracker-client = { version = "3.0.0-develop", path = "../../packages/tracker-client" } | ||
clap = { version = "4", features = ["derive", "env"] } | ||
futures = "0" | ||
hex-literal = "0" | ||
hyper = "1" | ||
reqwest = { version = "0", features = ["json"] } | ||
serde = { version = "1", features = ["derive"] } | ||
serde_bencode = "0" | ||
serde_bytes = "0" | ||
serde_json = { version = "1", features = ["preserve_order"] } | ||
thiserror = "1" | ||
tokio = { version = "1", features = ["macros", "net", "rt-multi-thread", "signal", "sync"] } | ||
torrust-tracker-configuration = { version = "3.0.0-develop", path = "../../packages/configuration" } | ||
tracing = "0" | ||
tracing-subscriber = { version = "0", features = ["json"] } | ||
url = { version = "2", features = ["serde"] } | ||
|
||
[package.metadata.cargo-machete] | ||
ignored = ["serde_bytes"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
# Torrust Tracker Client | ||
|
||
A collection of console clients to make requests to BitTorrent trackers. | ||
|
||
> **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. | ||
There are currently three console clients available: | ||
|
||
- UDP Client | ||
- HTTP Client | ||
- Tracker Checker | ||
|
||
> **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). | ||
## UDP Client | ||
|
||
`Announce` request: | ||
|
||
```text | ||
cargo run --bin udp_tracker_client announce udp://127.0.0.1:6969 9c38422213e30bff212b30c360d26f9a02136422 | jq | ||
``` | ||
|
||
`Announce` response: | ||
|
||
```json | ||
{ | ||
"AnnounceIpv4": { | ||
"transaction_id": -888840697, | ||
"announce_interval": 120, | ||
"leechers": 0, | ||
"seeders": 1, | ||
"peers": [] | ||
} | ||
} | ||
``` | ||
|
||
`Scrape` request: | ||
|
||
```text | ||
cargo run --bin udp_tracker_client scrape udp://127.0.0.1:6969 9c38422213e30bff212b30c360d26f9a02136422 | jq | ||
``` | ||
|
||
`Scrape` response: | ||
|
||
```json | ||
{ | ||
"Scrape": { | ||
"transaction_id": -888840697, | ||
"torrent_stats": [ | ||
{ | ||
"seeders": 1, | ||
"completed": 0, | ||
"leechers": 0 | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
## HTTP Client | ||
|
||
`Announce` request: | ||
|
||
```text | ||
cargo run --bin http_tracker_client announce http://127.0.0.1:7070 9c38422213e30bff212b30c360d26f9a02136422 | jq | ||
``` | ||
|
||
`Announce` response: | ||
|
||
```json | ||
{ | ||
"complete": 1, | ||
"incomplete": 0, | ||
"interval": 120, | ||
"min interval": 120, | ||
"peers": [] | ||
} | ||
``` | ||
|
||
`Scrape` request: | ||
|
||
```text | ||
cargo run --bin http_tracker_client scrape http://127.0.0.1:7070 9c38422213e30bff212b30c360d26f9a02136422 | jq | ||
``` | ||
|
||
`Scrape` response: | ||
|
||
```json | ||
{ | ||
"9c38422213e30bff212b30c360d26f9a02136422": { | ||
"complete": 1, | ||
"downloaded": 1, | ||
"incomplete": 0 | ||
} | ||
} | ||
``` | ||
|
||
## Tracker Checker | ||
|
||
The Tracker Checker is a tool to check the health of a list of trackers. | ||
|
||
```console | ||
TORRUST_CHECKER_CONFIG='{ | ||
"udp_trackers": ["127.0.0.1:6969"], | ||
"http_trackers": ["http://127.0.0.1:7070"], | ||
"health_checks": ["http://127.0.0.1:1212/api/health_check"] | ||
}' cargo run --bin tracker_checker | ||
``` | ||
|
||
Output: | ||
|
||
```json | ||
[ | ||
{ | ||
"Udp": { | ||
"Ok": { | ||
"remote_addr": "127.0.0.1:6969", | ||
"results": [ | ||
[ | ||
"Setup", | ||
{ | ||
"Ok": null | ||
} | ||
], | ||
[ | ||
"Connect", | ||
{ | ||
"Ok": null | ||
} | ||
], | ||
[ | ||
"Announce", | ||
{ | ||
"Ok": null | ||
} | ||
], | ||
[ | ||
"Scrape", | ||
{ | ||
"Ok": null | ||
} | ||
] | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
"Health": { | ||
"Ok": { | ||
"url": "http://127.0.0.1:1212/api/health_check", | ||
"result": { | ||
"Ok": "200 OK" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"Http": { | ||
"Ok": { | ||
"url": "http://127.0.0.1:7070/", | ||
"results": [ | ||
[ | ||
"Announce", | ||
{ | ||
"Ok": null | ||
} | ||
], | ||
[ | ||
"Scrape", | ||
{ | ||
"Ok": null | ||
} | ||
] | ||
] | ||
} | ||
} | ||
} | ||
] | ||
``` | ||
|
||
## License | ||
|
||
**Copyright (c) 2024 The Torrust Developers.** | ||
|
||
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. | ||
|
||
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. | ||
|
||
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/>. | ||
|
||
Some files include explicit copyright notices and/or license notices. | ||
|
||
### Legacy Exception | ||
|
||
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. | ||
|
||
[LGPL_3_0]: ./LICENSE | ||
[MIT_0]: ./docs/licenses/LICENSE-MIT_0 | ||
[FSF]: https://www.fsf.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
MIT No Attribution | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this | ||
software and associated documentation files (the "Software"), to deal in the Software | ||
without restriction, including without limitation the rights to use, copy, modify, | ||
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
2 changes: 1 addition & 1 deletion
2
...ker-client/src/bin/http_tracker_client.rs → ...ker-client/src/bin/http_tracker_client.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tracker-client/src/bin/tracker_checker.rs → ...tracker-client/src/bin/tracker_checker.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...cker-client/src/bin/udp_tracker_client.rs → ...cker-client/src/bin/udp_tracker_client.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.