191
191
//! The default configuration is:
192
192
//!
193
193
//! ```toml
194
- //! log_level = "info"
195
- //! mode = "public"
194
+ //! announce_interval = 120
196
195
//! db_driver = "Sqlite3"
197
196
//! 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"
200
200
//! max_peer_timeout = 900
201
+ //! min_announce_interval = 120
202
+ //! mode = "public"
201
203
//! on_reverse_proxy = false
202
- //! external_ip = "0.0.0.0"
203
- //! tracker_usage_statistics = true
204
204
//! persistent_torrent_completed_stat = false
205
- //! inactive_peer_cleanup_interval = 600
206
205
//! remove_peerless_torrents = true
206
+ //! tracker_usage_statistics = true
207
207
//!
208
208
//! [[udp_trackers]]
209
- //! enabled = false
210
209
//! bind_address = "0.0.0.0:6969"
210
+ //! enabled = false
211
211
//!
212
212
//! [[http_trackers]]
213
- //! enabled = false
214
213
//! bind_address = "0.0.0.0:7070"
215
- //! ssl_enabled = false
214
+ //! enabled = false
216
215
//! ssl_cert_path = ""
216
+ //! ssl_enabled = false
217
217
//! ssl_key_path = ""
218
218
//!
219
219
//! [http_api]
220
- //! enabled = true
221
220
//! bind_address = "127.0.0.1:1212"
222
- //! ssl_enabled = false
221
+ //! enabled = true
223
222
//! ssl_cert_path = ""
223
+ //! ssl_enabled = false
224
224
//! ssl_key_path = ""
225
225
//!
226
226
//! [http_api.access_tokens]
227
227
//! admin = "MyAccessToken"
228
+ //!
229
+ //! [health_check_api]
230
+ //! bind_address = "127.0.0.1:1313"
228
231
//!```
229
232
use std:: collections:: { HashMap , HashSet } ;
230
233
use std:: net:: IpAddr ;
@@ -342,7 +345,7 @@ pub struct HttpApi {
342
345
/// The address the tracker will bind to.
343
346
/// The format is `ip:port`, for example `0.0.0.0:6969`. If you want to
344
347
/// 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`.
346
349
pub bind_address : String ,
347
350
/// Weather the HTTP API will use SSL or not.
348
351
pub ssl_enabled : bool ,
@@ -363,9 +366,7 @@ impl HttpApi {
363
366
fn override_admin_token ( & mut self , api_admin_token : & str ) {
364
367
self . access_tokens . insert ( "admin" . to_string ( ) , api_admin_token. to_string ( ) ) ;
365
368
}
366
- }
367
369
368
- impl HttpApi {
369
370
/// Checks if the given token is one of the token in the configuration.
370
371
#[ must_use]
371
372
pub fn contains_token ( & self , token : & str ) -> bool {
@@ -375,6 +376,17 @@ impl HttpApi {
375
376
}
376
377
}
377
378
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
+
378
390
/// Core configuration for the tracker.
379
391
#[ allow( clippy:: struct_excessive_bools) ]
380
392
#[ derive( Serialize , Deserialize , PartialEq , Eq , Debug ) ]
@@ -465,6 +477,8 @@ pub struct Configuration {
465
477
pub http_trackers : Vec < HttpTracker > ,
466
478
/// The HTTP API configuration.
467
479
pub http_api : HttpApi ,
480
+ /// The Health Check API configuration.
481
+ pub health_check_api : HealthCheckApi ,
468
482
}
469
483
470
484
/// Errors that can occur when loading the configuration.
@@ -529,6 +543,9 @@ impl Default for Configuration {
529
543
. cloned ( )
530
544
. collect ( ) ,
531
545
} ,
546
+ health_check_api : HealthCheckApi {
547
+ bind_address : String :: from ( "127.0.0.1:1313" ) ,
548
+ } ,
532
549
} ;
533
550
configuration. udp_trackers . push ( UdpTracker {
534
551
enabled : false ,
@@ -676,6 +693,9 @@ mod tests {
676
693
677
694
[http_api.access_tokens]
678
695
admin = "MyAccessToken"
696
+
697
+ [health_check_api]
698
+ bind_address = "127.0.0.1:1313"
679
699
"#
680
700
. lines ( )
681
701
. map ( str:: trim_start)
0 commit comments