1
- use std:: net:: { IpAddr , Ipv4Addr } ;
2
-
3
1
use serde:: { Deserialize , Serialize } ;
4
2
use torrust_tracker_primitives:: TrackerMode ;
5
3
4
+ use super :: network:: Network ;
6
5
use crate :: v1:: database:: Database ;
7
6
use crate :: AnnouncePolicy ;
8
7
@@ -13,10 +12,6 @@ pub struct Core {
13
12
#[ serde( default = "Core::default_mode" ) ]
14
13
pub mode : TrackerMode ,
15
14
16
- // Database configuration.
17
- #[ serde( default = "Core::default_database" ) ]
18
- pub database : Database ,
19
-
20
15
/// See [`AnnouncePolicy::interval`]
21
16
#[ serde( default = "AnnouncePolicy::default_interval" ) ]
22
17
pub announce_interval : u32 ,
@@ -25,20 +20,6 @@ pub struct Core {
25
20
#[ serde( default = "AnnouncePolicy::default_interval_min" ) ]
26
21
pub min_announce_interval : u32 ,
27
22
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
-
42
23
/// Weather the tracker should collect statistics about tracker usage.
43
24
/// If enabled, the tracker will collect statistics like the number of
44
25
/// connections handled, the number of announce requests handled, etc.
@@ -71,6 +52,14 @@ pub struct Core {
71
52
/// enabled.
72
53
#[ serde( default = "Core::default_remove_peerless_torrents" ) ]
73
54
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 ,
74
63
}
75
64
76
65
impl Default for Core {
@@ -79,16 +68,15 @@ impl Default for Core {
79
68
80
69
Self {
81
70
mode : Self :: default_mode ( ) ,
82
- database : Self :: default_database ( ) ,
83
71
announce_interval : announce_policy. interval ,
84
72
min_announce_interval : announce_policy. interval_min ,
85
73
max_peer_timeout : Self :: default_max_peer_timeout ( ) ,
86
- on_reverse_proxy : Self :: default_on_reverse_proxy ( ) ,
87
- external_ip : Self :: default_external_ip ( ) ,
88
74
tracker_usage_statistics : Self :: default_tracker_usage_statistics ( ) ,
89
75
persistent_torrent_completed_stat : Self :: default_persistent_torrent_completed_stat ( ) ,
90
76
inactive_peer_cleanup_interval : Self :: default_inactive_peer_cleanup_interval ( ) ,
91
77
remove_peerless_torrents : Self :: default_remove_peerless_torrents ( ) ,
78
+ database : Self :: default_database ( ) ,
79
+ net : Self :: default_network ( ) ,
92
80
}
93
81
}
94
82
}
@@ -98,19 +86,6 @@ impl Core {
98
86
TrackerMode :: Public
99
87
}
100
88
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
-
114
89
fn default_tracker_usage_statistics ( ) -> bool {
115
90
true
116
91
}
@@ -130,4 +105,12 @@ impl Core {
130
105
fn default_remove_peerless_torrents ( ) -> bool {
131
106
true
132
107
}
108
+
109
+ fn default_database ( ) -> Database {
110
+ Database :: default ( )
111
+ }
112
+
113
+ fn default_network ( ) -> Network {
114
+ Network :: default ( )
115
+ }
133
116
}
0 commit comments