Skip to content

Overhaul stats: Add announced Peer to HTTP core announce event #1376

Description

@josecelano

Depends on: #1341

IMPORTANT: This has to be implemented after #1341.

I'm refactoring events to include more metadata:

pub enum Event {
    TcpAnnounce { connection: ConnectionContext },
    TcpScrape { connection: ConnectionContext },
}

It would also be convenient to include information about the announce request, in the event, like the peer.

pub enum Event {
    TcpAnnounce { connection: ConnectionContext, peer: Peer, original_peer_ip: IpAddr },
    TcpScrape { connection: ConnectionContext },
}

Where the Peer is the peer defined in primitive types.

NOTICE: The tracker might change the peer IP, depending on tracker configuration, like whether the tracker is running behind a reverse proxy or not. I have also added the original_peer_ip to the event; otherwise, that info would be lost. I want the events to have all the info needed to re-build exactly the tracker history if needed.

That's the only information that the tracker might change now. I do not think the tracker will ever change other data but maybe we should include the received peer and announce peer in the event:

pub enum Event {
    TcpAnnounce { connection: ConnectionContext, peer_announcement: Peer, peer_added: Peer },
    TcpScrape { connection: ConnectionContext },
}

cc @da2ce7

Activity

  1. self-assigned this
    on Mar 12, 2025
  2. changed the title [-]Overhaul stats: add announced `Peer` to HTTP core `announce` event[/-] [+]Overhaul stats: Add announced `Peer` to HTTP core `announce` event[/+] on Mar 18, 2025
  3. added a commit that references this issue on Apr 22, 2025
  4. added a commit that references this issue on Apr 22, 2025
  5. josecelano commented on Apr 22, 2025

    @josecelano
    MemberAuthor

    I've finally decided to include only the Peer. The original_peer_ip, also referred to as remote_client_ip, is already included in the ConnectionContext.

    I have also created an alias for the Peer information: PeerAnnouncement, as it represents the latest data received from that peer. Maybe we should rename the type Peer.

    I don't think the tracker will modify other fields in the Peer before adding it to the peer list in the future, so it doesn't make sense to duplicate the entire peer just for one change.

    I've also added the info_hash; otherwise, you don't know what swarm the peer belongs to.

    pub enum Event {
        TcpAnnounce {
            connection: ConnectionContext,
            info_hash: InfoHash,
            announcement: PeerAnnouncement,
        },
        TcpScrape {
            connection: ConnectionContext,
        },
    }
  6. added 3 commits that reference this issue on Apr 22, 2025
  7. added 3 commits that reference this issue on Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions