191191//! The default configuration is:
192192//!
193193//! ```toml
194- //! log_level = "info"
195- //! mode = "public"
194+ //! announce_interval = 120
196195//! db_driver = "Sqlite3"
197196//! db_path = "./storage/tracker/lib/database/sqlite3.db"
198- //! announce_interval = 120
199- //! min_announce_interval = 120
197+ //! external_ip = "0.0.0.0"
198+ //! inactive_peer_cleanup_interval = 600
199+ //! log_level = "info"
200200//! max_peer_timeout = 900
201+ //! min_announce_interval = 120
202+ //! mode = "public"
201203//! on_reverse_proxy = false
202- //! external_ip = "0.0.0.0"
203- //! tracker_usage_statistics = true
204204//! persistent_torrent_completed_stat = false
205- //! inactive_peer_cleanup_interval = 600
206205//! remove_peerless_torrents = true
206+ //! tracker_usage_statistics = true
207207//!
208208//! [[udp_trackers]]
209- //! enabled = false
210209//! bind_address = "0.0.0.0:6969"
210+ //! enabled = false
211211//!
212212//! [[http_trackers]]
213- //! enabled = false
214213//! bind_address = "0.0.0.0:7070"
215- //! ssl_enabled = false
214+ //! enabled = false
216215//! ssl_cert_path = ""
216+ //! ssl_enabled = false
217217//! ssl_key_path = ""
218218//!
219219//! [http_api]
220- //! enabled = true
221220//! bind_address = "127.0.0.1:1212"
222- //! ssl_enabled = false
221+ //! enabled = true
223222//! ssl_cert_path = ""
223+ //! ssl_enabled = false
224224//! ssl_key_path = ""
225225//!
226226//! [http_api.access_tokens]
227227//! admin = "MyAccessToken"
228+ //!
229+ //! [health_check_api]
230+ //! bind_address = "127.0.0.1:1313"
228231//!```
229232use std:: collections:: { HashMap , HashSet } ;
230233use std:: net:: IpAddr ;
@@ -342,7 +345,7 @@ pub struct HttpApi {
342345 /// The address the tracker will bind to.
343346 /// The format is `ip:port`, for example `0.0.0.0:6969`. If you want to
344347 /// listen to all interfaces, use `0.0.0.0`. If you want the operating
345- /// system to choose a random port, use port `0`.
348+ /// system to choose a random port, use port `0`.
346349 pub bind_address : String ,
347350 /// Weather the HTTP API will use SSL or not.
348351 pub ssl_enabled : bool ,
@@ -363,9 +366,7 @@ impl HttpApi {
363366 fn override_admin_token ( & mut self , api_admin_token : & str ) {
364367 self . access_tokens . insert ( "admin" . to_string ( ) , api_admin_token. to_string ( ) ) ;
365368 }
366- }
367369
368- impl HttpApi {
369370 /// Checks if the given token is one of the token in the configuration.
370371 #[ must_use]
371372 pub fn contains_token ( & self , token : & str ) -> bool {
@@ -375,6 +376,17 @@ impl HttpApi {
375376 }
376377}
377378
379+ /// Configuration for the Health Check API.
380+ #[ serde_as]
381+ #[ derive( Serialize , Deserialize , PartialEq , Eq , Debug , Clone ) ]
382+ pub struct HealthCheckApi {
383+ /// The address the API will bind to.
384+ /// The format is `ip:port`, for example `127.0.0.1:1313`. If you want to
385+ /// listen to all interfaces, use `0.0.0.0`. If you want the operating
386+ /// system to choose a random port, use port `0`.
387+ pub bind_address : String ,
388+ }
389+
378390/// Core configuration for the tracker.
379391#[ allow( clippy:: struct_excessive_bools) ]
380392#[ derive( Serialize , Deserialize , PartialEq , Eq , Debug ) ]
@@ -465,6 +477,8 @@ pub struct Configuration {
465477 pub http_trackers : Vec < HttpTracker > ,
466478 /// The HTTP API configuration.
467479 pub http_api : HttpApi ,
480+ /// The Health Check API configuration.
481+ pub health_check_api : HealthCheckApi ,
468482}
469483
470484/// Errors that can occur when loading the configuration.
@@ -529,6 +543,9 @@ impl Default for Configuration {
529543 . cloned ( )
530544 . collect ( ) ,
531545 } ,
546+ health_check_api : HealthCheckApi {
547+ bind_address : String :: from ( "127.0.0.1:1313" ) ,
548+ } ,
532549 } ;
533550 configuration. udp_trackers . push ( UdpTracker {
534551 enabled : false ,
@@ -676,6 +693,9 @@ mod tests {
676693
677694 [http_api.access_tokens]
678695 admin = "MyAccessToken"
696+
697+ [health_check_api]
698+ bind_address = "127.0.0.1:1313"
679699 "#
680700 . lines ( )
681701 . map ( str:: trim_start)
0 commit comments