11use serde:: { Deserialize , Serialize } ;
2- use torrust_tracker_primitives:: TrackerMode ;
32
43use super :: network:: Network ;
54use crate :: v1:: database:: Database ;
@@ -8,27 +7,6 @@ use crate::{AnnouncePolicy, TrackerPolicy};
87#[ allow( clippy:: struct_excessive_bools) ]
98#[ derive( Serialize , Deserialize , PartialEq , Eq , Debug , Clone ) ]
109pub struct Core {
11- /// Tracker mode. See [`TrackerMode`] for more information.
12- #[ serde( default = "Core::default_mode" ) ]
13- pub mode : TrackerMode ,
14-
15- /// Weather the tracker should collect statistics about tracker usage.
16- /// If enabled, the tracker will collect statistics like the number of
17- /// connections handled, the number of announce requests handled, etc.
18- /// Refer to the [`Tracker`](https://docs.rs/torrust-tracker) for more
19- /// information about the collected metrics.
20- #[ serde( default = "Core::default_tracker_usage_statistics" ) ]
21- pub tracker_usage_statistics : bool ,
22-
23- /// Interval in seconds that the cleanup job will run to remove inactive
24- /// peers from the torrent peer list.
25- #[ serde( default = "Core::default_inactive_peer_cleanup_interval" ) ]
26- pub inactive_peer_cleanup_interval : u64 ,
27-
28- // Tracker policy configuration.
29- #[ serde( default = "Core::default_tracker_policy" ) ]
30- pub tracker_policy : TrackerPolicy ,
31-
3210 // Announce policy configuration.
3311 #[ serde( default = "Core::default_announce_policy" ) ]
3412 pub announce_policy : AnnouncePolicy ,
@@ -37,51 +15,80 @@ pub struct Core {
3715 #[ serde( default = "Core::default_database" ) ]
3816 pub database : Database ,
3917
18+ /// Interval in seconds that the cleanup job will run to remove inactive
19+ /// peers from the torrent peer list.
20+ #[ serde( default = "Core::default_inactive_peer_cleanup_interval" ) ]
21+ pub inactive_peer_cleanup_interval : u64 ,
22+
23+ // When `true` only approved torrents can be announced in the tracker.
24+ #[ serde( default = "Core::default_listed" ) ]
25+ pub listed : bool ,
26+
4027 // Network configuration.
4128 #[ serde( default = "Core::default_network" ) ]
4229 pub net : Network ,
30+
31+ // When `true` clients require a key to connect and use the tracker.
32+ #[ serde( default = "Core::default_private" ) ]
33+ pub private : bool ,
34+
35+ // Tracker policy configuration.
36+ #[ serde( default = "Core::default_tracker_policy" ) ]
37+ pub tracker_policy : TrackerPolicy ,
38+
39+ /// Weather the tracker should collect statistics about tracker usage.
40+ /// If enabled, the tracker will collect statistics like the number of
41+ /// connections handled, the number of announce requests handled, etc.
42+ /// Refer to the [`Tracker`](https://docs.rs/torrust-tracker) for more
43+ /// information about the collected metrics.
44+ #[ serde( default = "Core::default_tracker_usage_statistics" ) ]
45+ pub tracker_usage_statistics : bool ,
4346}
4447
4548impl Default for Core {
4649 fn default ( ) -> Self {
4750 Self {
48- mode : Self :: default_mode ( ) ,
49- tracker_usage_statistics : Self :: default_tracker_usage_statistics ( ) ,
50- inactive_peer_cleanup_interval : Self :: default_inactive_peer_cleanup_interval ( ) ,
51- tracker_policy : Self :: default_tracker_policy ( ) ,
5251 announce_policy : Self :: default_announce_policy ( ) ,
5352 database : Self :: default_database ( ) ,
53+ inactive_peer_cleanup_interval : Self :: default_inactive_peer_cleanup_interval ( ) ,
54+ listed : Self :: default_listed ( ) ,
5455 net : Self :: default_network ( ) ,
56+ private : Self :: default_private ( ) ,
57+ tracker_policy : Self :: default_tracker_policy ( ) ,
58+ tracker_usage_statistics : Self :: default_tracker_usage_statistics ( ) ,
5559 }
5660 }
5761}
5862
5963impl Core {
60- fn default_mode ( ) -> TrackerMode {
61- TrackerMode :: Public
64+ fn default_announce_policy ( ) -> AnnouncePolicy {
65+ AnnouncePolicy :: default ( )
6266 }
6367
64- fn default_tracker_usage_statistics ( ) -> bool {
65- true
68+ fn default_database ( ) -> Database {
69+ Database :: default ( )
6670 }
6771
6872 fn default_inactive_peer_cleanup_interval ( ) -> u64 {
6973 600
7074 }
7175
72- fn default_tracker_policy ( ) -> TrackerPolicy {
73- TrackerPolicy :: default ( )
76+ fn default_listed ( ) -> bool {
77+ false
7478 }
7579
76- fn default_announce_policy ( ) -> AnnouncePolicy {
77- AnnouncePolicy :: default ( )
80+ fn default_network ( ) -> Network {
81+ Network :: default ( )
7882 }
7983
80- fn default_database ( ) -> Database {
81- Database :: default ( )
84+ fn default_private ( ) -> bool {
85+ false
8286 }
8387
84- fn default_network ( ) -> Network {
85- Network :: default ( )
88+ fn default_tracker_policy ( ) -> TrackerPolicy {
89+ TrackerPolicy :: default ( )
90+ }
91+ fn default_tracker_usage_statistics ( ) -> bool {
92+ true
8693 }
8794}
0 commit comments