1- use std:: net:: { IpAddr , Ipv4Addr } ;
2-
31use serde:: { Deserialize , Serialize } ;
42use torrust_tracker_primitives:: TrackerMode ;
53
4+ use super :: network:: Network ;
65use crate :: v1:: database:: Database ;
76use crate :: AnnouncePolicy ;
87
@@ -13,10 +12,6 @@ pub struct Core {
1312 #[ serde( default = "Core::default_mode" ) ]
1413 pub mode : TrackerMode ,
1514
16- // Database configuration.
17- #[ serde( default = "Core::default_database" ) ]
18- pub database : Database ,
19-
2015 /// See [`AnnouncePolicy::interval`]
2116 #[ serde( default = "AnnouncePolicy::default_interval" ) ]
2217 pub announce_interval : u32 ,
@@ -25,20 +20,6 @@ pub struct Core {
2520 #[ serde( default = "AnnouncePolicy::default_interval_min" ) ]
2621 pub min_announce_interval : u32 ,
2722
28- /// Weather the tracker is behind a reverse proxy or not.
29- /// If the tracker is behind a reverse proxy, the `X-Forwarded-For` header
30- /// sent from the proxy will be used to get the client's IP address.
31- #[ serde( default = "Core::default_on_reverse_proxy" ) ]
32- pub on_reverse_proxy : bool ,
33-
34- /// The external IP address of the tracker. If the client is using a
35- /// loopback IP address, this IP address will be used instead. If the peer
36- /// is using a loopback IP address, the tracker assumes that the peer is
37- /// in the same network as the tracker and will use the tracker's IP
38- /// address instead.
39- #[ serde( default = "Core::default_external_ip" ) ]
40- pub external_ip : Option < IpAddr > ,
41-
4223 /// Weather the tracker should collect statistics about tracker usage.
4324 /// If enabled, the tracker will collect statistics like the number of
4425 /// connections handled, the number of announce requests handled, etc.
@@ -71,6 +52,14 @@ pub struct Core {
7152 /// enabled.
7253 #[ serde( default = "Core::default_remove_peerless_torrents" ) ]
7354 pub remove_peerless_torrents : bool ,
55+
56+ // Database configuration.
57+ #[ serde( default = "Core::default_database" ) ]
58+ pub database : Database ,
59+
60+ // Network configuration.
61+ #[ serde( default = "Core::default_network" ) ]
62+ pub net : Network ,
7463}
7564
7665impl Default for Core {
@@ -79,16 +68,15 @@ impl Default for Core {
7968
8069 Self {
8170 mode : Self :: default_mode ( ) ,
82- database : Self :: default_database ( ) ,
8371 announce_interval : announce_policy. interval ,
8472 min_announce_interval : announce_policy. interval_min ,
8573 max_peer_timeout : Self :: default_max_peer_timeout ( ) ,
86- on_reverse_proxy : Self :: default_on_reverse_proxy ( ) ,
87- external_ip : Self :: default_external_ip ( ) ,
8874 tracker_usage_statistics : Self :: default_tracker_usage_statistics ( ) ,
8975 persistent_torrent_completed_stat : Self :: default_persistent_torrent_completed_stat ( ) ,
9076 inactive_peer_cleanup_interval : Self :: default_inactive_peer_cleanup_interval ( ) ,
9177 remove_peerless_torrents : Self :: default_remove_peerless_torrents ( ) ,
78+ database : Self :: default_database ( ) ,
79+ net : Self :: default_network ( ) ,
9280 }
9381 }
9482}
@@ -98,19 +86,6 @@ impl Core {
9886 TrackerMode :: Public
9987 }
10088
101- fn default_database ( ) -> Database {
102- Database :: default ( )
103- }
104-
105- fn default_on_reverse_proxy ( ) -> bool {
106- false
107- }
108-
109- #[ allow( clippy:: unnecessary_wraps) ]
110- fn default_external_ip ( ) -> Option < IpAddr > {
111- Some ( IpAddr :: V4 ( Ipv4Addr :: new ( 0 , 0 , 0 , 0 ) ) )
112- }
113-
11489 fn default_tracker_usage_statistics ( ) -> bool {
11590 true
11691 }
@@ -130,4 +105,12 @@ impl Core {
130105 fn default_remove_peerless_torrents ( ) -> bool {
131106 true
132107 }
108+
109+ fn default_database ( ) -> Database {
110+ Database :: default ( )
111+ }
112+
113+ fn default_network ( ) -> Network {
114+ Network :: default ( )
115+ }
133116}
0 commit comments