diff --git a/packages/configuration/src/lib.rs b/packages/configuration/src/lib.rs index 217f8a8b..918d9f01 100644 --- a/packages/configuration/src/lib.rs +++ b/packages/configuration/src/lib.rs @@ -30,10 +30,10 @@ //! //! Each section in the toml structure is mapped to a data structure. For //! example, the `[http_api]` section (configuration for the tracker HTTP API) -//! is mapped to the [`HttpApi`](HttpApi) structure. +//! is mapped to the [`HttpApi`] structure. //! //! > **NOTICE**: some sections are arrays of structures. For example, the -//! > `[[udp_trackers]]` section is an array of [`UdpTracker`](UdpTracker) since +//! > `[[udp_trackers]]` section is an array of [`UdpTracker`] since //! > you can have multiple running UDP trackers bound to different ports. //! //! Please refer to the documentation of each structure for more information @@ -394,7 +394,7 @@ pub struct Configuration { /// Logging level. Possible values are: `Off`, `Error`, `Warn`, `Info`, /// `Debug` and `Trace`. Default is `Info`. pub log_level: Option, - /// Tracker mode. See [`TrackerMode`](torrust_tracker_primitives::TrackerMode) for more information. + /// Tracker mode. See [`TrackerMode`] for more information. pub mode: TrackerMode, // Database configuration diff --git a/src/app.rs b/src/app.rs index e749f9c6..32c12d74 100644 --- a/src/app.rs +++ b/src/app.rs @@ -28,8 +28,8 @@ use tokio::task::JoinHandle; use torrust_tracker_configuration::Configuration; use crate::bootstrap::jobs::{health_check_api, http_tracker, torrent_cleanup, tracker_apis, udp_tracker}; +use crate::core; use crate::servers::http::Version; -use crate::tracker; /// # Panics /// @@ -37,7 +37,7 @@ use crate::tracker; /// /// - Can't retrieve tracker keys from database. /// - Can't load whitelist from database. -pub async fn start(config: Arc, tracker: Arc) -> Vec> { +pub async fn start(config: Arc, tracker: Arc) -> Vec> { let mut jobs: Vec> = Vec::new(); // Load peer keys diff --git a/src/bootstrap/app.rs b/src/bootstrap/app.rs index 78c16a0a..4a6f79a9 100644 --- a/src/bootstrap/app.rs +++ b/src/bootstrap/app.rs @@ -17,10 +17,10 @@ use torrust_tracker_configuration::Configuration; use super::config::initialize_configuration; use crate::bootstrap; +use crate::core::services::tracker_factory; +use crate::core::Tracker; use crate::shared::clock::static_time; use crate::shared::crypto::ephemeral_instance_keys; -use crate::tracker::services::tracker_factory; -use crate::tracker::Tracker; /// It loads the configuration from the environment and builds the main domain [`Tracker`] struct. #[must_use] diff --git a/src/bootstrap/jobs/http_tracker.rs b/src/bootstrap/jobs/http_tracker.rs index a38fe3a5..ecf6bd8a 100644 --- a/src/bootstrap/jobs/http_tracker.rs +++ b/src/bootstrap/jobs/http_tracker.rs @@ -19,9 +19,9 @@ use tokio::sync::oneshot; use tokio::task::JoinHandle; use torrust_tracker_configuration::HttpTracker; +use crate::core; use crate::servers::http::v1::launcher; use crate::servers::http::Version; -use crate::tracker; /// This is the message that the "**launcher**" spawned task sends to the main application process to notify that the HTTP server was successfully started. /// @@ -33,7 +33,7 @@ pub struct ServerJobStarted(); /// /// Right now there is only one version but in the future we could support more than one HTTP tracker version at the same time. /// This feature allows supporting breaking changes on `BitTorrent` BEPs. -pub async fn start_job(config: &HttpTracker, tracker: Arc, version: Version) -> JoinHandle<()> { +pub async fn start_job(config: &HttpTracker, tracker: Arc, version: Version) -> JoinHandle<()> { match version { Version::V1 => start_v1(config, tracker.clone()).await, } @@ -42,7 +42,7 @@ pub async fn start_job(config: &HttpTracker, tracker: Arc, ver /// # Panics /// /// It would panic if the `config::HttpTracker` struct would contain inappropriate values. -async fn start_v1(config: &HttpTracker, tracker: Arc) -> JoinHandle<()> { +async fn start_v1(config: &HttpTracker, tracker: Arc) -> JoinHandle<()> { let bind_addr = config .bind_address .parse::() diff --git a/src/bootstrap/jobs/torrent_cleanup.rs b/src/bootstrap/jobs/torrent_cleanup.rs index d4876913..d3b084d3 100644 --- a/src/bootstrap/jobs/torrent_cleanup.rs +++ b/src/bootstrap/jobs/torrent_cleanup.rs @@ -17,7 +17,7 @@ use log::info; use tokio::task::JoinHandle; use torrust_tracker_configuration::Configuration; -use crate::tracker; +use crate::core; /// It starts a jobs for cleaning up the torrent data in the tracker. /// @@ -25,7 +25,7 @@ use crate::tracker; /// /// Refer to [`torrust-tracker-configuration documentation`](https://docs.rs/torrust-tracker-configuration) for more info about that option. #[must_use] -pub fn start_job(config: &Arc, tracker: &Arc) -> JoinHandle<()> { +pub fn start_job(config: &Arc, tracker: &Arc) -> JoinHandle<()> { let weak_tracker = std::sync::Arc::downgrade(tracker); let interval = config.inactive_peer_cleanup_interval; diff --git a/src/bootstrap/jobs/tracker_apis.rs b/src/bootstrap/jobs/tracker_apis.rs index 33b9b6e4..ca29d2b5 100644 --- a/src/bootstrap/jobs/tracker_apis.rs +++ b/src/bootstrap/jobs/tracker_apis.rs @@ -28,8 +28,8 @@ use tokio::sync::oneshot; use tokio::task::JoinHandle; use torrust_tracker_configuration::HttpApi; +use crate::core; use crate::servers::apis::server; -use crate::tracker; /// This is the message that the "launcher" spawned task sends to the main /// application process to notify the API server was successfully started. @@ -49,7 +49,7 @@ pub struct ApiServerJobStarted(); /// # Panics /// /// It would panic if unable to send the `ApiServerJobStarted` notice. -pub async fn start_job(config: &HttpApi, tracker: Arc) -> JoinHandle<()> { +pub async fn start_job(config: &HttpApi, tracker: Arc) -> JoinHandle<()> { let bind_addr = config .bind_address .parse::() diff --git a/src/bootstrap/jobs/udp_tracker.rs b/src/bootstrap/jobs/udp_tracker.rs index 76c465a8..9a30c912 100644 --- a/src/bootstrap/jobs/udp_tracker.rs +++ b/src/bootstrap/jobs/udp_tracker.rs @@ -12,14 +12,14 @@ use log::{error, info, warn}; use tokio::task::JoinHandle; use torrust_tracker_configuration::UdpTracker; +use crate::core; use crate::servers::udp::server::Udp; -use crate::tracker; /// It starts a new UDP server with the provided configuration. /// /// It spawns a new asynchronous task for the new UDP server. #[must_use] -pub fn start_job(config: &UdpTracker, tracker: Arc) -> JoinHandle<()> { +pub fn start_job(config: &UdpTracker, tracker: Arc) -> JoinHandle<()> { let bind_addr = config.bind_address.clone(); tokio::spawn(async move { diff --git a/src/tracker/auth.rs b/src/core/auth.rs similarity index 96% rename from src/tracker/auth.rs rename to src/core/auth.rs index 2759c8d0..c6b77248 100644 --- a/src/tracker/auth.rs +++ b/src/core/auth.rs @@ -12,7 +12,7 @@ //! Keys are stored in this struct: //! //! ```rust,no_run -//! use torrust_tracker::tracker::auth::Key; +//! use torrust_tracker::core::auth::Key; //! use torrust_tracker::shared::clock::DurationSinceUnixEpoch; //! //! pub struct ExpiringKey { @@ -26,7 +26,7 @@ //! You can generate a new key valid for `9999` seconds and `0` nanoseconds from the current time with the following: //! //! ```rust,no_run -//! use torrust_tracker::tracker::auth; +//! use torrust_tracker::core::auth; //! use std::time::Duration; //! //! let expiring_key = auth::generate(Duration::new(9999, 0)); @@ -138,7 +138,7 @@ pub struct Key(String); /// Error returned when a key cannot be parsed from a string. /// /// ```rust,no_run -/// use torrust_tracker::tracker::auth::Key; +/// use torrust_tracker::core::auth::Key; /// use std::str::FromStr; /// /// let key_string = "YZSl4lMZupRuOpSRC3krIKR5BPB14nrJ"; @@ -164,7 +164,7 @@ impl FromStr for Key { } } -/// Verification error. Error returned when an [`ExpiringKey`] cannot be verified with the [`verify(...)`](crate::tracker::auth::verify) function. +/// Verification error. Error returned when an [`ExpiringKey`] cannot be verified with the [`verify(...)`](crate::core::auth::verify) function. /// #[derive(Debug, Error)] #[allow(dead_code)] @@ -196,7 +196,7 @@ mod tests { mod key { use std::str::FromStr; - use crate::tracker::auth::Key; + use crate::core::auth::Key; #[test] fn should_be_parsed_from_an_string() { @@ -212,8 +212,8 @@ mod tests { use std::str::FromStr; use std::time::Duration; + use crate::core::auth; use crate::shared::clock::{Current, StoppedTime}; - use crate::tracker::auth; #[test] fn should_be_parsed_from_an_string() { diff --git a/src/tracker/databases/driver.rs b/src/core/databases/driver.rs similarity index 90% rename from src/tracker/databases/driver.rs rename to src/core/databases/driver.rs index 19cb7046..99d96c6b 100644 --- a/src/tracker/databases/driver.rs +++ b/src/core/databases/driver.rs @@ -1,6 +1,6 @@ //! Database driver factory. //! -//! See [`databases::driver::build`](crate::tracker::databases::driver::build) +//! See [`databases::driver::build`](crate::core::databases::driver::build) //! function for more information. use torrust_tracker_primitives::DatabaseDriver; @@ -14,7 +14,7 @@ use super::{Builder, Database}; /// Example for `SQLite3`: /// /// ```rust,no_run -/// use torrust_tracker::tracker::databases; +/// use torrust_tracker::core::databases; /// use torrust_tracker_primitives::DatabaseDriver; /// /// let db_driver = DatabaseDriver::Sqlite3; @@ -25,7 +25,7 @@ use super::{Builder, Database}; /// Example for `MySQL`: /// /// ```rust,no_run -/// use torrust_tracker::tracker::databases; +/// use torrust_tracker::core::databases; /// use torrust_tracker_primitives::DatabaseDriver; /// /// let db_driver = DatabaseDriver::MySQL; diff --git a/src/tracker/databases/error.rs b/src/core/databases/error.rs similarity index 97% rename from src/tracker/databases/error.rs rename to src/core/databases/error.rs index d89ec05d..96b0d835 100644 --- a/src/tracker/databases/error.rs +++ b/src/core/databases/error.rs @@ -1,6 +1,6 @@ //! Database errors. //! -//! This module contains the [Database errors](crate::tracker::databases::error::Error). +//! This module contains the [Database errors](crate::core::databases::error::Error). use std::panic::Location; use std::sync::Arc; diff --git a/src/tracker/databases/mod.rs b/src/core/databases/mod.rs similarity index 92% rename from src/tracker/databases/mod.rs rename to src/core/databases/mod.rs index 90288049..14fcb6b5 100644 --- a/src/tracker/databases/mod.rs +++ b/src/core/databases/mod.rs @@ -4,8 +4,8 @@ //! //! There are two implementations of the trait (two drivers): //! -//! - [`Mysql`](crate::tracker::databases::mysql::Mysql) -//! - [`Sqlite`](crate::tracker::databases::sqlite::Sqlite) +//! - [`Mysql`](crate::core::databases::mysql::Mysql) +//! - [`Sqlite`](crate::core::databases::sqlite::Sqlite) //! //! > **NOTICE**: There are no database migrations. If there are any changes, //! we will implemented them or provide a script to migrate to the new schema. @@ -22,7 +22,7 @@ //! ---|---|--- //! `id` | 1 | Autoincrement id //! `info_hash` | `c1277613db1d28709b034a017ab2cae4be07ae10` | `BitTorrent` infohash V1 -//! `completed` | 20 | The number of peers that have ever completed downloading the torrent associated to this entry. See [`Entry`](crate::tracker::torrent::Entry) for more information. +//! `completed` | 20 | The number of peers that have ever completed downloading the torrent associated to this entry. See [`Entry`](crate::core::torrent::Entry) for more information. //! //! > **NOTICE**: The peer list for a torrent is not persisted. Since peer have to re-announce themselves on intervals, the data is be //! regenerated again after some minutes. @@ -53,8 +53,8 @@ use std::marker::PhantomData; use async_trait::async_trait; use self::error::Error; +use crate::core::auth::{self, Key}; use crate::shared::bit_torrent::info_hash::InfoHash; -use crate::tracker::auth::{self, Key}; struct Builder where @@ -116,9 +116,9 @@ pub trait Database: Sync + Send { /// /// It returns an array of tuples with the torrent /// [`InfoHash`] and the - /// [`completed`](crate::tracker::torrent::Entry::completed) counter + /// [`completed`](crate::core::torrent::Entry::completed) counter /// which is the number of times the torrent has been downloaded. - /// See [`Entry::completed`](crate::tracker::torrent::Entry::completed). + /// See [`Entry::completed`](crate::core::torrent::Entry::completed). /// /// # Context: Torrent Metrics /// @@ -200,8 +200,8 @@ pub trait Database: Sync + Send { /// It gets an expiring authentication key from the database. /// - /// It returns `Some(ExpiringKey)` if a [`ExpiringKey`](crate::tracker::auth::ExpiringKey) - /// with the input [`Key`](crate::tracker::auth::Key) exists, `None` otherwise. + /// It returns `Some(ExpiringKey)` if a [`ExpiringKey`](crate::core::auth::ExpiringKey) + /// with the input [`Key`](crate::core::auth::Key) exists, `None` otherwise. /// /// # Context: Authentication Keys /// diff --git a/src/tracker/databases/mysql.rs b/src/core/databases/mysql.rs similarity index 89% rename from src/tracker/databases/mysql.rs rename to src/core/databases/mysql.rs index 4419666a..c4630082 100644 --- a/src/tracker/databases/mysql.rs +++ b/src/core/databases/mysql.rs @@ -11,9 +11,9 @@ use r2d2_mysql::MySqlConnectionManager; use torrust_tracker_primitives::DatabaseDriver; use super::{Database, Error}; +use crate::core::auth::{self, Key}; use crate::shared::bit_torrent::common::AUTH_KEY_LENGTH; use crate::shared::bit_torrent::info_hash::InfoHash; -use crate::tracker::auth::{self, Key}; const DRIVER: DatabaseDriver = DatabaseDriver::MySQL; @@ -25,7 +25,7 @@ pub struct Mysql { impl Database for Mysql { /// It instantiates a new `MySQL` database driver. /// - /// Refer to [`databases::Database::new`](crate::tracker::databases::Database::new). + /// Refer to [`databases::Database::new`](crate::core::databases::Database::new). /// /// # Errors /// @@ -39,7 +39,7 @@ impl Database for Mysql { Ok(Self { pool }) } - /// Refer to [`databases::Database::create_database_tables`](crate::tracker::databases::Database::create_database_tables). + /// Refer to [`databases::Database::create_database_tables`](crate::core::databases::Database::create_database_tables). fn create_database_tables(&self) -> Result<(), Error> { let create_whitelist_table = " CREATE TABLE IF NOT EXISTS whitelist ( @@ -79,7 +79,7 @@ impl Database for Mysql { Ok(()) } - /// Refer to [`databases::Database::drop_database_tables`](crate::tracker::databases::Database::drop_database_tables). + /// Refer to [`databases::Database::drop_database_tables`](crate::core::databases::Database::drop_database_tables). fn drop_database_tables(&self) -> Result<(), Error> { let drop_whitelist_table = " DROP TABLE `whitelist`;" @@ -104,7 +104,7 @@ impl Database for Mysql { Ok(()) } - /// Refer to [`databases::Database::load_persistent_torrents`](crate::tracker::databases::Database::load_persistent_torrents). + /// Refer to [`databases::Database::load_persistent_torrents`](crate::core::databases::Database::load_persistent_torrents). async fn load_persistent_torrents(&self) -> Result, Error> { let mut conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -119,7 +119,7 @@ impl Database for Mysql { Ok(torrents) } - /// Refer to [`databases::Database::load_keys`](crate::tracker::databases::Database::load_keys). + /// Refer to [`databases::Database::load_keys`](crate::core::databases::Database::load_keys). async fn load_keys(&self) -> Result, Error> { let mut conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -134,7 +134,7 @@ impl Database for Mysql { Ok(keys) } - /// Refer to [`databases::Database::load_whitelist`](crate::tracker::databases::Database::load_whitelist). + /// Refer to [`databases::Database::load_whitelist`](crate::core::databases::Database::load_whitelist). async fn load_whitelist(&self) -> Result, Error> { let mut conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -145,7 +145,7 @@ impl Database for Mysql { Ok(info_hashes) } - /// Refer to [`databases::Database::save_persistent_torrent`](crate::tracker::databases::Database::save_persistent_torrent). + /// Refer to [`databases::Database::save_persistent_torrent`](crate::core::databases::Database::save_persistent_torrent). async fn save_persistent_torrent(&self, info_hash: &InfoHash, completed: u32) -> Result<(), Error> { const COMMAND : &str = "INSERT INTO torrents (info_hash, completed) VALUES (:info_hash_str, :completed) ON DUPLICATE KEY UPDATE completed = VALUES(completed)"; @@ -158,7 +158,7 @@ impl Database for Mysql { Ok(conn.exec_drop(COMMAND, params! { info_hash_str, completed })?) } - /// Refer to [`databases::Database::get_info_hash_from_whitelist`](crate::tracker::databases::Database::get_info_hash_from_whitelist). + /// Refer to [`databases::Database::get_info_hash_from_whitelist`](crate::core::databases::Database::get_info_hash_from_whitelist). async fn get_info_hash_from_whitelist(&self, info_hash: &InfoHash) -> Result, Error> { let mut conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -172,7 +172,7 @@ impl Database for Mysql { Ok(info_hash) } - /// Refer to [`databases::Database::add_info_hash_to_whitelist`](crate::tracker::databases::Database::add_info_hash_to_whitelist). + /// Refer to [`databases::Database::add_info_hash_to_whitelist`](crate::core::databases::Database::add_info_hash_to_whitelist). async fn add_info_hash_to_whitelist(&self, info_hash: InfoHash) -> Result { let mut conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -186,7 +186,7 @@ impl Database for Mysql { Ok(1) } - /// Refer to [`databases::Database::remove_info_hash_from_whitelist`](crate::tracker::databases::Database::remove_info_hash_from_whitelist). + /// Refer to [`databases::Database::remove_info_hash_from_whitelist`](crate::core::databases::Database::remove_info_hash_from_whitelist). async fn remove_info_hash_from_whitelist(&self, info_hash: InfoHash) -> Result { let mut conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -197,7 +197,7 @@ impl Database for Mysql { Ok(1) } - /// Refer to [`databases::Database::get_key_from_keys`](crate::tracker::databases::Database::get_key_from_keys). + /// Refer to [`databases::Database::get_key_from_keys`](crate::core::databases::Database::get_key_from_keys). async fn get_key_from_keys(&self, key: &Key) -> Result, Error> { let mut conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -214,7 +214,7 @@ impl Database for Mysql { })) } - /// Refer to [`databases::Database::add_key_to_keys`](crate::tracker::databases::Database::add_key_to_keys). + /// Refer to [`databases::Database::add_key_to_keys`](crate::core::databases::Database::add_key_to_keys). async fn add_key_to_keys(&self, auth_key: &auth::ExpiringKey) -> Result { let mut conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -229,7 +229,7 @@ impl Database for Mysql { Ok(1) } - /// Refer to [`databases::Database::remove_key_from_keys`](crate::tracker::databases::Database::remove_key_from_keys). + /// Refer to [`databases::Database::remove_key_from_keys`](crate::core::databases::Database::remove_key_from_keys). async fn remove_key_from_keys(&self, key: &Key) -> Result { let mut conn = self.pool.get().map_err(|e| (e, DRIVER))?; diff --git a/src/tracker/databases/sqlite.rs b/src/core/databases/sqlite.rs similarity index 90% rename from src/tracker/databases/sqlite.rs rename to src/core/databases/sqlite.rs index 1968ee04..bf2d6b8b 100644 --- a/src/tracker/databases/sqlite.rs +++ b/src/core/databases/sqlite.rs @@ -8,9 +8,9 @@ use r2d2_sqlite::SqliteConnectionManager; use torrust_tracker_primitives::DatabaseDriver; use super::{Database, Error}; +use crate::core::auth::{self, Key}; use crate::shared::bit_torrent::info_hash::InfoHash; use crate::shared::clock::DurationSinceUnixEpoch; -use crate::tracker::auth::{self, Key}; const DRIVER: DatabaseDriver = DatabaseDriver::Sqlite3; @@ -22,7 +22,7 @@ pub struct Sqlite { impl Database for Sqlite { /// It instantiates a new `SQLite3` database driver. /// - /// Refer to [`databases::Database::new`](crate::tracker::databases::Database::new). + /// Refer to [`databases::Database::new`](crate::core::databases::Database::new). /// /// # Errors /// @@ -32,7 +32,7 @@ impl Database for Sqlite { Pool::new(cm).map_or_else(|err| Err((err, DatabaseDriver::Sqlite3).into()), |pool| Ok(Sqlite { pool })) } - /// Refer to [`databases::Database::create_database_tables`](crate::tracker::databases::Database::create_database_tables). + /// Refer to [`databases::Database::create_database_tables`](crate::core::databases::Database::create_database_tables). fn create_database_tables(&self) -> Result<(), Error> { let create_whitelist_table = " CREATE TABLE IF NOT EXISTS whitelist ( @@ -66,7 +66,7 @@ impl Database for Sqlite { Ok(()) } - /// Refer to [`databases::Database::drop_database_tables`](crate::tracker::databases::Database::drop_database_tables). + /// Refer to [`databases::Database::drop_database_tables`](crate::core::databases::Database::drop_database_tables). fn drop_database_tables(&self) -> Result<(), Error> { let drop_whitelist_table = " DROP TABLE whitelist;" @@ -89,7 +89,7 @@ impl Database for Sqlite { Ok(()) } - /// Refer to [`databases::Database::load_persistent_torrents`](crate::tracker::databases::Database::load_persistent_torrents). + /// Refer to [`databases::Database::load_persistent_torrents`](crate::core::databases::Database::load_persistent_torrents). async fn load_persistent_torrents(&self) -> Result, Error> { let conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -110,7 +110,7 @@ impl Database for Sqlite { Ok(torrents) } - /// Refer to [`databases::Database::load_keys`](crate::tracker::databases::Database::load_keys). + /// Refer to [`databases::Database::load_keys`](crate::core::databases::Database::load_keys). async fn load_keys(&self) -> Result, Error> { let conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -131,7 +131,7 @@ impl Database for Sqlite { Ok(keys) } - /// Refer to [`databases::Database::load_whitelist`](crate::tracker::databases::Database::load_whitelist). + /// Refer to [`databases::Database::load_whitelist`](crate::core::databases::Database::load_whitelist). async fn load_whitelist(&self) -> Result, Error> { let conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -148,7 +148,7 @@ impl Database for Sqlite { Ok(info_hashes) } - /// Refer to [`databases::Database::save_persistent_torrent`](crate::tracker::databases::Database::save_persistent_torrent). + /// Refer to [`databases::Database::save_persistent_torrent`](crate::core::databases::Database::save_persistent_torrent). async fn save_persistent_torrent(&self, info_hash: &InfoHash, completed: u32) -> Result<(), Error> { let conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -167,7 +167,7 @@ impl Database for Sqlite { } } - /// Refer to [`databases::Database::get_info_hash_from_whitelist`](crate::tracker::databases::Database::get_info_hash_from_whitelist). + /// Refer to [`databases::Database::get_info_hash_from_whitelist`](crate::core::databases::Database::get_info_hash_from_whitelist). async fn get_info_hash_from_whitelist(&self, info_hash: &InfoHash) -> Result, Error> { let conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -180,7 +180,7 @@ impl Database for Sqlite { Ok(query.map(|f| InfoHash::from_str(&f.get_unwrap::<_, String>(0)).unwrap())) } - /// Refer to [`databases::Database::add_info_hash_to_whitelist`](crate::tracker::databases::Database::add_info_hash_to_whitelist). + /// Refer to [`databases::Database::add_info_hash_to_whitelist`](crate::core::databases::Database::add_info_hash_to_whitelist). async fn add_info_hash_to_whitelist(&self, info_hash: InfoHash) -> Result { let conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -196,7 +196,7 @@ impl Database for Sqlite { } } - /// Refer to [`databases::Database::remove_info_hash_from_whitelist`](crate::tracker::databases::Database::remove_info_hash_from_whitelist). + /// Refer to [`databases::Database::remove_info_hash_from_whitelist`](crate::core::databases::Database::remove_info_hash_from_whitelist). async fn remove_info_hash_from_whitelist(&self, info_hash: InfoHash) -> Result { let conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -214,7 +214,7 @@ impl Database for Sqlite { } } - /// Refer to [`databases::Database::get_key_from_keys`](crate::tracker::databases::Database::get_key_from_keys). + /// Refer to [`databases::Database::get_key_from_keys`](crate::core::databases::Database::get_key_from_keys). async fn get_key_from_keys(&self, key: &Key) -> Result, Error> { let conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -234,7 +234,7 @@ impl Database for Sqlite { })) } - /// Refer to [`databases::Database::add_key_to_keys`](crate::tracker::databases::Database::add_key_to_keys). + /// Refer to [`databases::Database::add_key_to_keys`](crate::core::databases::Database::add_key_to_keys). async fn add_key_to_keys(&self, auth_key: &auth::ExpiringKey) -> Result { let conn = self.pool.get().map_err(|e| (e, DRIVER))?; @@ -253,7 +253,7 @@ impl Database for Sqlite { } } - /// Refer to [`databases::Database::remove_key_from_keys`](crate::tracker::databases::Database::remove_key_from_keys). + /// Refer to [`databases::Database::remove_key_from_keys`](crate::core::databases::Database::remove_key_from_keys). async fn remove_key_from_keys(&self, key: &Key) -> Result { let conn = self.pool.get().map_err(|e| (e, DRIVER))?; diff --git a/src/tracker/error.rs b/src/core/error.rs similarity index 100% rename from src/tracker/error.rs rename to src/core/error.rs diff --git a/src/tracker/mod.rs b/src/core/mod.rs similarity index 97% rename from src/tracker/mod.rs rename to src/core/mod.rs index 94d75a8c..ed6ba6a8 100644 --- a/src/tracker/mod.rs +++ b/src/core/mod.rs @@ -55,7 +55,7 @@ //! Once you have instantiated the `Tracker` you can `announce` a new [`Peer`] with: //! //! ```rust,no_run -//! use torrust_tracker::tracker::peer; +//! use torrust_tracker::core::peer; //! use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; //! use torrust_tracker::shared::clock::DurationSinceUnixEpoch; //! use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes}; @@ -97,7 +97,7 @@ //! The returned struct is: //! //! ```rust,no_run -//! use torrust_tracker::tracker::peer::Peer; +//! use torrust_tracker::core::peer::Peer; //! //! pub struct AnnounceData { //! pub peers: Vec, @@ -251,7 +251,7 @@ //! A `Peer` is the struct used by the `Tracker` to keep peers data: //! //! ```rust,no_run -//! use torrust_tracker::tracker::peer::Id; +//! use torrust_tracker::core::peer::Id; //! use std::net::SocketAddr; //! use torrust_tracker::shared::clock::DurationSinceUnixEpoch; //! use aquatic_udp_protocol::NumberOfBytes; @@ -364,7 +364,7 @@ //! To learn more about tracker authentication, refer to the following modules : //! //! - [`auth`] module. -//! - [`tracker`](crate::tracker) module. +//! - [`core`](crate::core) module. //! - [`http`](crate::servers::http) module. //! //! # Statistics @@ -455,8 +455,8 @@ use self::auth::Key; use self::error::Error; use self::peer::Peer; use self::torrent::{SwarmMetadata, SwarmStats}; +use crate::core::databases::Database; use crate::shared::bit_torrent::info_hash::InfoHash; -use crate::tracker::databases::Database; /// The domain layer tracker service. /// @@ -470,8 +470,8 @@ use crate::tracker::databases::Database; pub struct Tracker { /// `Tracker` configuration. See [`torrust-tracker-configuration`](torrust_tracker_configuration) pub config: Arc, - /// A database driver implementation: [`Sqlite3`](crate::tracker::databases::sqlite) - /// or [`MySQL`](crate::tracker::databases::mysql) + /// A database driver implementation: [`Sqlite3`](crate::core::databases::sqlite) + /// or [`MySQL`](crate::core::databases::mysql) pub database: Box, mode: TrackerMode, keys: RwLock>, @@ -1110,11 +1110,11 @@ mod tests { use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes}; use torrust_tracker_test_helpers::configuration; + use crate::core::peer::{self, Peer}; + use crate::core::services::tracker_factory; + use crate::core::{TorrentsMetrics, Tracker}; use crate::shared::bit_torrent::info_hash::InfoHash; use crate::shared::clock::DurationSinceUnixEpoch; - use crate::tracker::peer::{self, Peer}; - use crate::tracker::services::tracker_factory; - use crate::tracker::{TorrentsMetrics, Tracker}; fn public_tracker() -> Tracker { tracker_factory(configuration::ephemeral_mode_public().into()) @@ -1288,7 +1288,7 @@ mod tests { mod handling_an_announce_request { - use crate::tracker::tests::the_tracker::{ + use crate::core::tests::the_tracker::{ peer_ip, public_tracker, sample_info_hash, sample_peer, sample_peer_1, sample_peer_2, }; @@ -1296,7 +1296,7 @@ mod tests { use std::net::{IpAddr, Ipv4Addr}; - use crate::tracker::assign_ip_address_to_peer; + use crate::core::assign_ip_address_to_peer; #[test] fn using_the_source_ip_instead_of_the_ip_in_the_announce_request() { @@ -1312,7 +1312,7 @@ mod tests { use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use std::str::FromStr; - use crate::tracker::assign_ip_address_to_peer; + use crate::core::assign_ip_address_to_peer; #[test] fn it_should_use_the_loopback_ip_if_the_tracker_does_not_have_the_external_ip_configuration() { @@ -1353,7 +1353,7 @@ mod tests { use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use std::str::FromStr; - use crate::tracker::assign_ip_address_to_peer; + use crate::core::assign_ip_address_to_peer; #[test] fn it_should_use_the_loopback_ip_if_the_tracker_does_not_have_the_external_ip_configuration() { @@ -1418,7 +1418,7 @@ mod tests { mod it_should_update_the_swarm_stats_for_the_torrent { - use crate::tracker::tests::the_tracker::{ + use crate::core::tests::the_tracker::{ completed_peer, leecher, peer_ip, public_tracker, sample_info_hash, seeder, started_peer, }; @@ -1464,9 +1464,9 @@ mod tests { use std::net::{IpAddr, Ipv4Addr}; + use crate::core::tests::the_tracker::{complete_peer, incomplete_peer, public_tracker}; + use crate::core::{ScrapeData, SwarmMetadata}; use crate::shared::bit_torrent::info_hash::InfoHash; - use crate::tracker::tests::the_tracker::{complete_peer, incomplete_peer, public_tracker}; - use crate::tracker::{ScrapeData, SwarmMetadata}; #[tokio::test] async fn it_should_return_a_zeroed_swarm_metadata_for_the_requested_file_if_the_tracker_does_not_have_that_torrent( @@ -1542,7 +1542,7 @@ mod tests { mod configured_as_whitelisted { mod handling_authorization { - use crate::tracker::tests::the_tracker::{sample_info_hash, whitelisted_tracker}; + use crate::core::tests::the_tracker::{sample_info_hash, whitelisted_tracker}; #[tokio::test] async fn it_should_authorize_the_announce_and_scrape_actions_on_whitelisted_torrents() { @@ -1569,7 +1569,7 @@ mod tests { } mod handling_the_torrent_whitelist { - use crate::tracker::tests::the_tracker::{sample_info_hash, whitelisted_tracker}; + use crate::core::tests::the_tracker::{sample_info_hash, whitelisted_tracker}; #[tokio::test] async fn it_should_add_a_torrent_to_the_whitelist() { @@ -1596,7 +1596,7 @@ mod tests { } mod persistence { - use crate::tracker::tests::the_tracker::{sample_info_hash, whitelisted_tracker}; + use crate::core::tests::the_tracker::{sample_info_hash, whitelisted_tracker}; #[tokio::test] async fn it_should_load_the_whitelist_from_the_database() { @@ -1621,12 +1621,12 @@ mod tests { mod handling_an_scrape_request { - use crate::shared::bit_torrent::info_hash::InfoHash; - use crate::tracker::tests::the_tracker::{ + use crate::core::tests::the_tracker::{ complete_peer, incomplete_peer, peer_ip, sample_info_hash, whitelisted_tracker, }; - use crate::tracker::torrent::SwarmMetadata; - use crate::tracker::ScrapeData; + use crate::core::torrent::SwarmMetadata; + use crate::core::ScrapeData; + use crate::shared::bit_torrent::info_hash::InfoHash; #[test] fn it_should_be_able_to_build_a_zeroed_scrape_data_for_a_list_of_info_hashes() { @@ -1670,8 +1670,8 @@ mod tests { use std::str::FromStr; use std::time::Duration; - use crate::tracker::auth; - use crate::tracker::tests::the_tracker::private_tracker; + use crate::core::auth; + use crate::core::tests::the_tracker::private_tracker; #[tokio::test] async fn it_should_generate_the_expiring_authentication_keys() { @@ -1767,7 +1767,7 @@ mod tests { mod handling_torrent_persistence { use aquatic_udp_protocol::AnnounceEvent; - use crate::tracker::tests::the_tracker::{sample_info_hash, sample_peer, tracker_persisting_torrents_in_database}; + use crate::core::tests::the_tracker::{sample_info_hash, sample_peer, tracker_persisting_torrents_in_database}; #[tokio::test] async fn it_should_persist_the_number_of_completed_peers_for_all_torrents_into_the_database() { diff --git a/src/tracker/peer.rs b/src/core/peer.rs similarity index 98% rename from src/tracker/peer.rs rename to src/core/peer.rs index 4027799a..a64f87b6 100644 --- a/src/tracker/peer.rs +++ b/src/core/peer.rs @@ -3,7 +3,7 @@ //! A sample peer: //! //! ```rust,no_run -//! use torrust_tracker::tracker::peer; +//! use torrust_tracker::core::peer; //! use std::net::SocketAddr; //! use std::net::IpAddr; //! use std::net::Ipv4Addr; @@ -46,7 +46,7 @@ pub enum IPVersion { /// A sample peer: /// /// ```rust,no_run -/// use torrust_tracker::tracker::peer; +/// use torrust_tracker::core::peer; /// use std::net::SocketAddr; /// use std::net::IpAddr; /// use std::net::Ipv4Addr; @@ -118,7 +118,7 @@ impl Peer { /// A sample peer ID: /// /// ```rust,no_run -/// use torrust_tracker::tracker::peer; +/// use torrust_tracker::core::peer; /// /// let peer_id = peer::Id(*b"-qB00000000000000000"); /// ``` @@ -281,7 +281,7 @@ impl Serialize for Id { mod test { mod torrent_peer_id { - use crate::tracker::peer; + use crate::core::peer; #[test] fn should_be_instantiated_from_a_byte_slice() { @@ -398,8 +398,8 @@ mod test { use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes}; use serde_json::Value; + use crate::core::peer::{self, Peer}; use crate::shared::clock::{Current, Time}; - use crate::tracker::peer::{self, Peer}; #[test] fn it_should_be_serializable() { diff --git a/src/tracker/services/mod.rs b/src/core/services/mod.rs similarity index 71% rename from src/tracker/services/mod.rs rename to src/core/services/mod.rs index deb07a43..f5868fc2 100644 --- a/src/tracker/services/mod.rs +++ b/src/core/services/mod.rs @@ -2,8 +2,8 @@ //! //! There are two types of service: //! -//! - [Core tracker services](crate::tracker::services::torrent): related to the tracker main functionalities like getting info about torrents. -//! - [Services for statistics](crate::tracker::services::statistics): related to tracker metrics. Aggregate data about the tracker server. +//! - [Core tracker services](crate::core::services::torrent): related to the tracker main functionalities like getting info about torrents. +//! - [Services for statistics](crate::core::services::statistics): related to tracker metrics. Aggregate data about the tracker server. pub mod statistics; pub mod torrent; @@ -11,7 +11,7 @@ use std::sync::Arc; use torrust_tracker_configuration::Configuration; -use crate::tracker::Tracker; +use crate::core::Tracker; /// It returns a new tracker building its dependencies. /// diff --git a/src/tracker/services/statistics/mod.rs b/src/core/services/statistics/mod.rs similarity index 81% rename from src/tracker/services/statistics/mod.rs rename to src/core/services/statistics/mod.rs index 3ef8b52b..f74df62e 100644 --- a/src/tracker/services/statistics/mod.rs +++ b/src/core/services/statistics/mod.rs @@ -2,15 +2,15 @@ //! //! It includes: //! -//! - A [`factory`](crate::tracker::services::statistics::setup::factory) function to build the structs needed to collect the tracker metrics. -//! - A [`get_metrics`] service to get the [`tracker metrics`](crate::tracker::statistics::Metrics). +//! - A [`factory`](crate::core::services::statistics::setup::factory) function to build the structs needed to collect the tracker metrics. +//! - A [`get_metrics`] service to get the [`tracker metrics`](crate::core::statistics::Metrics). //! //! Tracker metrics are collected using a Publisher-Subscribe pattern. //! //! The factory function builds two structs: //! -//! - An statistics [`EventSender`](crate::tracker::statistics::EventSender) -//! - An statistics [`Repo`](crate::tracker::statistics::Repo) +//! - An statistics [`EventSender`](crate::core::statistics::EventSender) +//! - An statistics [`Repo`](crate::core::statistics::Repo) //! //! ```text //! let (stats_event_sender, stats_repository) = factory(tracker_usage_statistics); @@ -21,7 +21,7 @@ //! There is an event listener that is receiving all the events and processing them with an event handler. //! Then, the event handler updates the metrics depending on the received event. //! -//! For example, if you send the event [`Event::Udp4Connect`](crate::tracker::statistics::Event::Udp4Connect): +//! For example, if you send the event [`Event::Udp4Connect`](crate::core::statistics::Event::Udp4Connect): //! //! ```text //! let result = event_sender.send_event(Event::Udp4Connect).await; @@ -40,8 +40,8 @@ pub mod setup; use std::sync::Arc; -use crate::tracker::statistics::Metrics; -use crate::tracker::{TorrentsMetrics, Tracker}; +use crate::core::statistics::Metrics; +use crate::core::{TorrentsMetrics, Tracker}; /// All the metrics collected by the tracker. #[derive(Debug, PartialEq)] @@ -88,9 +88,9 @@ mod tests { use torrust_tracker_configuration::Configuration; use torrust_tracker_test_helpers::configuration; - use crate::tracker; - use crate::tracker::services::statistics::{get_metrics, TrackerMetrics}; - use crate::tracker::services::tracker_factory; + use crate::core; + use crate::core::services::statistics::{get_metrics, TrackerMetrics}; + use crate::core::services::tracker_factory; pub fn tracker_configuration() -> Arc { Arc::new(configuration::ephemeral()) @@ -105,8 +105,8 @@ mod tests { assert_eq!( tracker_metrics, TrackerMetrics { - torrents_metrics: tracker::TorrentsMetrics::default(), - protocol_metrics: tracker::statistics::Metrics::default(), + torrents_metrics: core::TorrentsMetrics::default(), + protocol_metrics: core::statistics::Metrics::default(), } ); } diff --git a/src/tracker/services/statistics/setup.rs b/src/core/services/statistics/setup.rs similarity index 83% rename from src/tracker/services/statistics/setup.rs rename to src/core/services/statistics/setup.rs index 4bf5a827..37603852 100644 --- a/src/tracker/services/statistics/setup.rs +++ b/src/core/services/statistics/setup.rs @@ -1,14 +1,14 @@ //! Setup for the tracker statistics. //! //! The [`factory`] function builds the structs needed for handling the tracker metrics. -use crate::tracker::statistics; +use crate::core::statistics; /// It builds the structs needed for handling the tracker metrics. /// /// It returns: /// -/// - An statistics [`EventSender`](crate::tracker::statistics::EventSender) that allows you to send events related to statistics. -/// - An statistics [`Repo`](crate::tracker::statistics::Repo) which is an in-memory repository for the tracker metrics. +/// - An statistics [`EventSender`](crate::core::statistics::EventSender) that allows you to send events related to statistics. +/// - An statistics [`Repo`](crate::core::statistics::Repo) which is an in-memory repository for the tracker metrics. /// /// When the input argument `tracker_usage_statistics`is false the setup does not run the event listeners, consequently the statistics /// events are sent are received but not dispatched to the handler. diff --git a/src/tracker/services/torrent.rs b/src/core/services/torrent.rs similarity index 95% rename from src/tracker/services/torrent.rs rename to src/core/services/torrent.rs index 934fa6b7..651f40ca 100644 --- a/src/tracker/services/torrent.rs +++ b/src/core/services/torrent.rs @@ -8,9 +8,9 @@ use std::sync::Arc; use serde::Deserialize; +use crate::core::peer::Peer; +use crate::core::Tracker; use crate::shared::bit_torrent::info_hash::InfoHash; -use crate::tracker::peer::Peer; -use crate::tracker::Tracker; /// It contains all the information the tracker has about a torrent #[derive(Debug, PartialEq)] @@ -141,8 +141,8 @@ mod tests { use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes}; + use crate::core::peer; use crate::shared::clock::DurationSinceUnixEpoch; - use crate::tracker::peer; fn sample_peer() -> peer::Peer { peer::Peer { @@ -164,10 +164,10 @@ mod tests { use torrust_tracker_configuration::Configuration; use torrust_tracker_test_helpers::configuration; + use crate::core::services::torrent::tests::sample_peer; + use crate::core::services::torrent::{get_torrent_info, Info}; + use crate::core::services::tracker_factory; use crate::shared::bit_torrent::info_hash::InfoHash; - use crate::tracker::services::torrent::tests::sample_peer; - use crate::tracker::services::torrent::{get_torrent_info, Info}; - use crate::tracker::services::tracker_factory; pub fn tracker_configuration() -> Arc { Arc::new(configuration::ephemeral()) @@ -219,10 +219,10 @@ mod tests { use torrust_tracker_configuration::Configuration; use torrust_tracker_test_helpers::configuration; + use crate::core::services::torrent::tests::sample_peer; + use crate::core::services::torrent::{get_torrents, BasicInfo, Pagination}; + use crate::core::services::tracker_factory; use crate::shared::bit_torrent::info_hash::InfoHash; - use crate::tracker::services::torrent::tests::sample_peer; - use crate::tracker::services::torrent::{get_torrents, BasicInfo, Pagination}; - use crate::tracker::services::tracker_factory; pub fn tracker_configuration() -> Arc { Arc::new(configuration::ephemeral()) diff --git a/src/tracker/statistics.rs b/src/core/statistics.rs similarity index 95% rename from src/tracker/statistics.rs rename to src/core/statistics.rs index 85cc4f25..f38662cd 100644 --- a/src/tracker/statistics.rs +++ b/src/core/statistics.rs @@ -13,10 +13,10 @@ //! //! The data is collected by using an `event-sender -> event listener` model. //! -//! The tracker uses an [`statistics::EventSender`](crate::tracker::statistics::EventSender) instance to send an event. -//! The [`statistics::Keeper`](crate::tracker::statistics::Keeper) listens to new events and uses the [`statistics::Repo`](crate::tracker::statistics::Repo) to upgrade and store metrics. +//! The tracker uses an [`statistics::EventSender`](crate::core::statistics::EventSender) instance to send an event. +//! The [`statistics::Keeper`](crate::core::statistics::Keeper) listens to new events and uses the [`statistics::Repo`](crate::core::statistics::Repo) to upgrade and store metrics. //! -//! See the [`statistics::Event`](crate::tracker::statistics::Event) enum to check which events are available. +//! See the [`statistics::Event`](crate::core::statistics::Event) enum to check which events are available. use std::sync::Arc; use async_trait::async_trait; @@ -191,10 +191,10 @@ pub trait EventSender: Sync + Send { async fn send_event(&self, event: Event) -> Option>>; } -/// An [`statistics::EventSender`](crate::tracker::statistics::EventSender) implementation. +/// An [`statistics::EventSender`](crate::core::statistics::EventSender) implementation. /// /// It uses a channel sender to send the statistic events. The channel is created by a -/// [`statistics::Keeper`](crate::tracker::statistics::Keeper) +/// [`statistics::Keeper`](crate::core::statistics::Keeper) pub struct Sender { sender: mpsc::Sender, } @@ -307,7 +307,7 @@ impl Repo { mod tests { mod stats_tracker { - use crate::tracker::statistics::{Event, Keeper, Metrics}; + use crate::core::statistics::{Event, Keeper, Metrics}; #[tokio::test] async fn should_contain_the_tracker_statistics() { @@ -331,7 +331,7 @@ mod tests { } mod event_handler { - use crate::tracker::statistics::{event_handler, Event, Repo}; + use crate::core::statistics::{event_handler, Event, Repo}; #[tokio::test] async fn should_increase_the_tcp4_announces_counter_when_it_receives_a_tcp4_announce_event() { diff --git a/src/tracker/torrent.rs b/src/core/torrent.rs similarity index 99% rename from src/tracker/torrent.rs rename to src/core/torrent.rs index de520aeb..8167aa2d 100644 --- a/src/tracker/torrent.rs +++ b/src/core/torrent.rs @@ -191,9 +191,9 @@ mod tests { use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes}; + use crate::core::peer; + use crate::core::torrent::Entry; use crate::shared::clock::{Current, DurationSinceUnixEpoch, Stopped, StoppedTime, Time, Working}; - use crate::tracker::peer; - use crate::tracker::torrent::Entry; struct TorrentPeerBuilder { peer: peer::Peer, diff --git a/src/lib.rs b/src/lib.rs index 8d453f17..c5f77564 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -387,7 +387,7 @@ //! //! Torrust Tracker has four main components: //! -//! - The core [`tracker`] +//! - The core tracker [`core`] //! - The tracker REST [`API`](crate::servers::apis) //! - The [`UDP`](crate::servers::udp) tracker //! - The [`HTTP`](crate::servers::http) tracker @@ -405,7 +405,7 @@ //! - Statistics //! - Persistence //! -//! See [`tracker`] for more details on the [`tracker`] module. +//! See [`core`] for more details on the [`core`] module. //! //! ## Tracker API //! @@ -471,9 +471,9 @@ //! examples on the integration and unit tests. pub mod app; pub mod bootstrap; +pub mod core; pub mod servers; pub mod shared; -pub mod tracker; #[macro_use] extern crate lazy_static; diff --git a/src/servers/apis/routes.rs b/src/servers/apis/routes.rs index 0740e1f6..49f263db 100644 --- a/src/servers/apis/routes.rs +++ b/src/servers/apis/routes.rs @@ -13,7 +13,7 @@ use tower_http::compression::CompressionLayer; use super::v1; use super::v1::context::health_check::handlers::health_check_handler; -use crate::tracker::Tracker; +use crate::core::Tracker; /// Add all API routes to the router. #[allow(clippy::needless_pass_by_value)] diff --git a/src/servers/apis/server.rs b/src/servers/apis/server.rs index 778a17d9..58b60638 100644 --- a/src/servers/apis/server.rs +++ b/src/servers/apis/server.rs @@ -34,8 +34,8 @@ use futures::Future; use log::info; use super::routes::router; +use crate::core::Tracker; use crate::servers::signals::shutdown_signal; -use crate::tracker::Tracker; /// Errors that can occur when starting or stopping the API server. #[derive(Debug)] @@ -281,9 +281,9 @@ mod tests { use torrust_tracker_configuration::Configuration; use torrust_tracker_test_helpers::configuration; + use crate::core; + use crate::core::statistics; use crate::servers::apis::server::ApiServer; - use crate::tracker; - use crate::tracker::statistics; fn tracker_configuration() -> Arc { Arc::new(configuration::ephemeral()) @@ -293,7 +293,7 @@ mod tests { async fn it_should_be_able_to_start_from_stopped_state_and_then_stop_again() { let cfg = tracker_configuration(); - let tracker = Arc::new(tracker::Tracker::new(cfg.clone(), None, statistics::Repo::new()).unwrap()); + let tracker = Arc::new(core::Tracker::new(cfg.clone(), None, statistics::Repo::new()).unwrap()); let stopped_api_server = ApiServer::new(cfg.http_api.clone()); diff --git a/src/servers/apis/v1/context/auth_key/handlers.rs b/src/servers/apis/v1/context/auth_key/handlers.rs index d6a2992f..a6c8bf81 100644 --- a/src/servers/apis/v1/context/auth_key/handlers.rs +++ b/src/servers/apis/v1/context/auth_key/handlers.rs @@ -10,10 +10,10 @@ use serde::Deserialize; use super::responses::{ auth_key_response, failed_to_delete_key_response, failed_to_generate_key_response, failed_to_reload_keys_response, }; +use crate::core::auth::Key; +use crate::core::Tracker; use crate::servers::apis::v1::context::auth_key::resources::AuthKey; use crate::servers::apis::v1::responses::{invalid_auth_key_param_response, ok_response}; -use crate::tracker::auth::Key; -use crate::tracker::Tracker; /// It handles the request to generate a new authentication key. /// diff --git a/src/servers/apis/v1/context/auth_key/resources.rs b/src/servers/apis/v1/context/auth_key/resources.rs index 5099fad8..f4c7f34c 100644 --- a/src/servers/apis/v1/context/auth_key/resources.rs +++ b/src/servers/apis/v1/context/auth_key/resources.rs @@ -3,8 +3,8 @@ use std::convert::From; use serde::{Deserialize, Serialize}; +use crate::core::auth::{self, Key}; use crate::shared::clock::convert_from_iso_8601_to_timestamp; -use crate::tracker::auth::{self, Key}; /// A resource that represents an authentication key. #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] @@ -43,8 +43,8 @@ mod tests { use std::time::Duration; use super::AuthKey; + use crate::core::auth::{self, Key}; use crate::shared::clock::{Current, TimeNow}; - use crate::tracker::auth::{self, Key}; struct TestTime { pub timestamp: u64, diff --git a/src/servers/apis/v1/context/auth_key/routes.rs b/src/servers/apis/v1/context/auth_key/routes.rs index 76c634e2..003ee5af 100644 --- a/src/servers/apis/v1/context/auth_key/routes.rs +++ b/src/servers/apis/v1/context/auth_key/routes.rs @@ -12,7 +12,7 @@ use axum::routing::{get, post}; use axum::Router; use super::handlers::{delete_auth_key_handler, generate_auth_key_handler, reload_keys_handler}; -use crate::tracker::Tracker; +use crate::core::Tracker; /// It adds the routes to the router for the [`auth_key`](crate::servers::apis::v1::context::auth_key) API context. pub fn add(prefix: &str, router: Router, tracker: Arc) -> Router { diff --git a/src/servers/apis/v1/context/stats/handlers.rs b/src/servers/apis/v1/context/stats/handlers.rs index bb531c80..c3be5dc7 100644 --- a/src/servers/apis/v1/context/stats/handlers.rs +++ b/src/servers/apis/v1/context/stats/handlers.rs @@ -7,8 +7,8 @@ use axum::response::Json; use super::resources::Stats; use super::responses::stats_response; -use crate::tracker::services::statistics::get_metrics; -use crate::tracker::Tracker; +use crate::core::services::statistics::get_metrics; +use crate::core::Tracker; /// It handles the request to get the tracker statistics. /// diff --git a/src/servers/apis/v1/context/stats/resources.rs b/src/servers/apis/v1/context/stats/resources.rs index 355a1e44..b241c469 100644 --- a/src/servers/apis/v1/context/stats/resources.rs +++ b/src/servers/apis/v1/context/stats/resources.rs @@ -2,7 +2,7 @@ //! API context. use serde::{Deserialize, Serialize}; -use crate::tracker::services::statistics::TrackerMetrics; +use crate::core::services::statistics::TrackerMetrics; /// It contains all the statistics generated by the tracker. #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] @@ -72,9 +72,9 @@ impl From for Stats { #[cfg(test)] mod tests { use super::Stats; - use crate::tracker::services::statistics::TrackerMetrics; - use crate::tracker::statistics::Metrics; - use crate::tracker::TorrentsMetrics; + use crate::core::services::statistics::TrackerMetrics; + use crate::core::statistics::Metrics; + use crate::core::TorrentsMetrics; #[test] fn stats_resource_should_be_converted_from_tracker_metrics() { diff --git a/src/servers/apis/v1/context/stats/responses.rs b/src/servers/apis/v1/context/stats/responses.rs index e8e7cb84..9d03cced 100644 --- a/src/servers/apis/v1/context/stats/responses.rs +++ b/src/servers/apis/v1/context/stats/responses.rs @@ -3,7 +3,7 @@ use axum::response::Json; use super::resources::Stats; -use crate::tracker::services::statistics::TrackerMetrics; +use crate::core::services::statistics::TrackerMetrics; /// `200` response that contains the [`Stats`] resource as json. pub fn stats_response(tracker_metrics: TrackerMetrics) -> Json { diff --git a/src/servers/apis/v1/context/stats/routes.rs b/src/servers/apis/v1/context/stats/routes.rs index 9198562d..d8d55269 100644 --- a/src/servers/apis/v1/context/stats/routes.rs +++ b/src/servers/apis/v1/context/stats/routes.rs @@ -9,7 +9,7 @@ use axum::routing::get; use axum::Router; use super::handlers::get_stats_handler; -use crate::tracker::Tracker; +use crate::core::Tracker; /// It adds the routes to the router for the [`stats`](crate::servers::apis::v1::context::stats) API context. pub fn add(prefix: &str, router: Router, tracker: Arc) -> Router { diff --git a/src/servers/apis/v1/context/torrent/handlers.rs b/src/servers/apis/v1/context/torrent/handlers.rs index 1f38ab47..101a25c8 100644 --- a/src/servers/apis/v1/context/torrent/handlers.rs +++ b/src/servers/apis/v1/context/torrent/handlers.rs @@ -11,11 +11,11 @@ use serde::{de, Deserialize, Deserializer}; use super::resources::torrent::ListItem; use super::responses::{torrent_info_response, torrent_list_response, torrent_not_known_response}; +use crate::core::services::torrent::{get_torrent_info, get_torrents, Pagination}; +use crate::core::Tracker; use crate::servers::apis::v1::responses::invalid_info_hash_param_response; use crate::servers::apis::InfoHashParam; use crate::shared::bit_torrent::info_hash::InfoHash; -use crate::tracker::services::torrent::{get_torrent_info, get_torrents, Pagination}; -use crate::tracker::Tracker; /// It handles the request to get the torrent data. /// diff --git a/src/servers/apis/v1/context/torrent/resources/peer.rs b/src/servers/apis/v1/context/torrent/resources/peer.rs index e0cab853..75269439 100644 --- a/src/servers/apis/v1/context/torrent/resources/peer.rs +++ b/src/servers/apis/v1/context/torrent/resources/peer.rs @@ -1,7 +1,7 @@ //! `Peer` and Peer `Id` API resources. use serde::{Deserialize, Serialize}; -use crate::tracker; +use crate::core; /// `Peer` API resource. #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] @@ -35,8 +35,8 @@ pub struct Id { pub client: Option, } -impl From for Id { - fn from(peer_id: tracker::peer::Id) -> Self { +impl From for Id { + fn from(peer_id: core::peer::Id) -> Self { Id { id: peer_id.to_hex_string(), client: peer_id.get_client_name(), @@ -44,9 +44,9 @@ impl From for Id { } } -impl From for Peer { +impl From for Peer { #[allow(deprecated)] - fn from(peer: tracker::peer::Peer) -> Self { + fn from(peer: core::peer::Peer) -> Self { Peer { peer_id: Id::from(peer.peer_id), peer_addr: peer.peer_addr.to_string(), diff --git a/src/servers/apis/v1/context/torrent/resources/torrent.rs b/src/servers/apis/v1/context/torrent/resources/torrent.rs index ebebda79..74577a23 100644 --- a/src/servers/apis/v1/context/torrent/resources/torrent.rs +++ b/src/servers/apis/v1/context/torrent/resources/torrent.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; use super::peer; -use crate::tracker::services::torrent::{BasicInfo, Info}; +use crate::core::services::torrent::{BasicInfo, Info}; /// `Torrent` API resource. #[derive(Serialize, Deserialize, Debug, PartialEq, Eq)] @@ -103,12 +103,12 @@ mod tests { use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes}; use super::Torrent; + use crate::core::peer; + use crate::core::services::torrent::{BasicInfo, Info}; use crate::servers::apis::v1::context::torrent::resources::peer::Peer; use crate::servers::apis::v1::context::torrent::resources::torrent::ListItem; use crate::shared::bit_torrent::info_hash::InfoHash; use crate::shared::clock::DurationSinceUnixEpoch; - use crate::tracker::peer; - use crate::tracker::services::torrent::{BasicInfo, Info}; fn sample_peer() -> peer::Peer { peer::Peer { diff --git a/src/servers/apis/v1/context/torrent/responses.rs b/src/servers/apis/v1/context/torrent/responses.rs index 99c2fcae..5daceaf9 100644 --- a/src/servers/apis/v1/context/torrent/responses.rs +++ b/src/servers/apis/v1/context/torrent/responses.rs @@ -4,7 +4,7 @@ use axum::response::{IntoResponse, Json, Response}; use serde_json::json; use super::resources::torrent::{ListItem, Torrent}; -use crate::tracker::services::torrent::{BasicInfo, Info}; +use crate::core::services::torrent::{BasicInfo, Info}; /// `200` response that contains an array of /// [`ListItem`] diff --git a/src/servers/apis/v1/context/torrent/routes.rs b/src/servers/apis/v1/context/torrent/routes.rs index 18295f2a..6f8c28df 100644 --- a/src/servers/apis/v1/context/torrent/routes.rs +++ b/src/servers/apis/v1/context/torrent/routes.rs @@ -10,7 +10,7 @@ use axum::routing::get; use axum::Router; use super::handlers::{get_torrent_handler, get_torrents_handler}; -use crate::tracker::Tracker; +use crate::core::Tracker; /// It adds the routes to the router for the [`torrent`](crate::servers::apis::v1::context::torrent) API context. pub fn add(prefix: &str, router: Router, tracker: Arc) -> Router { diff --git a/src/servers/apis/v1/context/whitelist/handlers.rs b/src/servers/apis/v1/context/whitelist/handlers.rs index bd1da735..fc32f667 100644 --- a/src/servers/apis/v1/context/whitelist/handlers.rs +++ b/src/servers/apis/v1/context/whitelist/handlers.rs @@ -9,10 +9,10 @@ use axum::response::Response; use super::responses::{ failed_to_reload_whitelist_response, failed_to_remove_torrent_from_whitelist_response, failed_to_whitelist_torrent_response, }; +use crate::core::Tracker; use crate::servers::apis::v1::responses::{invalid_info_hash_param_response, ok_response}; use crate::servers::apis::InfoHashParam; use crate::shared::bit_torrent::info_hash::InfoHash; -use crate::tracker::Tracker; /// It handles the request to add a torrent to the whitelist. /// diff --git a/src/servers/apis/v1/context/whitelist/routes.rs b/src/servers/apis/v1/context/whitelist/routes.rs index 65d51134..e4e85181 100644 --- a/src/servers/apis/v1/context/whitelist/routes.rs +++ b/src/servers/apis/v1/context/whitelist/routes.rs @@ -11,7 +11,7 @@ use axum::routing::{delete, get, post}; use axum::Router; use super::handlers::{add_torrent_to_whitelist_handler, reload_whitelist_handler, remove_torrent_from_whitelist_handler}; -use crate::tracker::Tracker; +use crate::core::Tracker; /// It adds the routes to the router for the [`whitelist`](crate::servers::apis::v1::context::whitelist) API context. pub fn add(prefix: &str, router: Router, tracker: Arc) -> Router { diff --git a/src/servers/apis/v1/routes.rs b/src/servers/apis/v1/routes.rs index 74778ca1..48b79557 100644 --- a/src/servers/apis/v1/routes.rs +++ b/src/servers/apis/v1/routes.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use axum::Router; use super::context::{auth_key, stats, torrent, whitelist}; -use crate::tracker::Tracker; +use crate::core::Tracker; /// Add the routes for the v1 API. pub fn add(prefix: &str, router: Router, tracker: Arc) -> Router { diff --git a/src/servers/http/mod.rs b/src/servers/http/mod.rs index e6dd808b..10666d8a 100644 --- a/src/servers/http/mod.rs +++ b/src/servers/http/mod.rs @@ -206,15 +206,15 @@ //! //! ### Scrape //! -//! The `scrape` request allows a peer to get [swarm metadata](crate::tracker::torrent::SwarmMetadata) +//! The `scrape` request allows a peer to get [swarm metadata](crate::core::torrent::SwarmMetadata) //! for multiple torrents at the same time. //! -//! The response contains the [swarm metadata](crate::tracker::torrent::SwarmMetadata) +//! The response contains the [swarm metadata](crate::core::torrent::SwarmMetadata) //! for that torrent: //! -//! - [complete](crate::tracker::torrent::SwarmMetadata::complete) -//! - [downloaded](crate::tracker::torrent::SwarmMetadata::downloaded) -//! - [incomplete](crate::tracker::torrent::SwarmMetadata::incomplete) +//! - [complete](crate::core::torrent::SwarmMetadata::complete) +//! - [downloaded](crate::core::torrent::SwarmMetadata::downloaded) +//! - [incomplete](crate::core::torrent::SwarmMetadata::incomplete) //! //! **Query parameters** //! @@ -266,7 +266,7 @@ //! Where the `files` key contains a dictionary of dictionaries. The first //! dictionary key is the `info_hash` of the torrent (`iiiiiiiiiiiiiiiiiiii` in //! the example). The second level dictionary contains the -//! [swarm metadata](crate::tracker::torrent::SwarmMetadata) for that torrent. +//! [swarm metadata](crate::core::torrent::SwarmMetadata) for that torrent. //! //! If you save the response as a file and you open it with a program that //! can handle binary data you would see: diff --git a/src/servers/http/percent_encoding.rs b/src/servers/http/percent_encoding.rs index b674f047..472b1e72 100644 --- a/src/servers/http/percent_encoding.rs +++ b/src/servers/http/percent_encoding.rs @@ -15,8 +15,8 @@ //! - //! - //! - +use crate::core::peer::{self, IdConversionError}; use crate::shared::bit_torrent::info_hash::{ConversionError, InfoHash}; -use crate::tracker::peer::{self, IdConversionError}; /// Percent decodes a percent encoded infohash. Internally an /// [`InfoHash`] is a 20-byte array. @@ -28,7 +28,7 @@ use crate::tracker::peer::{self, IdConversionError}; /// use std::str::FromStr; /// use torrust_tracker::servers::http::percent_encoding::percent_decode_info_hash; /// use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; -/// use torrust_tracker::tracker::peer; +/// use torrust_tracker::core::peer; /// /// let encoded_infohash = "%3B%24U%04%CF%5F%11%BB%DB%E1%20%1C%EAjk%F4Z%EE%1B%C0"; /// @@ -49,7 +49,7 @@ pub fn percent_decode_info_hash(raw_info_hash: &str) -> Result Result Result Tracker { tracker_factory(configuration::ephemeral_mode_private().into()) @@ -215,9 +215,9 @@ mod tests { use std::sync::Arc; use super::{private_tracker, sample_announce_request, sample_client_ip_sources}; + use crate::core::auth; use crate::servers::http::v1::handlers::announce::handle_announce; use crate::servers::http::v1::handlers::announce::tests::assert_error_response; - use crate::tracker::auth; #[tokio::test] async fn it_should_fail_when_the_authentication_key_is_missing() { diff --git a/src/servers/http/v1/handlers/common/auth.rs b/src/servers/http/v1/handlers/common/auth.rs index 720ed765..f9a7796a 100644 --- a/src/servers/http/v1/handlers/common/auth.rs +++ b/src/servers/http/v1/handlers/common/auth.rs @@ -5,8 +5,8 @@ use std::panic::Location; use thiserror::Error; +use crate::core::auth; use crate::servers::http::v1::responses; -use crate::tracker::auth; /// Authentication error. /// diff --git a/src/servers/http/v1/handlers/mod.rs b/src/servers/http/v1/handlers/mod.rs index d7fd0583..7b3a1e7c 100644 --- a/src/servers/http/v1/handlers/mod.rs +++ b/src/servers/http/v1/handlers/mod.rs @@ -3,7 +3,7 @@ //! Refer to the generic [HTTP server documentation](crate::servers::http) for //! more information about the HTTP tracker. use super::responses; -use crate::tracker::error::Error; +use crate::core::error::Error; pub mod announce; pub mod common; diff --git a/src/servers/http/v1/handlers/scrape.rs b/src/servers/http/v1/handlers/scrape.rs index 58b8aa84..298d4738 100644 --- a/src/servers/http/v1/handlers/scrape.rs +++ b/src/servers/http/v1/handlers/scrape.rs @@ -11,14 +11,14 @@ use axum::extract::State; use axum::response::{IntoResponse, Response}; use log::debug; +use crate::core::auth::Key; +use crate::core::{ScrapeData, Tracker}; use crate::servers::http::v1::extractors::authentication_key::Extract as ExtractKey; use crate::servers::http::v1::extractors::client_ip_sources::Extract as ExtractClientIpSources; use crate::servers::http::v1::extractors::scrape_request::ExtractRequest; use crate::servers::http::v1::requests::scrape::Scrape; use crate::servers::http::v1::services::peer_ip_resolver::{self, ClientIpSources}; use crate::servers::http::v1::{responses, services}; -use crate::tracker::auth::Key; -use crate::tracker::{ScrapeData, Tracker}; /// It handles the `scrape` request when the HTTP tracker is configured /// to run in `public` mode. @@ -113,12 +113,12 @@ mod tests { use torrust_tracker_test_helpers::configuration; + use crate::core::services::tracker_factory; + use crate::core::Tracker; use crate::servers::http::v1::requests::scrape::Scrape; use crate::servers::http::v1::responses; use crate::servers::http::v1::services::peer_ip_resolver::ClientIpSources; use crate::shared::bit_torrent::info_hash::InfoHash; - use crate::tracker::services::tracker_factory; - use crate::tracker::Tracker; fn private_tracker() -> Tracker { tracker_factory(configuration::ephemeral_mode_private().into()) @@ -161,8 +161,8 @@ mod tests { use std::sync::Arc; use super::{private_tracker, sample_client_ip_sources, sample_scrape_request}; + use crate::core::{auth, ScrapeData}; use crate::servers::http::v1::handlers::scrape::handle_scrape; - use crate::tracker::{auth, ScrapeData}; #[tokio::test] async fn it_should_return_zeroed_swarm_metadata_when_the_authentication_key_is_missing() { @@ -203,8 +203,8 @@ mod tests { use std::sync::Arc; use super::{sample_client_ip_sources, sample_scrape_request, whitelisted_tracker}; + use crate::core::ScrapeData; use crate::servers::http::v1::handlers::scrape::handle_scrape; - use crate::tracker::ScrapeData; #[tokio::test] async fn it_should_return_zeroed_swarm_metadata_when_the_torrent_is_not_whitelisted() { diff --git a/src/servers/http/v1/launcher.rs b/src/servers/http/v1/launcher.rs index b5faf8d4..1ae09a5f 100644 --- a/src/servers/http/v1/launcher.rs +++ b/src/servers/http/v1/launcher.rs @@ -11,8 +11,8 @@ use futures::future::BoxFuture; use log::info; use super::routes::router; +use crate::core::Tracker; use crate::servers::http::server::HttpServerLauncher; -use crate::tracker::Tracker; #[derive(Debug)] pub enum Error { diff --git a/src/servers/http/v1/requests/announce.rs b/src/servers/http/v1/requests/announce.rs index c330ca3b..7f77f727 100644 --- a/src/servers/http/v1/requests/announce.rs +++ b/src/servers/http/v1/requests/announce.rs @@ -8,11 +8,11 @@ use std::str::FromStr; use thiserror::Error; use torrust_tracker_located_error::{Located, LocatedError}; +use crate::core::peer::{self, IdConversionError}; 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; use crate::shared::bit_torrent::info_hash::{ConversionError, InfoHash}; -use crate::tracker::peer::{self, IdConversionError}; /// The number of bytes `downloaded`, `uploaded` or `left`. It's used in the /// `Announce` request for parameters that represent a number of bytes. @@ -34,7 +34,7 @@ const COMPACT: &str = "compact"; /// ```rust /// use torrust_tracker::servers::http::v1::requests::announce::{Announce, Compact, Event}; /// use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; -/// use torrust_tracker::tracker::peer; +/// use torrust_tracker::core::peer; /// /// let request = Announce { /// // Mandatory params @@ -355,12 +355,12 @@ mod tests { mod announce_request { + use crate::core::peer; use crate::servers::http::v1::query::Query; use crate::servers::http::v1::requests::announce::{ Announce, Compact, Event, COMPACT, DOWNLOADED, EVENT, INFO_HASH, LEFT, PEER_ID, PORT, UPLOADED, }; use crate::shared::bit_torrent::info_hash::InfoHash; - use crate::tracker::peer; #[test] fn should_be_instantiated_from_the_url_query_with_only_the_mandatory_params() { diff --git a/src/servers/http/v1/responses/announce.rs b/src/servers/http/v1/responses/announce.rs index f45f4c82..8a245476 100644 --- a/src/servers/http/v1/responses/announce.rs +++ b/src/servers/http/v1/responses/announce.rs @@ -11,8 +11,8 @@ use serde::{self, Deserialize, Serialize}; use thiserror::Error; use torrust_tracker_contrib_bencode::{ben_bytes, ben_int, ben_list, ben_map, BMutAccess, BencodeMut}; +use crate::core::{self, AnnounceData}; use crate::servers::http::v1::responses; -use crate::tracker::{self, AnnounceData}; /// Normal (non compact) `announce` response. /// @@ -125,8 +125,8 @@ impl Peer { } } -impl From for Peer { - fn from(peer: tracker::peer::Peer) -> Self { +impl From for Peer { + fn from(peer: core::peer::Peer) -> Self { Peer { peer_id: peer.peer_id.to_bytes(), ip: peer.peer_addr.ip(), @@ -312,8 +312,8 @@ impl CompactPeer { } } -impl From for CompactPeer { - fn from(peer: tracker::peer::Peer) -> Self { +impl From for CompactPeer { + fn from(peer: core::peer::Peer) -> Self { CompactPeer { ip: peer.peer_addr.ip(), port: peer.peer_addr.port(), diff --git a/src/servers/http/v1/responses/scrape.rs b/src/servers/http/v1/responses/scrape.rs index 9cd88b9a..e1682782 100644 --- a/src/servers/http/v1/responses/scrape.rs +++ b/src/servers/http/v1/responses/scrape.rs @@ -7,15 +7,15 @@ use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; use torrust_tracker_contrib_bencode::{ben_int, ben_map, BMutAccess}; -use crate::tracker::ScrapeData; +use crate::core::ScrapeData; /// The `Scrape` response for the HTTP tracker. /// /// ```rust /// use torrust_tracker::servers::http::v1::responses::scrape::Bencoded; /// use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; -/// use torrust_tracker::tracker::torrent::SwarmMetadata; -/// use torrust_tracker::tracker::ScrapeData; +/// use torrust_tracker::core::torrent::SwarmMetadata; +/// use torrust_tracker::core::ScrapeData; /// /// let info_hash = InfoHash([0x69; 20]); /// let mut scrape_data = ScrapeData::empty(); @@ -92,10 +92,10 @@ impl IntoResponse for Bencoded { mod tests { mod scrape_response { + use crate::core::torrent::SwarmMetadata; + use crate::core::ScrapeData; use crate::servers::http::v1::responses::scrape::Bencoded; use crate::shared::bit_torrent::info_hash::InfoHash; - use crate::tracker::torrent::SwarmMetadata; - use crate::tracker::ScrapeData; fn sample_scrape_data() -> ScrapeData { let info_hash = InfoHash([0x69; 20]); diff --git a/src/servers/http/v1/routes.rs b/src/servers/http/v1/routes.rs index 0b6b419c..20e96d7f 100644 --- a/src/servers/http/v1/routes.rs +++ b/src/servers/http/v1/routes.rs @@ -7,7 +7,7 @@ use axum_client_ip::SecureClientIpSource; use tower_http::compression::CompressionLayer; use super::handlers::{announce, health_check, scrape}; -use crate::tracker::Tracker; +use crate::core::Tracker; /// It adds the routes to the router. /// diff --git a/src/servers/http/v1/services/announce.rs b/src/servers/http/v1/services/announce.rs index ddb3b122..bdf8afc8 100644 --- a/src/servers/http/v1/services/announce.rs +++ b/src/servers/http/v1/services/announce.rs @@ -2,7 +2,7 @@ //! //! The service is responsible for handling the `announce` requests. //! -//! It delegates the `announce` logic to the [`Tracker`](crate::tracker::Tracker::announce) +//! It delegates the `announce` logic to the [`Tracker`](crate::core::Tracker::announce) //! and it returns the [`AnnounceData`] returned //! by the [`Tracker`]. //! @@ -11,9 +11,9 @@ use std::net::IpAddr; use std::sync::Arc; +use crate::core::peer::Peer; +use crate::core::{statistics, AnnounceData, Tracker}; use crate::shared::bit_torrent::info_hash::InfoHash; -use crate::tracker::peer::Peer; -use crate::tracker::{statistics, AnnounceData, Tracker}; /// The HTTP tracker `announce` service. /// @@ -50,10 +50,10 @@ mod tests { use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes}; use torrust_tracker_test_helpers::configuration; + use crate::core::services::tracker_factory; + use crate::core::{peer, Tracker}; use crate::shared::bit_torrent::info_hash::InfoHash; use crate::shared::clock::DurationSinceUnixEpoch; - use crate::tracker::services::tracker_factory; - use crate::tracker::{peer, Tracker}; fn public_tracker() -> Tracker { tracker_factory(configuration::ephemeral_mode_public().into()) @@ -97,11 +97,11 @@ mod tests { use torrust_tracker_test_helpers::configuration; use super::{sample_peer_using_ipv4, sample_peer_using_ipv6}; + use crate::core::peer::Peer; + use crate::core::torrent::SwarmStats; + use crate::core::{statistics, AnnounceData, Tracker}; use crate::servers::http::v1::services::announce::invoke; use crate::servers::http::v1::services::announce::tests::{public_tracker, sample_info_hash, sample_peer}; - use crate::tracker::peer::Peer; - use crate::tracker::torrent::SwarmStats; - use crate::tracker::{statistics, AnnounceData, Tracker}; #[tokio::test] async fn it_should_return_the_announce_data() { diff --git a/src/servers/http/v1/services/scrape.rs b/src/servers/http/v1/services/scrape.rs index adea2808..c2fa104d 100644 --- a/src/servers/http/v1/services/scrape.rs +++ b/src/servers/http/v1/services/scrape.rs @@ -2,7 +2,7 @@ //! //! The service is responsible for handling the `scrape` requests. //! -//! It delegates the `scrape` logic to the [`Tracker`](crate::tracker::Tracker::scrape) +//! It delegates the `scrape` logic to the [`Tracker`](crate::core::Tracker::scrape) //! and it returns the [`ScrapeData`] returned //! by the [`Tracker`]. //! @@ -11,8 +11,8 @@ use std::net::IpAddr; use std::sync::Arc; +use crate::core::{statistics, ScrapeData, Tracker}; use crate::shared::bit_torrent::info_hash::InfoHash; -use crate::tracker::{statistics, ScrapeData, Tracker}; /// The HTTP tracker `scrape` service. /// @@ -63,10 +63,10 @@ mod tests { use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes}; use torrust_tracker_test_helpers::configuration; + use crate::core::services::tracker_factory; + use crate::core::{peer, Tracker}; use crate::shared::bit_torrent::info_hash::InfoHash; use crate::shared::clock::DurationSinceUnixEpoch; - use crate::tracker::services::tracker_factory; - use crate::tracker::{peer, Tracker}; fn public_tracker() -> Tracker { tracker_factory(configuration::ephemeral_mode_public().into()) @@ -101,12 +101,12 @@ mod tests { use mockall::predicate::eq; use torrust_tracker_test_helpers::configuration; + use crate::core::torrent::SwarmMetadata; + use crate::core::{statistics, ScrapeData, Tracker}; use crate::servers::http::v1::services::scrape::invoke; use crate::servers::http::v1::services::scrape::tests::{ public_tracker, sample_info_hash, sample_info_hashes, sample_peer, }; - use crate::tracker::torrent::SwarmMetadata; - use crate::tracker::{statistics, ScrapeData, Tracker}; #[tokio::test] async fn it_should_return_the_scrape_data_for_a_torrent() { @@ -193,11 +193,11 @@ mod tests { use mockall::predicate::eq; use torrust_tracker_test_helpers::configuration; + use crate::core::{statistics, ScrapeData, Tracker}; use crate::servers::http::v1::services::scrape::fake; use crate::servers::http::v1::services::scrape::tests::{ public_tracker, sample_info_hash, sample_info_hashes, sample_peer, }; - use crate::tracker::{statistics, ScrapeData, Tracker}; #[tokio::test] async fn it_should_always_return_the_zeroed_scrape_data_for_a_torrent() { diff --git a/src/servers/udp/handlers.rs b/src/servers/udp/handlers.rs index 64d60e54..1878c30e 100644 --- a/src/servers/udp/handlers.rs +++ b/src/servers/udp/handlers.rs @@ -10,12 +10,12 @@ use aquatic_udp_protocol::{ use log::debug; use super::connection_cookie::{check, from_connection_id, into_connection_id, make}; +use crate::core::{statistics, Tracker}; use crate::servers::udp::error::Error; use crate::servers::udp::peer_builder; use crate::servers::udp::request::AnnounceWrapper; use crate::shared::bit_torrent::common::MAX_SCRAPE_TORRENTS; use crate::shared::bit_torrent::info_hash::InfoHash; -use crate::tracker::{statistics, Tracker}; /// It handles the incoming UDP packets. /// @@ -283,9 +283,9 @@ mod tests { use torrust_tracker_configuration::Configuration; use torrust_tracker_test_helpers::configuration; + use crate::core::services::tracker_factory; + use crate::core::{peer, Tracker}; use crate::shared::clock::{Current, Time}; - use crate::tracker::services::tracker_factory; - use crate::tracker::{peer, Tracker}; fn tracker_configuration() -> Arc { Arc::new(default_testing_tracker_configuration()) @@ -396,10 +396,10 @@ mod tests { use mockall::predicate::eq; use super::{sample_ipv4_socket_address, sample_ipv6_remote_addr, tracker_configuration}; + use crate::core::{self, statistics}; use crate::servers::udp::connection_cookie::{into_connection_id, make}; use crate::servers::udp::handlers::handle_connect; use crate::servers::udp::handlers::tests::{public_tracker, sample_ipv4_remote_addr}; - use crate::tracker::{self, statistics}; fn sample_connect_request() -> ConnectRequest { ConnectRequest { @@ -457,9 +457,8 @@ mod tests { let client_socket_address = sample_ipv4_socket_address(); - let torrent_tracker = Arc::new( - tracker::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap(), - ); + let torrent_tracker = + Arc::new(core::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap()); handle_connect(client_socket_address, &sample_connect_request(), &torrent_tracker) .await .unwrap(); @@ -475,9 +474,8 @@ mod tests { .returning(|_| Box::pin(future::ready(Some(Ok(()))))); let stats_event_sender = Box::new(stats_event_sender_mock); - let torrent_tracker = Arc::new( - tracker::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap(), - ); + let torrent_tracker = + Arc::new(core::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap()); handle_connect(sample_ipv6_remote_addr(), &sample_connect_request(), &torrent_tracker) .await .unwrap(); @@ -567,13 +565,13 @@ mod tests { }; use mockall::predicate::eq; + use crate::core::{self, peer, statistics}; use crate::servers::udp::connection_cookie::{into_connection_id, make}; use crate::servers::udp::handlers::handle_announce; use crate::servers::udp::handlers::tests::announce_request::AnnounceRequestBuilder; use crate::servers::udp::handlers::tests::{ public_tracker, sample_ipv4_socket_address, tracker_configuration, TorrentPeerBuilder, }; - use crate::tracker::{self, peer, statistics}; #[tokio::test] async fn an_announced_peer_should_be_added_to_the_tracker() { @@ -662,7 +660,7 @@ mod tests { assert_eq!(peers[0].peer_addr, SocketAddr::new(IpAddr::V4(remote_client_ip), client_port)); } - async fn add_a_torrent_peer_using_ipv6(tracker: Arc) { + async fn add_a_torrent_peer_using_ipv6(tracker: Arc) { let info_hash = AquaticInfoHash([0u8; 20]); let client_ip_v4 = Ipv4Addr::new(126, 0, 0, 1); @@ -680,7 +678,7 @@ mod tests { .await; } - async fn announce_a_new_peer_using_ipv4(tracker: Arc) -> Response { + async fn announce_a_new_peer_using_ipv4(tracker: Arc) -> Response { let remote_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(126, 0, 0, 1)), 8080); let request = AnnounceRequestBuilder::default() .with_connection_id(into_connection_id(&make(&remote_addr))) @@ -717,7 +715,7 @@ mod tests { let stats_event_sender = Box::new(stats_event_sender_mock); let tracker = Arc::new( - tracker::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap(), + core::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap(), ); handle_announce( @@ -734,11 +732,11 @@ mod tests { use aquatic_udp_protocol::{InfoHash as AquaticInfoHash, PeerId as AquaticPeerId}; + use crate::core::peer; use crate::servers::udp::connection_cookie::{into_connection_id, make}; use crate::servers::udp::handlers::handle_announce; use crate::servers::udp::handlers::tests::announce_request::AnnounceRequestBuilder; use crate::servers::udp::handlers::tests::{public_tracker, TorrentPeerBuilder}; - use crate::tracker::peer; #[tokio::test] async fn the_peer_ip_should_be_changed_to_the_external_ip_in_the_tracker_configuration_if_defined() { @@ -788,13 +786,13 @@ mod tests { }; use mockall::predicate::eq; + use crate::core::{self, peer, statistics}; use crate::servers::udp::connection_cookie::{into_connection_id, make}; use crate::servers::udp::handlers::handle_announce; use crate::servers::udp::handlers::tests::announce_request::AnnounceRequestBuilder; use crate::servers::udp::handlers::tests::{ public_tracker, sample_ipv6_remote_addr, tracker_configuration, TorrentPeerBuilder, }; - use crate::tracker::{self, peer, statistics}; #[tokio::test] async fn an_announced_peer_should_be_added_to_the_tracker() { @@ -888,7 +886,7 @@ mod tests { assert_eq!(peers[0].peer_addr, SocketAddr::new(IpAddr::V6(remote_client_ip), client_port)); } - async fn add_a_torrent_peer_using_ipv4(tracker: Arc) { + async fn add_a_torrent_peer_using_ipv4(tracker: Arc) { let info_hash = AquaticInfoHash([0u8; 20]); let client_ip_v4 = Ipv4Addr::new(126, 0, 0, 1); @@ -905,7 +903,7 @@ mod tests { .await; } - async fn announce_a_new_peer_using_ipv6(tracker: Arc) -> Response { + async fn announce_a_new_peer_using_ipv6(tracker: Arc) -> Response { let client_ip_v4 = Ipv4Addr::new(126, 0, 0, 1); let client_ip_v6 = client_ip_v4.to_ipv6_compatible(); let client_port = 8080; @@ -945,7 +943,7 @@ mod tests { let stats_event_sender = Box::new(stats_event_sender_mock); let tracker = Arc::new( - tracker::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap(), + core::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap(), ); let remote_addr = sample_ipv6_remote_addr(); @@ -963,19 +961,19 @@ mod tests { use aquatic_udp_protocol::{InfoHash as AquaticInfoHash, PeerId as AquaticPeerId}; + use crate::core; + use crate::core::statistics::Keeper; use crate::servers::udp::connection_cookie::{into_connection_id, make}; use crate::servers::udp::handlers::handle_announce; use crate::servers::udp::handlers::tests::announce_request::AnnounceRequestBuilder; use crate::servers::udp::handlers::tests::TrackerConfigurationBuilder; - use crate::tracker; - use crate::tracker::statistics::Keeper; #[tokio::test] async fn the_peer_ip_should_be_changed_to_the_external_ip_in_the_tracker_configuration() { let configuration = Arc::new(TrackerConfigurationBuilder::default().with_external_ip("::126.0.0.1").into()); let (stats_event_sender, stats_repository) = Keeper::new_active_instance(); let tracker = - Arc::new(tracker::Tracker::new(configuration, Some(stats_event_sender), stats_repository).unwrap()); + Arc::new(core::Tracker::new(configuration, Some(stats_event_sender), stats_repository).unwrap()); let loopback_ipv4 = Ipv4Addr::new(127, 0, 0, 1); let loopback_ipv6 = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1); @@ -1025,10 +1023,10 @@ mod tests { }; use super::TorrentPeerBuilder; + use crate::core::{self, peer}; use crate::servers::udp::connection_cookie::{into_connection_id, make}; use crate::servers::udp::handlers::handle_scrape; use crate::servers::udp::handlers::tests::{public_tracker, sample_ipv4_remote_addr}; - use crate::tracker::{self, peer}; fn zeroed_torrent_statistics() -> TorrentScrapeStatistics { TorrentScrapeStatistics { @@ -1064,7 +1062,7 @@ mod tests { ); } - async fn add_a_seeder(tracker: Arc, remote_addr: &SocketAddr, info_hash: &InfoHash) { + async fn add_a_seeder(tracker: Arc, remote_addr: &SocketAddr, info_hash: &InfoHash) { let peer_id = peer::Id([255u8; 20]); let peer = TorrentPeerBuilder::default() @@ -1088,7 +1086,7 @@ mod tests { } } - async fn add_a_sample_seeder_and_scrape(tracker: Arc) -> Response { + async fn add_a_sample_seeder_and_scrape(tracker: Arc) -> Response { let remote_addr = sample_ipv4_remote_addr(); let info_hash = InfoHash([0u8; 20]); @@ -1237,9 +1235,9 @@ mod tests { use mockall::predicate::eq; use super::sample_scrape_request; + use crate::core::{self, statistics}; use crate::servers::udp::handlers::handle_scrape; use crate::servers::udp::handlers::tests::{sample_ipv4_remote_addr, tracker_configuration}; - use crate::tracker::{self, statistics}; #[tokio::test] async fn should_send_the_upd4_scrape_event() { @@ -1253,7 +1251,7 @@ mod tests { let remote_addr = sample_ipv4_remote_addr(); let tracker = Arc::new( - tracker::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap(), + core::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap(), ); handle_scrape(remote_addr, &sample_scrape_request(&remote_addr), &tracker) @@ -1269,9 +1267,9 @@ mod tests { use mockall::predicate::eq; use super::sample_scrape_request; + use crate::core::{self, statistics}; use crate::servers::udp::handlers::handle_scrape; use crate::servers::udp::handlers::tests::{sample_ipv6_remote_addr, tracker_configuration}; - use crate::tracker::{self, statistics}; #[tokio::test] async fn should_send_the_upd6_scrape_event() { @@ -1285,7 +1283,7 @@ mod tests { let remote_addr = sample_ipv6_remote_addr(); let tracker = Arc::new( - tracker::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap(), + core::Tracker::new(tracker_configuration(), Some(stats_event_sender), statistics::Repo::new()).unwrap(), ); handle_scrape(remote_addr, &sample_scrape_request(&remote_addr), &tracker) diff --git a/src/servers/udp/mod.rs b/src/servers/udp/mod.rs index a50fffd3..985c1cec 100644 --- a/src/servers/udp/mod.rs +++ b/src/servers/udp/mod.rs @@ -53,7 +53,7 @@ //! supports only three types of requests: `Connect`, `Announce` and `Scrape`. //! //! Request are parsed from UDP packets using the [`aquatic_udp_protocol`](https://crates.io/crates/aquatic_udp_protocol) -//! crate and then handled by the [`Tracker`](crate::tracker::Tracker) struct. +//! crate and then handled by the [`Tracker`](crate::core::Tracker) struct. //! And then the response is also build using the [`aquatic_udp_protocol`](https://crates.io/crates/aquatic_udp_protocol) //! and converted to a UDP packet. //! @@ -467,15 +467,15 @@ //! //! ### Scrape //! -//! The `scrape` request allows a peer to get [swarm metadata](crate::tracker::torrent::SwarmMetadata) +//! The `scrape` request allows a peer to get [swarm metadata](crate::core::torrent::SwarmMetadata) //! for multiple torrents at the same time. //! -//! The response contains the [swarm metadata](crate::tracker::torrent::SwarmMetadata) +//! The response contains the [swarm metadata](crate::core::torrent::SwarmMetadata) //! for that torrent: //! -//! - [complete](crate::tracker::torrent::SwarmMetadata::complete) -//! - [downloaded](crate::tracker::torrent::SwarmMetadata::downloaded) -//! - [incomplete](crate::tracker::torrent::SwarmMetadata::incomplete) +//! - [complete](crate::core::torrent::SwarmMetadata::complete) +//! - [downloaded](crate::core::torrent::SwarmMetadata::downloaded) +//! - [incomplete](crate::core::torrent::SwarmMetadata::incomplete) //! //! > **NOTICE**: up to about 74 torrents can be scraped at once. A full scrape //! can't be done with this protocol. This is a limitation of the UDP protocol. diff --git a/src/servers/udp/peer_builder.rs b/src/servers/udp/peer_builder.rs index 7c83089b..5168e257 100644 --- a/src/servers/udp/peer_builder.rs +++ b/src/servers/udp/peer_builder.rs @@ -2,8 +2,8 @@ use std::net::{IpAddr, SocketAddr}; use super::request::AnnounceWrapper; +use crate::core::peer::{Id, Peer}; use crate::shared::clock::{Current, Time}; -use crate::tracker::peer::{Id, Peer}; /// Extracts the [`Peer`] info from the /// announce request. diff --git a/src/servers/udp/server.rs b/src/servers/udp/server.rs index 31e87481..c6b73860 100644 --- a/src/servers/udp/server.rs +++ b/src/servers/udp/server.rs @@ -28,10 +28,10 @@ use log::{debug, error, info}; use tokio::net::UdpSocket; use tokio::task::JoinHandle; +use crate::core::Tracker; use crate::servers::signals::shutdown_signal; use crate::servers::udp::handlers::handle_packet; use crate::shared::bit_torrent::udp::MAX_PACKET_SIZE; -use crate::tracker::Tracker; /// Error that can occur when starting or stopping the UDP server. /// diff --git a/src/shared/bit_torrent/common.rs b/src/shared/bit_torrent/common.rs index fd52e098..0ce345a3 100644 --- a/src/shared/bit_torrent/common.rs +++ b/src/shared/bit_torrent/common.rs @@ -20,8 +20,8 @@ pub const MAX_SCRAPE_TORRENTS: u8 = 74; /// HTTP tracker authentication key length. /// -/// See function to [`generate`](crate::tracker::auth::generate) the -/// [`ExpiringKeys`](crate::tracker::auth::ExpiringKey) for more information. +/// See function to [`generate`](crate::core::auth::generate) the +/// [`ExpiringKeys`](crate::core::auth::ExpiringKey) for more information. pub const AUTH_KEY_LENGTH: usize = 32; #[repr(u32)] diff --git a/tests/common/app.rs b/tests/common/app.rs index ee3fba06..1b735bc8 100644 --- a/tests/common/app.rs +++ b/tests/common/app.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use torrust_tracker::bootstrap; -use torrust_tracker::tracker::Tracker; +use torrust_tracker::core::Tracker; pub fn setup_with_configuration(configuration: &Arc) -> Arc { bootstrap::app::initialize_with_configuration(configuration) diff --git a/tests/common/fixtures.rs b/tests/common/fixtures.rs index 7062c837..9fd328d5 100644 --- a/tests/common/fixtures.rs +++ b/tests/common/fixtures.rs @@ -1,8 +1,8 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use aquatic_udp_protocol::{AnnounceEvent, NumberOfBytes}; +use torrust_tracker::core::peer::{self, Id, Peer}; use torrust_tracker::shared::clock::DurationSinceUnixEpoch; -use torrust_tracker::tracker::peer::{self, Id, Peer}; pub struct PeerBuilder { peer: Peer, diff --git a/tests/servers/api/mod.rs b/tests/servers/api/mod.rs index 7022da9b..155ac0de 100644 --- a/tests/servers/api/mod.rs +++ b/tests/servers/api/mod.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use torrust_tracker::tracker::Tracker; +use torrust_tracker::core::Tracker; pub mod connection_info; pub mod test_environment; diff --git a/tests/servers/api/test_environment.rs b/tests/servers/api/test_environment.rs index dbb23dcf..0501d9c5 100644 --- a/tests/servers/api/test_environment.rs +++ b/tests/servers/api/test_environment.rs @@ -1,9 +1,9 @@ use std::sync::Arc; +use torrust_tracker::core::peer::Peer; +use torrust_tracker::core::Tracker; use torrust_tracker::servers::apis::server::{ApiServer, RunningApiServer, StoppedApiServer}; use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; -use torrust_tracker::tracker::peer::Peer; -use torrust_tracker::tracker::Tracker; use super::connection_info::ConnectionInfo; use crate::common::app::setup_with_configuration; diff --git a/tests/servers/api/v1/contract/context/auth_key.rs b/tests/servers/api/v1/contract/context/auth_key.rs index a99272e8..4c59b4e9 100644 --- a/tests/servers/api/v1/contract/context/auth_key.rs +++ b/tests/servers/api/v1/contract/context/auth_key.rs @@ -1,6 +1,6 @@ use std::time::Duration; -use torrust_tracker::tracker::auth::Key; +use torrust_tracker::core::auth::Key; use torrust_tracker_test_helpers::configuration; use crate::servers::api::connection_info::{connection_with_invalid_token, connection_with_no_token}; diff --git a/tests/servers/http/client.rs b/tests/servers/http/client.rs index 03ed9aee..288987c5 100644 --- a/tests/servers/http/client.rs +++ b/tests/servers/http/client.rs @@ -1,7 +1,7 @@ use std::net::IpAddr; use reqwest::{Client as ReqwestClient, Response}; -use torrust_tracker::tracker::auth::Key; +use torrust_tracker::core::auth::Key; use super::requests::announce::{self, Query}; use super::requests::scrape; diff --git a/tests/servers/http/connection_info.rs b/tests/servers/http/connection_info.rs index 5736271f..f4081d60 100644 --- a/tests/servers/http/connection_info.rs +++ b/tests/servers/http/connection_info.rs @@ -1,4 +1,4 @@ -use torrust_tracker::tracker::auth::Key; +use torrust_tracker::core::auth::Key; #[derive(Clone, Debug)] pub struct ConnectionInfo { diff --git a/tests/servers/http/requests/announce.rs b/tests/servers/http/requests/announce.rs index f7f25da3..2cc615d0 100644 --- a/tests/servers/http/requests/announce.rs +++ b/tests/servers/http/requests/announce.rs @@ -3,8 +3,8 @@ use std::net::{IpAddr, Ipv4Addr}; use std::str::FromStr; use serde_repr::Serialize_repr; +use torrust_tracker::core::peer::Id; use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; -use torrust_tracker::tracker::peer::Id; use crate::servers::http::{percent_encode_byte_array, ByteArray20}; diff --git a/tests/servers/http/responses/announce.rs b/tests/servers/http/responses/announce.rs index 8a07ebd5..a57b41c7 100644 --- a/tests/servers/http/responses/announce.rs +++ b/tests/servers/http/responses/announce.rs @@ -1,7 +1,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use serde::{self, Deserialize, Serialize}; -use torrust_tracker::tracker::peer::Peer; +use torrust_tracker::core::peer::Peer; #[derive(Serialize, Deserialize, Debug, PartialEq)] pub struct Announce { diff --git a/tests/servers/http/test_environment.rs b/tests/servers/http/test_environment.rs index 8d0aaba0..e24e1b9a 100644 --- a/tests/servers/http/test_environment.rs +++ b/tests/servers/http/test_environment.rs @@ -1,9 +1,9 @@ use std::sync::Arc; +use torrust_tracker::core::peer::Peer; +use torrust_tracker::core::Tracker; use torrust_tracker::servers::http::server::{HttpServer, HttpServerLauncher, RunningHttpServer, StoppedHttpServer}; use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; -use torrust_tracker::tracker::peer::Peer; -use torrust_tracker::tracker::Tracker; use crate::common::app::setup_with_configuration; diff --git a/tests/servers/http/v1/contract.rs b/tests/servers/http/v1/contract.rs index b1900945..d7f4d50c 100644 --- a/tests/servers/http/v1/contract.rs +++ b/tests/servers/http/v1/contract.rs @@ -93,8 +93,8 @@ mod for_all_config_modes { use local_ip_address::local_ip; use reqwest::Response; use tokio::net::TcpListener; + use torrust_tracker::core::peer; use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; - use torrust_tracker::tracker::peer; use torrust_tracker_test_helpers::configuration; use crate::common::fixtures::{invalid_info_hashes, PeerBuilder}; @@ -869,8 +869,8 @@ mod for_all_config_modes { use std::str::FromStr; use tokio::net::TcpListener; + use torrust_tracker::core::peer; use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; - use torrust_tracker::tracker::peer; use torrust_tracker_test_helpers::configuration; use crate::common::fixtures::{invalid_info_hashes, PeerBuilder}; @@ -1147,8 +1147,8 @@ mod configured_as_whitelisted { mod receiving_an_scrape_request { use std::str::FromStr; + use torrust_tracker::core::peer; use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; - use torrust_tracker::tracker::peer; use torrust_tracker_test_helpers::configuration; use crate::common::fixtures::PeerBuilder; @@ -1244,8 +1244,8 @@ mod configured_as_private { use std::str::FromStr; use std::time::Duration; + use torrust_tracker::core::auth::Key; use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; - use torrust_tracker::tracker::auth::Key; use torrust_tracker_test_helpers::configuration; use crate::servers::http::asserts::{assert_authentication_error_response, assert_is_announce_response}; @@ -1321,9 +1321,9 @@ mod configured_as_private { use std::str::FromStr; use std::time::Duration; + use torrust_tracker::core::auth::Key; + use torrust_tracker::core::peer; use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; - use torrust_tracker::tracker::auth::Key; - use torrust_tracker::tracker::peer; use torrust_tracker_test_helpers::configuration; use crate::common::fixtures::PeerBuilder; diff --git a/tests/servers/udp/test_environment.rs b/tests/servers/udp/test_environment.rs index 15266d88..dfe19ac8 100644 --- a/tests/servers/udp/test_environment.rs +++ b/tests/servers/udp/test_environment.rs @@ -1,10 +1,10 @@ use std::net::SocketAddr; use std::sync::Arc; +use torrust_tracker::core::peer::Peer; +use torrust_tracker::core::Tracker; use torrust_tracker::servers::udp::server::{RunningUdpServer, StoppedUdpServer, UdpServer}; use torrust_tracker::shared::bit_torrent::info_hash::InfoHash; -use torrust_tracker::tracker::peer::Peer; -use torrust_tracker::tracker::Tracker; use crate::common::app::setup_with_configuration;