torrust-tracker icon indicating copy to clipboard operation
torrust-tracker copied to clipboard

Tracker client: change the default `PeerId` use in clients

Open josecelano opened this issue 6 months ago • 0 comments

The default PeerId used in client requests is b"-qB00000000000000001".

The prefix -qB is used by qBittorrent. We should use a new one that is not already in use by another client.

  • https://wiki.theory.org/BitTorrentSpecification#peer_id
  • https://www.bittorrent.org/beps/bep_0020.html

I think we can use:

  • TC: In the future if we have a Torrust BitTorrent Client
  • RC: Now, for the Torrust Tracker (Rust) Client.
impl QueryBuilder {
    /// # Panics
    ///
    /// Will panic if the default info-hash value is not a valid info-hash.
    #[must_use]
    pub fn with_default_values() -> QueryBuilder {
        let default_announce_query = Query {
            info_hash: InfoHash::from_str("9c38422213e30bff212b30c360d26f9a02136422").unwrap().0, // DevSkim: ignore DS173237
            peer_addr: IpAddr::V4(Ipv4Addr::new(192, 168, 1, 88)),
            downloaded: 0,
            uploaded: 0,
            peer_id: PeerId(*b"b"-qB00000000000000001"00000000000000001").0,
            port: 17548,
            left: 0,
            event: Some(Event::Started),
            compact: Some(Compact::NotAccepted),
        };
        Self {
            announce_query: default_announce_query,
        }
    }

We can use a random ID, for example: b"-RC53070047639607806"

cc @da2ce7

josecelano avatar Jun 09 '25 10:06 josecelano