Skip to content

Commit

Permalink
refactor: [torrust#932] WIP. Add new core config options: private and…
Browse files Browse the repository at this point in the history
… listed
  • Loading branch information
josecelano committed Jul 1, 2024
1 parent 2186809 commit f5d8dc6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions packages/configuration/src/v1/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ pub struct Core {
#[serde(default = "Core::default_inactive_peer_cleanup_interval")]
pub inactive_peer_cleanup_interval: u64,

// Whe `true` only approved torrents can be announced in the tracker.
#[serde(default = "Core::default_listed")]
pub listed: bool,

/// Tracker mode. See [`TrackerMode`] for more information.
#[serde(default = "Core::default_mode")]
pub mode: TrackerMode,
Expand All @@ -29,6 +33,10 @@ pub struct Core {
#[serde(default = "Core::default_network")]
pub net: Network,

// Whe `true` clients require a key to connect and use the tracker.
#[serde(default = "Core::default_private")]
pub private: bool,

// Tracker policy configuration.
#[serde(default = "Core::default_tracker_policy")]
pub tracker_policy: TrackerPolicy,
Expand All @@ -48,8 +56,10 @@ impl Default for Core {
announce_policy: Self::default_announce_policy(),
database: Self::default_database(),
inactive_peer_cleanup_interval: Self::default_inactive_peer_cleanup_interval(),
listed: Self::default_listed(),
mode: Self::default_mode(),
net: Self::default_network(),
private: Self::default_private(),
tracker_policy: Self::default_tracker_policy(),
tracker_usage_statistics: Self::default_tracker_usage_statistics(),
}
Expand All @@ -69,6 +79,10 @@ impl Core {
600
}

fn default_listed() -> bool {
false
}

fn default_mode() -> TrackerMode {
TrackerMode::Public
}
Expand All @@ -77,6 +91,10 @@ impl Core {
Network::default()
}

fn default_private() -> bool {
false
}

fn default_tracker_policy() -> TrackerPolicy {
TrackerPolicy::default()
}
Expand Down
4 changes: 3 additions & 1 deletion packages/configuration/src/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,10 @@ mod tests {
[core]
mode = "public"
tracker_usage_statistics = true
inactive_peer_cleanup_interval = 600
listed = false
private = false
tracker_usage_statistics = true
[core.tracker_policy]
max_peer_timeout = 900
Expand Down

0 comments on commit f5d8dc6

Please sign in to comment.