Skip to content

Align TrackerMode with Index #870

@josecelano

Description

@josecelano

In the Index the TrackerMode is defined with:

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum TrackerMode {
    // todo: use https://crates.io/crates/torrust-tracker-primitives
    /// Will track every new info hash and serve every peer.
    Public,
    /// Will only serve authenticated peers.
    Private,
    /// Will only track whitelisted info hashes.
    Whitelisted,
    /// Will only track whitelisted info hashes and serve authenticated peers.
    PrivateWhitelisted,
}

impl Default for TrackerMode {
    fn default() -> Self {
        Self::Public
    }
}

impl TrackerMode {
    #[must_use]
    pub fn is_open(&self) -> bool {
        matches!(self, TrackerMode::Public | TrackerMode::Whitelisted)
    }

    #[must_use]
    pub fn is_close(&self) -> bool {
        !self.is_open()
    }
}

We should get this type from the torrust-tracker-primitives crate and update the Index. Howeveer the Index has added the concept "open" and "close". We need to add this concept to the enum in the Tracker before we update the Index.

TrackerMode in the Tracker.

#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Eq, Debug)]
pub enum TrackerMode {
    /// Will track every new info hash and serve every peer.
    #[serde(rename = "public")]
    Public,

    /// Will only track whitelisted info hashes.
    #[serde(rename = "listed")]
    Listed,

    /// Will only serve authenticated peers
    #[serde(rename = "private")]
    Private,

    /// Will only track whitelisted info hashes and serve authenticated peers
    #[serde(rename = "private_listed")]
    PrivateListed,
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions