pub struct Configuration {
Show 16 fields pub log_level: Option<String>, pub mode: TrackerMode, pub db_driver: DatabaseDriver, pub db_path: String, pub announce_interval: u32, pub min_announce_interval: u32, pub on_reverse_proxy: bool, pub external_ip: Option<String>, pub tracker_usage_statistics: bool, pub persistent_torrent_completed_stat: bool, pub max_peer_timeout: u32, pub inactive_peer_cleanup_interval: u64, pub remove_peerless_torrents: bool, pub udp_trackers: Vec<UdpTracker>, pub http_trackers: Vec<HttpTracker>, pub http_api: HttpApi,
}
Expand description

Core configuration for the tracker.

Fields§

§log_level: Option<String>

Logging level. Possible values are: Off, Error, Warn, Info, Debug and Trace. Default is Info.

§mode: TrackerMode

Tracker mode. See TrackerMode for more information.

§db_driver: DatabaseDriver

Database driver. Possible values are: Sqlite3, and MySQL.

§db_path: String

Database connection string. The format depends on the database driver. For Sqlite3, the format is path/to/database.db, for example: ./storage/database/data.db. For Mysql, the format is mysql://db_user:db_user_password:port/db_name, for example: root:password@localhost:3306/torrust.

§announce_interval: u32

Interval in seconds that the client should wait between sending regular announce requests to the tracker.

It’s a recommended wait time between announcements.

This is the standard amount of time that clients should wait between sending consecutive announcements to the tracker. This value is set by the tracker and is typically provided in the tracker’s response to a client’s initial request. It serves as a guideline for clients to know how often they should contact the tracker for updates on the peer list, while ensuring that the tracker is not overwhelmed with requests.

§min_announce_interval: u32

Minimum announce interval. Clients must not reannounce more frequently than this.

It establishes the shortest allowed wait time.

This is an optional parameter in the protocol that the tracker may provide in its response. It sets a lower limit on the frequency at which clients are allowed to send announcements. Clients should respect this value to prevent sending too many requests in a short period, which could lead to excessive load on the tracker or even getting banned by the tracker for not adhering to the rules.

§on_reverse_proxy: bool

Weather the tracker is behind a reverse proxy or not. If the tracker is behind a reverse proxy, the X-Forwarded-For header sent from the proxy will be used to get the client’s IP address.

§external_ip: Option<String>

The external IP address of the tracker. If the client is using a loopback IP address, this IP address will be used instead. If the peer is using a loopback IP address, the tracker assumes that the peer is in the same network as the tracker and will use the tracker’s IP address instead.

§tracker_usage_statistics: bool

Weather the tracker should collect statistics about tracker usage. If enabled, the tracker will collect statistics like the number of connections handled, the number of announce requests handled, etc. Refer to the Tracker for more information about the collected metrics.

§persistent_torrent_completed_stat: bool

If enabled the tracker will persist the number of completed downloads. That’s how many times a torrent has been downloaded completely.

§max_peer_timeout: u32

Maximum time in seconds that a peer can be inactive before being considered an inactive peer. If a peer is inactive for more than this time, it will be removed from the torrent peer list.

§inactive_peer_cleanup_interval: u64

Interval in seconds that the cleanup job will run to remove inactive peers from the torrent peer list.

§remove_peerless_torrents: bool

If enabled, the tracker will remove torrents that have no peers. THe clean up torrent job runs every inactive_peer_cleanup_interval seconds and it removes inactive peers. Eventually, the peer list of a torrent could be empty and the torrent will be removed if this option is enabled.

§udp_trackers: Vec<UdpTracker>

The list of UDP trackers the tracker is running. Each UDP tracker represents a UDP server that the tracker is running and it has its own configuration.

§http_trackers: Vec<HttpTracker>

The list of HTTP trackers the tracker is running. Each HTTP tracker represents a HTTP server that the tracker is running and it has its own configuration.

§http_api: HttpApi

The HTTP API configuration.

Implementations§

source§

impl Configuration

source

pub fn get_ext_ip(&self) -> Option<IpAddr>

Returns the tracker public IP address id defined in the configuration, and None otherwise.

source

pub fn load_from_file(path: &str) -> Result<Configuration, Error>

Loads the configuration from the configuration file.

Errors

Will return Err if path does not exist or has a bad configuration.

source

pub fn load_from_env_var( config_env_var_name: &str ) -> Result<Configuration, Error>

Loads the configuration from the environment variable. The whole configuration must be in the environment variable. It contains the same configuration as the configuration file with the same format.

Errors

Will return Err if the environment variable does not exist or has a bad configuration.

source

pub fn save_to_file(&self, path: &str) -> Result<(), Error>

Saves the configuration to the configuration file.

Errors

Will return Err if filename does not exist or the user does not have permission to read it. Will also return Err if the configuration is not valid or cannot be encoded to TOML.

Trait Implementations§

source§

impl Debug for Configuration

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Configuration

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Configuration

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq<Configuration> for Configuration

source§

fn eq(&self, other: &Configuration) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Configuration

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Configuration

source§

impl StructuralEq for Configuration

source§

impl StructuralPartialEq for Configuration

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,