pub struct TrackerConfig { /* private fields */ }Expand description
Tracker deployment configuration
This structure mirrors the real tracker configuration but only includes user-configurable fields that are exposed via the environment.json file.
§Examples
use torrust_tracker_deployer_lib::domain::tracker::{
TrackerConfig, TrackerCoreConfig, DatabaseConfig, SqliteConfig,
UdpTrackerConfig, HttpTrackerConfig, HttpApiConfig, HealthCheckApiConfig
};
let tracker_config = TrackerConfig::new(
TrackerCoreConfig::new(
DatabaseConfig::Sqlite(SqliteConfig::new("tracker.db").unwrap()),
false,
),
vec![UdpTrackerConfig::new("0.0.0.0:6969".parse().unwrap(), None).unwrap()],
vec![HttpTrackerConfig::new("0.0.0.0:7070".parse().unwrap(), None, false).unwrap()],
HttpApiConfig::new(
"0.0.0.0:1212".parse().unwrap(),
"MyAccessToken".to_string().into(),
None,
false,
).expect("valid config"),
HealthCheckApiConfig::new(
"127.0.0.1:1313".parse().unwrap(),
None,
false,
).expect("valid config"),
).expect("valid config");Implementations§
Source§impl TrackerConfig
impl TrackerConfig
Sourcepub fn new(
core: TrackerCoreConfig,
udp_trackers: Vec<UdpTrackerConfig>,
http_trackers: Vec<HttpTrackerConfig>,
http_api: HttpApiConfig,
health_check_api: HealthCheckApiConfig,
) -> Result<Self, TrackerConfigError>
pub fn new( core: TrackerCoreConfig, udp_trackers: Vec<UdpTrackerConfig>, http_trackers: Vec<HttpTrackerConfig>, http_api: HttpApiConfig, health_check_api: HealthCheckApiConfig, ) -> Result<Self, TrackerConfigError>
Creates a new TrackerConfig with validated aggregate invariants.
This constructor validates that no socket address conflicts exist (multiple services binding to the same IP:port:protocol combination).
§Errors
Returns TrackerConfigError::DuplicateSocketAddress if multiple services
using the same protocol attempt to bind to the same socket address.
§Note
Individual component validation (port != 0, TLS requires domain, localhost cannot use TLS) is enforced by the child config types at their construction time. This constructor only validates aggregate-level invariants.
§Examples
use torrust_tracker_deployer_lib::domain::tracker::{
TrackerConfig, TrackerCoreConfig, DatabaseConfig, SqliteConfig,
UdpTrackerConfig, HttpTrackerConfig, HttpApiConfig, HealthCheckApiConfig
};
let config = TrackerConfig::new(
TrackerCoreConfig::new(
DatabaseConfig::Sqlite(SqliteConfig::new("tracker.db").unwrap()),
false,
),
vec![UdpTrackerConfig::new("0.0.0.0:6969".parse().unwrap(), None).unwrap()],
vec![HttpTrackerConfig::new("0.0.0.0:7070".parse().unwrap(), None, false).unwrap()],
HttpApiConfig::new(
"0.0.0.0:1212".parse().unwrap(),
"MyAccessToken".to_string().into(),
None,
false,
).unwrap(),
HealthCheckApiConfig::new(
"127.0.0.1:1313".parse().unwrap(),
None,
false,
).unwrap(),
).expect("valid config");Sourcepub fn core(&self) -> &TrackerCoreConfig
pub fn core(&self) -> &TrackerCoreConfig
Returns the core tracker configuration.
Sourcepub fn udp_trackers(&self) -> &[UdpTrackerConfig]
pub fn udp_trackers(&self) -> &[UdpTrackerConfig]
Returns the UDP tracker configurations.
Sourcepub fn http_trackers(&self) -> &[HttpTrackerConfig]
pub fn http_trackers(&self) -> &[HttpTrackerConfig]
Returns the HTTP tracker configurations.
Sourcepub fn http_api(&self) -> &HttpApiConfig
pub fn http_api(&self) -> &HttpApiConfig
Returns the HTTP API configuration.
Sourcepub fn health_check_api(&self) -> &HealthCheckApiConfig
pub fn health_check_api(&self) -> &HealthCheckApiConfig
Returns the Health Check API configuration.
Sourcepub fn uses_mysql(&self) -> bool
pub fn uses_mysql(&self) -> bool
Returns whether the tracker is configured to use MySQL database.
This is useful for determining if MySQL-related infrastructure (like storage directories) needs to be created.
§Examples
use torrust_tracker_deployer_lib::domain::tracker::{
TrackerConfig, TrackerCoreConfig, DatabaseConfig, SqliteConfig,
UdpTrackerConfig, HttpTrackerConfig, HttpApiConfig, HealthCheckApiConfig
};
let tracker_config = TrackerConfig::new(
TrackerCoreConfig::new(
DatabaseConfig::Sqlite(SqliteConfig::new("tracker.db").unwrap()),
false,
),
vec![UdpTrackerConfig::new("0.0.0.0:6969".parse().unwrap(), None).unwrap()],
vec![HttpTrackerConfig::new("0.0.0.0:7070".parse().unwrap(), None, false).unwrap()],
HttpApiConfig::new(
"0.0.0.0:1212".parse().unwrap(),
"MyAccessToken".to_string().into(),
None,
false,
).expect("valid config"),
HealthCheckApiConfig::new(
"127.0.0.1:1313".parse().unwrap(),
None,
false,
).expect("valid config"),
).expect("valid config");
// SQLite config -> not MySQL
assert!(!tracker_config.uses_mysql());Sourcepub fn docker_image() -> DockerImage
pub fn docker_image() -> DockerImage
Returns the Docker image used for the tracker service.
This is a pinned constant — not user-configurable.
§Examples
use torrust_tracker_deployer_lib::domain::tracker::TrackerConfig;
let image = TrackerConfig::docker_image();
assert_eq!(image.full_reference(), "torrust/tracker:develop");Sourcepub fn http_api_tls_domain(&self) -> Option<&str>
pub fn http_api_tls_domain(&self) -> Option<&str>
Returns the HTTP API TLS domain if configured
Sourcepub fn http_api_port(&self) -> u16
pub fn http_api_port(&self) -> u16
Returns the HTTP API port number
Sourcepub fn health_check_api_tls_domain(&self) -> Option<&str>
pub fn health_check_api_tls_domain(&self) -> Option<&str>
Returns the Health Check API TLS domain if configured
Sourcepub fn health_check_api_port(&self) -> u16
pub fn health_check_api_port(&self) -> u16
Returns the Health Check API port number
Sourcepub fn http_trackers_with_tls(&self) -> Vec<(&str, u16)>
pub fn http_trackers_with_tls(&self) -> Vec<(&str, u16)>
Returns HTTP trackers that have TLS proxy enabled
Returns a vector of tuples containing (domain, port) for each
HTTP tracker that has use_tls_proxy: true and a domain configured.
Sourcepub fn any_http_tracker_uses_tls_proxy(&self) -> bool
pub fn any_http_tracker_uses_tls_proxy(&self) -> bool
Returns true if any HTTP tracker has use_tls_proxy: true
This is used to determine if the tracker’s global on_reverse_proxy
setting should be enabled in the tracker configuration template.
Sourcepub fn has_any_tls_configured(&self) -> bool
pub fn has_any_tls_configured(&self) -> bool
Returns true if any service has TLS proxy configured
Checks if at least one of the following services has TLS enabled:
- HTTP API (
use_tls_proxy: true) - Any HTTP tracker (
use_tls_proxy: true) - Health Check API (
use_tls_proxy: true)
This is used for cross-service validation to ensure that when the HTTPS section is defined, at least one service actually uses TLS.
Trait Implementations§
Source§impl Clone for TrackerConfig
impl Clone for TrackerConfig
Source§impl Debug for TrackerConfig
impl Debug for TrackerConfig
Source§impl Default for TrackerConfig
impl Default for TrackerConfig
Source§fn default() -> Self
fn default() -> Self
Returns a default tracker configuration suitable for development and testing
§Default Values
- Database:
SQLitewith filename “tracker.db” - Mode: Public tracker (private = false)
- UDP trackers: One instance on port 6969
- HTTP trackers: One instance on port 7070
- HTTP API: Bind address 0.0.0.0:1212
- Admin token:
MyAccessToken
Source§impl<'de> Deserialize<'de> for TrackerConfig
impl<'de> Deserialize<'de> for TrackerConfig
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl NetworkDerivation for TrackerConfig
impl NetworkDerivation for TrackerConfig
Source§fn derive_networks(&self, enabled_services: &EnabledServices) -> Vec<Network>
fn derive_networks(&self, enabled_services: &EnabledServices) -> Vec<Network>
Derives network assignments for the Tracker service
Implements NET-01 through NET-03:
- NET-01: Metrics network if Prometheus enabled
- NET-02: Database network if
MySQLenabled - NET-03: Proxy network if Caddy enabled
Source§impl PartialEq for TrackerConfig
impl PartialEq for TrackerConfig
Source§impl PortDerivation for TrackerConfig
impl PortDerivation for TrackerConfig
Source§fn derive_ports(&self) -> Vec<PortBinding>
fn derive_ports(&self) -> Vec<PortBinding>
Derives port bindings for the Tracker service
Implements PORT-01 through PORT-06:
- PORT-01: Tracker needs ports if UDP OR HTTP without TLS OR API without TLS
- PORT-02: UDP ports always exposed (UDP doesn’t use TLS)
- PORT-03: HTTP ports WITHOUT TLS exposed directly
- PORT-04: HTTP ports WITH TLS NOT exposed (Caddy handles)
- PORT-05: API port exposed only when no TLS
- PORT-06: API port NOT exposed when TLS
Source§impl Serialize for TrackerConfig
impl Serialize for TrackerConfig
impl StructuralPartialEq for TrackerConfig
Source§impl TryFrom<TrackerSection> for TrackerConfig
impl TryFrom<TrackerSection> for TrackerConfig
Source§type Error = CreateConfigError
type Error = CreateConfigError
Auto Trait Implementations§
impl Freeze for TrackerConfig
impl RefUnwindSafe for TrackerConfig
impl Send for TrackerConfig
impl Sync for TrackerConfig
impl Unpin for TrackerConfig
impl UnsafeUnpin for TrackerConfig
impl UnwindSafe for TrackerConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request