diff --git a/docs/benchmarking.md b/docs/benchmarking.md index 67b680fd..ce3b6905 100644 --- a/docs/benchmarking.md +++ b/docs/benchmarking.md @@ -33,7 +33,7 @@ Run the tracker with UDP service enabled and other services disabled and set log log_level = "error" [[udp_trackers]] -enabled = true +bind_address = "0.0.0.0:6969" ``` Build and run the tracker: @@ -168,7 +168,7 @@ Run the tracker with UDP service enabled and other services disabled and set log log_level = "error" [[udp_trackers]] -enabled = true +bind_address = "0.0.0.0:6969" ``` ```console diff --git a/packages/configuration/src/v1/http_tracker.rs b/packages/configuration/src/v1/http_tracker.rs index fed2282a..42ec02bf 100644 --- a/packages/configuration/src/v1/http_tracker.rs +++ b/packages/configuration/src/v1/http_tracker.rs @@ -9,10 +9,6 @@ use crate::TslConfig; #[serde_as] #[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)] pub struct HttpTracker { - /// Weather the HTTP tracker is enabled or not. - #[serde(default = "HttpTracker::default_enabled")] - pub enabled: bool, - /// The address the tracker will bind to. /// The format is `ip:port`, for example `0.0.0.0:6969`. If you want to /// listen to all interfaces, use `0.0.0.0`. If you want the operating @@ -28,7 +24,6 @@ pub struct HttpTracker { impl Default for HttpTracker { fn default() -> Self { Self { - enabled: Self::default_enabled(), bind_address: Self::default_bind_address(), tsl_config: Self::default_tsl_config(), } @@ -36,10 +31,6 @@ impl Default for HttpTracker { } impl HttpTracker { - fn default_enabled() -> bool { - false - } - fn default_bind_address() -> SocketAddr { SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 7070) } diff --git a/packages/configuration/src/v1/mod.rs b/packages/configuration/src/v1/mod.rs index 603be85d..546f55b6 100644 --- a/packages/configuration/src/v1/mod.rs +++ b/packages/configuration/src/v1/mod.rs @@ -220,16 +220,7 @@ //! external_ip = "0.0.0.0" //! on_reverse_proxy = false //! -//! [[udp_trackers]] -//! enabled = false -//! bind_address = "0.0.0.0:6969" -//! -//! [[http_trackers]] -//! enabled = false -//! bind_address = "0.0.0.0:7070" -//! //! [http_api] -//! enabled = true //! bind_address = "127.0.0.1:1212" //! //! [http_api.access_tokens] @@ -267,7 +258,7 @@ const CONFIG_OVERRIDE_PREFIX: &str = "TORRUST_TRACKER_CONFIG_OVERRIDE_"; const CONFIG_OVERRIDE_SEPARATOR: &str = "__"; /// Core configuration for the tracker. -#[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] +#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default)] pub struct Configuration { /// Logging configuration pub logging: Logging, @@ -278,33 +269,20 @@ pub struct Configuration { /// The list of UDP trackers the tracker is running. Each UDP tracker /// represents a UDP server that the tracker is running and it has its own /// configuration. - pub udp_trackers: Vec, + pub udp_trackers: Option>, /// The list of HTTP trackers the tracker is running. Each HTTP tracker /// represents a HTTP server that the tracker is running and it has its own /// configuration. - pub http_trackers: Vec, + pub http_trackers: Option>, /// The HTTP API configuration. - pub http_api: HttpApi, + pub http_api: Option, /// The Health Check API configuration. pub health_check_api: HealthCheckApi, } -impl Default for Configuration { - fn default() -> Self { - Self { - logging: Logging::default(), - core: Core::default(), - udp_trackers: vec![UdpTracker::default()], - http_trackers: vec![HttpTracker::default()], - http_api: HttpApi::default(), - health_check_api: HealthCheckApi::default(), - } - } -} - impl Configuration { /// Returns the tracker public IP address id defined in the configuration, /// and `None` otherwise. @@ -408,21 +386,6 @@ mod tests { external_ip = "0.0.0.0" on_reverse_proxy = false - [[udp_trackers]] - enabled = false - bind_address = "0.0.0.0:6969" - - [[http_trackers]] - enabled = false - bind_address = "0.0.0.0:7070" - - [http_api] - enabled = true - bind_address = "127.0.0.1:1212" - - [http_api.access_tokens] - admin = "MyAccessToken" - [health_check_api] bind_address = "127.0.0.1:1313" "# @@ -556,7 +519,7 @@ mod tests { let configuration = Configuration::load(&info).expect("Could not load configuration from file"); assert_eq!( - configuration.http_api.access_tokens.get("admin"), + configuration.http_api.unwrap().access_tokens.get("admin"), Some("NewToken".to_owned()).as_ref() ); diff --git a/packages/configuration/src/v1/tracker_api.rs b/packages/configuration/src/v1/tracker_api.rs index 42794ad1..302a4ee9 100644 --- a/packages/configuration/src/v1/tracker_api.rs +++ b/packages/configuration/src/v1/tracker_api.rs @@ -12,10 +12,6 @@ pub type AccessTokens = HashMap; #[serde_as] #[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)] pub struct HttpApi { - /// Weather the HTTP API is enabled or not. - #[serde(default = "HttpApi::default_enabled")] - pub enabled: bool, - /// The address the tracker will bind to. /// The format is `ip:port`, for example `0.0.0.0:6969`. If you want to /// listen to all interfaces, use `0.0.0.0`. If you want the operating @@ -38,7 +34,6 @@ pub struct HttpApi { impl Default for HttpApi { fn default() -> Self { Self { - enabled: Self::default_enabled(), bind_address: Self::default_bind_address(), tsl_config: Self::default_tsl_config(), access_tokens: Self::default_access_tokens(), @@ -47,10 +42,6 @@ impl Default for HttpApi { } impl HttpApi { - fn default_enabled() -> bool { - true - } - fn default_bind_address() -> SocketAddr { SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 1212) } diff --git a/packages/configuration/src/v1/udp_tracker.rs b/packages/configuration/src/v1/udp_tracker.rs index f8387202..b3d420d7 100644 --- a/packages/configuration/src/v1/udp_tracker.rs +++ b/packages/configuration/src/v1/udp_tracker.rs @@ -4,9 +4,6 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)] pub struct UdpTracker { - /// Weather the UDP tracker is enabled or not. - #[serde(default = "UdpTracker::default_enabled")] - pub enabled: bool, /// The address the tracker will bind to. /// The format is `ip:port`, for example `0.0.0.0:6969`. If you want to /// listen to all interfaces, use `0.0.0.0`. If you want the operating @@ -17,17 +14,12 @@ pub struct UdpTracker { impl Default for UdpTracker { fn default() -> Self { Self { - enabled: Self::default_enabled(), bind_address: Self::default_bind_address(), } } } impl UdpTracker { - fn default_enabled() -> bool { - false - } - fn default_bind_address() -> SocketAddr { SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 6969) } diff --git a/packages/test-helpers/src/configuration.rs b/packages/test-helpers/src/configuration.rs index 9c6c0fe1..646617b3 100644 --- a/packages/test-helpers/src/configuration.rs +++ b/packages/test-helpers/src/configuration.rs @@ -2,7 +2,7 @@ use std::env; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; -use torrust_tracker_configuration::{Configuration, LogLevel}; +use torrust_tracker_configuration::{Configuration, HttpApi, HttpTracker, LogLevel, UdpTracker}; use torrust_tracker_primitives::TrackerMode; use crate::random; @@ -33,8 +33,10 @@ pub fn ephemeral() -> Configuration { // Ephemeral socket address for API let api_port = 0u16; - config.http_api.enabled = true; - config.http_api.bind_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), api_port); + config.http_api = Some(HttpApi { + bind_address: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), api_port), + ..Default::default() + }); // Ephemeral socket address for Health Check API let health_check_api_port = 0u16; @@ -42,13 +44,16 @@ pub fn ephemeral() -> Configuration { // Ephemeral socket address for UDP tracker let udp_port = 0u16; - config.udp_trackers[0].enabled = true; - config.udp_trackers[0].bind_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), udp_port); + config.udp_trackers = Some(vec![UdpTracker { + bind_address: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), udp_port), + }]); // Ephemeral socket address for HTTP tracker let http_port = 0u16; - config.http_trackers[0].enabled = true; - config.http_trackers[0].bind_address = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), http_port); + config.http_trackers = Some(vec![HttpTracker { + bind_address: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), http_port), + tsl_config: None, + }]); // Ephemeral sqlite database let temp_directory = env::temp_dir(); @@ -137,9 +142,17 @@ pub fn ephemeral_ipv6() -> Configuration { let ipv6 = SocketAddr::new(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)), 0); - cfg.http_api.bind_address.clone_from(&ipv6); - cfg.http_trackers[0].bind_address.clone_from(&ipv6); - cfg.udp_trackers[0].bind_address = ipv6; + if let Some(ref mut http_api) = cfg.http_api { + http_api.bind_address.clone_from(&ipv6); + }; + + if let Some(ref mut http_trackers) = cfg.http_trackers { + http_trackers[0].bind_address.clone_from(&ipv6); + } + + if let Some(ref mut udp_trackers) = cfg.udp_trackers { + udp_trackers[0].bind_address.clone_from(&ipv6); + } cfg } @@ -149,9 +162,9 @@ pub fn ephemeral_ipv6() -> Configuration { pub fn ephemeral_with_no_services() -> Configuration { let mut cfg = ephemeral(); - cfg.http_api.enabled = false; - cfg.http_trackers[0].enabled = false; - cfg.udp_trackers[0].enabled = false; + cfg.http_api = None; + cfg.http_trackers = None; + cfg.udp_trackers = None; cfg } diff --git a/share/default/config/tracker.container.mysql.toml b/share/default/config/tracker.container.mysql.toml index 70ee8b50..68cc8db8 100644 --- a/share/default/config/tracker.container.mysql.toml +++ b/share/default/config/tracker.container.mysql.toml @@ -2,6 +2,16 @@ driver = "MySQL" path = "mysql://db_user:db_user_secret_password@mysql:3306/torrust_tracker" -[[http_trackers]] -bind_address = "0.0.0.0:7070" -enabled = true +# Uncomment to enable services + +#[[udp_trackers]] +#bind_address = "0.0.0.0:6969" + +#[[http_trackers]] +#bind_address = "0.0.0.0:7070" + +#[http_api] +#bind_address = "0.0.0.0:1212" + +#[http_api.access_tokens] +#admin = "MyAccessToken" diff --git a/share/default/config/tracker.container.sqlite3.toml b/share/default/config/tracker.container.sqlite3.toml index f7bb6b8b..63e169a7 100644 --- a/share/default/config/tracker.container.sqlite3.toml +++ b/share/default/config/tracker.container.sqlite3.toml @@ -1,2 +1,16 @@ [core.database] path = "/var/lib/torrust/tracker/database/sqlite3.db" + +# Uncomment to enable services + +#[[udp_trackers]] +#bind_address = "0.0.0.0:6969" + +#[[http_trackers]] +#bind_address = "0.0.0.0:7070" + +#[http_api] +#bind_address = "0.0.0.0:1212" + +#[http_api.access_tokens] +#admin = "MyAccessToken" diff --git a/share/default/config/tracker.development.sqlite3.toml b/share/default/config/tracker.development.sqlite3.toml index bf647849..84754794 100644 --- a/share/default/config/tracker.development.sqlite3.toml +++ b/share/default/config/tracker.development.sqlite3.toml @@ -1,5 +1,11 @@ [[udp_trackers]] -enabled = true +bind_address = "0.0.0.0:6969" [[http_trackers]] -enabled = true +bind_address = "0.0.0.0:7070" + +[http_api] +bind_address = "0.0.0.0:1212" + +[http_api.access_tokens] +admin = "MyAccessToken" diff --git a/share/default/config/tracker.e2e.container.sqlite3.toml b/share/default/config/tracker.e2e.container.sqlite3.toml index 744d267f..fb33a8e3 100644 --- a/share/default/config/tracker.e2e.container.sqlite3.toml +++ b/share/default/config/tracker.e2e.container.sqlite3.toml @@ -2,10 +2,16 @@ path = "/var/lib/torrust/tracker/database/sqlite3.db" [[udp_trackers]] -enabled = true +bind_address = "0.0.0.0:6969" [[http_trackers]] -enabled = true +bind_address = "0.0.0.0:7070" + +[http_api] +bind_address = "0.0.0.0:1212" + +[http_api.access_tokens] +admin = "MyAccessToken" [health_check_api] # Must be bound to wildcard IP to be accessible from outside the container diff --git a/share/default/config/tracker.udp.benchmarking.toml b/share/default/config/tracker.udp.benchmarking.toml index cd193c40..d9361cf1 100644 --- a/share/default/config/tracker.udp.benchmarking.toml +++ b/share/default/config/tracker.udp.benchmarking.toml @@ -6,7 +6,4 @@ remove_peerless_torrents = false tracker_usage_statistics = false [[udp_trackers]] -enabled = true - -[http_api] -enabled = false +bind_address = "0.0.0.0:6969" diff --git a/src/app.rs b/src/app.rs index b41f4098..f6a90900 100644 --- a/src/app.rs +++ b/src/app.rs @@ -25,7 +25,7 @@ use std::sync::Arc; use tokio::task::JoinHandle; use torrust_tracker_configuration::Configuration; -use tracing::warn; +use tracing::{info, warn}; use crate::bootstrap::jobs::{health_check_api, http_tracker, torrent_cleanup, tracker_apis, udp_tracker}; use crate::servers::registar::Registar; @@ -59,51 +59,56 @@ pub async fn start(config: &Configuration, tracker: Arc) -> Vec { + for udp_tracker_config in udp_trackers { + if tracker.is_private() { + warn!( + "Could not start UDP tracker on: {} while in {:?}. UDP is not safe for private trackers!", + udp_tracker_config.bind_address, config.core.mode + ); + } else { + jobs.push(udp_tracker::start_job(udp_tracker_config, tracker.clone(), registar.give_form()).await); + } + } } + None => info!("No UDP blocks in configuration"), } // Start the HTTP blocks - for http_tracker_config in &config.http_trackers { - if !http_tracker_config.enabled { - continue; + match &config.http_trackers { + Some(http_trackers) => { + for http_tracker_config in http_trackers { + if let Some(job) = http_tracker::start_job( + http_tracker_config, + tracker.clone(), + registar.give_form(), + servers::http::Version::V1, + ) + .await + { + jobs.push(job); + }; + } } - - if let Some(job) = http_tracker::start_job( - http_tracker_config, - tracker.clone(), - registar.give_form(), - servers::http::Version::V1, - ) - .await - { - jobs.push(job); - }; + None => info!("No HTTP blocks in configuration"), } // Start HTTP API - if config.http_api.enabled { - if let Some(job) = tracker_apis::start_job( - &config.http_api, - tracker.clone(), - registar.give_form(), - servers::apis::Version::V1, - ) - .await - { - jobs.push(job); - }; + match &config.http_api { + Some(http_api_config) => { + if let Some(job) = tracker_apis::start_job( + http_api_config, + tracker.clone(), + registar.give_form(), + servers::apis::Version::V1, + ) + .await + { + jobs.push(job); + }; + } + None => info!("No API block in configuration"), } // Start runners to remove torrents without peers, every interval diff --git a/src/bootstrap/jobs/http_tracker.rs b/src/bootstrap/jobs/http_tracker.rs index 05bfe234..fed4e534 100644 --- a/src/bootstrap/jobs/http_tracker.rs +++ b/src/bootstrap/jobs/http_tracker.rs @@ -16,7 +16,6 @@ use std::sync::Arc; use axum_server::tls_rustls::RustlsConfig; use tokio::task::JoinHandle; use torrust_tracker_configuration::HttpTracker; -use tracing::info; use super::make_rust_tls; use crate::core; @@ -39,19 +38,14 @@ pub async fn start_job( form: ServiceRegistrationForm, version: Version, ) -> Option> { - if config.enabled { - let socket = config.bind_address; + let socket = config.bind_address; - let tls = make_rust_tls(&config.tsl_config) - .await - .map(|tls| tls.expect("it should have a valid http tracker tls configuration")); + let tls = make_rust_tls(&config.tsl_config) + .await + .map(|tls| tls.expect("it should have a valid http tracker tls configuration")); - match version { - Version::V1 => Some(start_v1(socket, tls, tracker.clone(), form).await), - } - } else { - info!("Note: Not loading Http Tracker Service, Not Enabled in Configuration."); - None + match version { + Version::V1 => Some(start_v1(socket, tls, tracker.clone(), form).await), } } @@ -93,7 +87,8 @@ mod tests { #[tokio::test] async fn it_should_start_http_tracker() { let cfg = Arc::new(ephemeral_mode_public()); - let config = &cfg.http_trackers[0]; + let http_tracker = cfg.http_trackers.clone().expect("missing HTTP tracker configuration"); + let config = &http_tracker[0]; let tracker = initialize_with_configuration(&cfg); let version = Version::V1; diff --git a/src/bootstrap/jobs/mod.rs b/src/bootstrap/jobs/mod.rs index 87a60772..79a4347e 100644 --- a/src/bootstrap/jobs/mod.rs +++ b/src/bootstrap/jobs/mod.rs @@ -43,9 +43,7 @@ pub async fn make_rust_tls(opt_tsl_config: &Option) -> Option { - None - } + None => None, } } diff --git a/src/bootstrap/jobs/tracker_apis.rs b/src/bootstrap/jobs/tracker_apis.rs index c3b12d7a..2067e5b0 100644 --- a/src/bootstrap/jobs/tracker_apis.rs +++ b/src/bootstrap/jobs/tracker_apis.rs @@ -26,7 +26,6 @@ use std::sync::Arc; use axum_server::tls_rustls::RustlsConfig; use tokio::task::JoinHandle; use torrust_tracker_configuration::{AccessTokens, HttpApi}; -use tracing::info; use super::make_rust_tls; use crate::core; @@ -60,21 +59,16 @@ pub async fn start_job( form: ServiceRegistrationForm, version: Version, ) -> Option> { - if config.enabled { - let bind_to = config.bind_address; + let bind_to = config.bind_address; - let tls = make_rust_tls(&config.tsl_config) - .await - .map(|tls| tls.expect("it should have a valid tracker api tls configuration")); + let tls = make_rust_tls(&config.tsl_config) + .await + .map(|tls| tls.expect("it should have a valid tracker api tls configuration")); - let access_tokens = Arc::new(config.access_tokens.clone()); + let access_tokens = Arc::new(config.access_tokens.clone()); - match version { - Version::V1 => Some(start_v1(bind_to, tls, tracker.clone(), form, access_tokens).await), - } - } else { - info!("Note: Not loading Http Tracker Service, Not Enabled in Configuration."); - None + match version { + Version::V1 => Some(start_v1(bind_to, tls, tracker.clone(), form, access_tokens).await), } } @@ -110,7 +104,7 @@ mod tests { #[tokio::test] async fn it_should_start_http_tracker() { let cfg = Arc::new(ephemeral_mode_public()); - let config = &cfg.http_api; + let config = &cfg.http_api.clone().unwrap(); let tracker = initialize_with_configuration(&cfg); let version = Version::V1; diff --git a/src/lib.rs b/src/lib.rs index 7f8c70a4..cf283441 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -192,21 +192,6 @@ //! external_ip = "0.0.0.0" //! on_reverse_proxy = false //! -//! [[udp_trackers]] -//! bind_address = "0.0.0.0:6969" -//! enabled = false -//! -//! [[http_trackers]] -//! bind_address = "0.0.0.0:7070" -//! enabled = false -//! -//! [http_api] -//! bind_address = "127.0.0.1:1212" -//! enabled = true -//! -//! [http_api.access_tokens] -//! admin = "MyAccessToken" -//! //! [health_check_api] //! bind_address = "127.0.0.1:1313" //!``` @@ -253,8 +238,10 @@ //! //! ```toml //! [http_api] -//! enabled = true //! bind_address = "127.0.0.1:1212" +//! +//! [http_api.access_tokens] +//! admin = "MyAccessToken" //! ``` //! //! By default it's enabled on port `1212`. You also need to add access tokens in the configuration: @@ -310,7 +297,6 @@ //! //! ```toml //! [[http_trackers]] -//! enabled = true //! bind_address = "0.0.0.0:7070" //! ``` //! @@ -405,7 +391,6 @@ //! //! ```toml //! [[udp_trackers]] -//! enabled = true //! bind_address = "0.0.0.0:6969" //! ``` //! diff --git a/src/servers/apis/mod.rs b/src/servers/apis/mod.rs index 02b93efa..6dae66c2 100644 --- a/src/servers/apis/mod.rs +++ b/src/servers/apis/mod.rs @@ -25,7 +25,6 @@ //! //! ```toml //! [http_api] -//! enabled = true //! bind_address = "0.0.0.0:1212" //! //! [http_api.tsl_config] @@ -112,7 +111,6 @@ //! //! ```toml //! [http_api] -//! enabled = true //! bind_address = "0.0.0.0:1212" //! //! [http_api.tsl_config] diff --git a/src/servers/apis/server.rs b/src/servers/apis/server.rs index 74dc8969..246660ab 100644 --- a/src/servers/apis/server.rs +++ b/src/servers/apis/server.rs @@ -274,7 +274,7 @@ mod tests { #[tokio::test] async fn it_should_be_able_to_start_and_stop() { let cfg = Arc::new(ephemeral_mode_public()); - let config = &cfg.http_api; + let config = &cfg.http_api.clone().unwrap(); let tracker = initialize_with_configuration(&cfg); diff --git a/src/servers/http/server.rs b/src/servers/http/server.rs index bbe0c3cc..5798f7c1 100644 --- a/src/servers/http/server.rs +++ b/src/servers/http/server.rs @@ -206,7 +206,7 @@ impl HttpServer { /// Or if the request returns an error. #[must_use] pub fn check_fn(binding: &SocketAddr) -> ServiceHealthCheckJob { - let url = format!("http://{binding}/health_check"); + let url = format!("http://{binding}/health_check"); // DevSkim: ignore DS137138 let info = format!("checking http tracker health check at: {url}"); @@ -235,7 +235,8 @@ mod tests { async fn it_should_be_able_to_start_and_stop() { let cfg = Arc::new(ephemeral_mode_public()); let tracker = initialize_with_configuration(&cfg); - let config = &cfg.http_trackers[0]; + let http_trackers = cfg.http_trackers.clone().expect("missing HTTP trackers configuration"); + let config = &http_trackers[0]; let bind_to = config.bind_address; diff --git a/src/servers/udp/server.rs b/src/servers/udp/server.rs index b2c72258..f36f7df4 100644 --- a/src/servers/udp/server.rs +++ b/src/servers/udp/server.rs @@ -460,7 +460,8 @@ mod tests { async fn it_should_be_able_to_start_and_stop() { let cfg = Arc::new(ephemeral_mode_public()); let tracker = initialize_with_configuration(&cfg); - let config = &cfg.udp_trackers[0]; + let udp_trackers = cfg.udp_trackers.clone().expect("missing UDP trackers configuration"); + let config = &udp_trackers[0]; let bind_to = config.bind_address; let register = &Registar::default(); diff --git a/tests/servers/api/environment.rs b/tests/servers/api/environment.rs index 8f84620d..dc2f70a7 100644 --- a/tests/servers/api/environment.rs +++ b/tests/servers/api/environment.rs @@ -31,7 +31,7 @@ impl Environment { pub fn new(configuration: &Arc) -> Self { let tracker = initialize_with_configuration(configuration); - let config = Arc::new(configuration.http_api.clone()); + let config = Arc::new(configuration.http_api.clone().expect("missing API configuration")); let bind_to = config.bind_address; diff --git a/tests/servers/http/environment.rs b/tests/servers/http/environment.rs index 6e80569e..2133ed6d 100644 --- a/tests/servers/http/environment.rs +++ b/tests/servers/http/environment.rs @@ -29,7 +29,12 @@ impl Environment { pub fn new(configuration: &Arc) -> Self { let tracker = initialize_with_configuration(configuration); - let config = Arc::new(configuration.http_trackers[0].clone()); + let http_tracker = configuration + .http_trackers + .clone() + .expect("missing HTTP tracker configuration"); + + let config = Arc::new(http_tracker[0].clone()); let bind_to = config.bind_address; diff --git a/tests/servers/udp/environment.rs b/tests/servers/udp/environment.rs index c1fecbdd..1ba038c7 100644 --- a/tests/servers/udp/environment.rs +++ b/tests/servers/udp/environment.rs @@ -29,7 +29,9 @@ impl Environment { pub fn new(configuration: &Arc) -> Self { let tracker = initialize_with_configuration(configuration); - let config = Arc::new(configuration.udp_trackers[0].clone()); + let udp_tracker = configuration.udp_trackers.clone().expect("missing UDP tracker configuration"); + + let config = Arc::new(udp_tracker[0].clone()); let bind_to = config.bind_address;