Skip to content

Commit

Permalink
fix: [#1097] by extracting duplicate module
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Nov 29, 2024
1 parent e0245f0 commit 555d5b8
Show file tree
Hide file tree
Showing 14 changed files with 715 additions and 139 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
env:
CARGO_REGISTRY_TOKEN: "${{ secrets.TORRUST_UPDATE_CARGO_REGISTRY_TOKEN }}"
run: |
cargo publish -p bittorrent-http-protocol
cargo publish -p bittorrent-tracker-client
cargo publish -p torrust-tracker
cargo publish -p torrust-tracker-client
Expand Down
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ axum = { version = "0", features = ["macros"] }
axum-client-ip = "0"
axum-extra = { version = "0", features = ["query"] }
axum-server = { version = "0", features = ["tls-rustls-no-provider"] }
bittorrent-http-protocol = { version = "3.0.0-develop", path = "packages/http-protocol" }
bittorrent-primitives = "0.1.0"
bittorrent-tracker-client = { version = "3.0.0-develop", path = "packages/tracker-client" }
blowfish = "0"
Expand Down
21 changes: 21 additions & 0 deletions packages/http-protocol/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
description = "A library with the primitive types and functions for the BitTorrent HTTP tracker protocol."
keywords = ["api", "library", "primitives"]
name = "bittorrent-http-protocol"
readme = "README.md"

authors.workspace = true
documentation.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
publish.workspace = true
repository.workspace = true
rust-version.workspace = true
version.workspace = true

[dependencies]
aquatic_udp_protocol = "0"
bittorrent-primitives = "0.1.0"
percent-encoding = "2"
torrust-tracker-primitives = { version = "3.0.0-develop", path = "../primitives" }
661 changes: 661 additions & 0 deletions packages/http-protocol/LICENSE

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions packages/http-protocol/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# BitTorrent HTTP Tracker Protocol

A library with the primitive types and functions used by BitTorrent HTTP trackers.

## Documentation

[Crate documentation](https://docs.rs/bittorrent-http-protocol).

## License

The project is licensed under the terms of the [GNU AFFERO GENERAL PUBLIC LICENSE](./LICENSE).
2 changes: 2 additions & 0 deletions packages/http-protocol/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//! Primitive types and function for `BitTorrent` HTTP trackers.
pub mod percent_encoding;
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use torrust_tracker_primitives::peer;
///
/// ```rust
/// use std::str::FromStr;
/// use torrust_tracker::servers::http::percent_encoding::percent_decode_info_hash;
/// use bittorrent_http_protocol::percent_encoding::percent_decode_info_hash;
/// use bittorrent_primitives::info_hash::InfoHash;
/// use torrust_tracker_primitives::peer;
///
Expand Down Expand Up @@ -60,7 +60,7 @@ pub fn percent_decode_info_hash(raw_info_hash: &str) -> Result<InfoHash, info_ha
/// use std::str::FromStr;
///
/// use aquatic_udp_protocol::PeerId;
/// use torrust_tracker::servers::http::percent_encoding::percent_decode_peer_id;
/// use bittorrent_http_protocol::percent_encoding::percent_decode_peer_id;
/// use bittorrent_primitives::info_hash::InfoHash;
///
/// let encoded_peer_id = "%2DqB00000000000000000";
Expand All @@ -85,7 +85,7 @@ mod tests {
use aquatic_udp_protocol::PeerId;
use bittorrent_primitives::info_hash::InfoHash;

use crate::servers::http::percent_encoding::{percent_decode_info_hash, percent_decode_peer_id};
use crate::percent_encoding::{percent_decode_info_hash, percent_decode_peer_id};

#[test]
fn it_should_decode_a_percent_encoded_info_hash() {
Expand Down
1 change: 1 addition & 0 deletions packages/tracker-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ version.workspace = true

[dependencies]
aquatic_udp_protocol = "0"
bittorrent-http-protocol = { version = "3.0.0-develop", path = "../http-protocol" }
bittorrent-primitives = "0.1.0"
derive_more = { version = "1", features = ["as_ref", "constructor", "from"] }
hyper = "1"
Expand Down
1 change: 0 additions & 1 deletion packages/tracker-client/src/http/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
pub mod client;
pub mod url_encoding;

use percent_encoding::NON_ALPHANUMERIC;

Expand Down
132 changes: 0 additions & 132 deletions packages/tracker-client/src/http/url_encoding.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/servers/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@
//! - [Bencode to Json Online converter](https://chocobo1.github.io/bencode_online).
use serde::{Deserialize, Serialize};

pub mod percent_encoding;
pub mod server;
pub mod v1;

Expand Down
2 changes: 1 addition & 1 deletion src/servers/http/v1/requests/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use std::panic::Location;
use std::str::FromStr;

use aquatic_udp_protocol::{NumberOfBytes, PeerId};
use bittorrent_http_protocol::percent_encoding::{percent_decode_info_hash, percent_decode_peer_id};
use bittorrent_primitives::info_hash::{self, InfoHash};
use thiserror::Error;
use torrust_tracker_located_error::{Located, LocatedError};
use torrust_tracker_primitives::peer;

use crate::servers::http::percent_encoding::{percent_decode_info_hash, percent_decode_peer_id};
use crate::servers::http::v1::query::{ParseQueryError, Query};
use crate::servers::http::v1::responses;

Expand Down
2 changes: 1 addition & 1 deletion src/servers/http/v1/requests/scrape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
//! Data structures and logic for parsing the `scrape` request.
use std::panic::Location;

use bittorrent_http_protocol::percent_encoding::percent_decode_info_hash;
use bittorrent_primitives::info_hash::{self, InfoHash};
use thiserror::Error;
use torrust_tracker_located_error::{Located, LocatedError};

use crate::servers::http::percent_encoding::percent_decode_info_hash;
use crate::servers::http::v1::query::Query;
use crate::servers::http::v1::responses;

Expand Down

0 comments on commit 555d5b8

Please # to comment.