Skip to content

Overhaul stats events: merge HTTP core events with a different IP version #1373

Closed

Description

@josecelano

Change events from this:

bittorrent_http_tracker_core::statistics::event::Event:

pub enum Event {
    Tcp4Announce,
    Tcp4Scrape,
    Tcp6Announce,
    Tcp6Scrape,
}

To this:

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

pub struct ConnectionContext {
    pub client_ip_addr: IpAddr,
    pub server_socket_addr: SocketAddr,
}

Activity

  1. self-assigned this
    on Mar 11, 2025
  2. added theissue type on Mar 11, 2025
  3. added 2 commits that reference this issue on Mar 17, 2025
  4. changed the title [-]Overhaul stats events: group HTTP core events by IP version[/-] [+]Overhaul stats events: merge HTTP core events with a different IP version[/+] on Mar 17, 2025
  5. josecelano commented on Mar 17, 2025

    @josecelano
    MemberAuthor

    In the end, the code looks like the following:

    pub enum Event {
        TcpAnnounce { connection: ConnectionContext },
        TcpScrape { connection: ConnectionContext },
    }
    
    pub struct ConnectionContext {
        client: ClientConnectionContext,
        server: ServerConnectionContext,
    }
    
    pub struct ClientConnectionContext {
        ip_addr: IpAddr,
        port: Option<u16>,
    }
    
    pub struct ServerConnectionContext {
        socket_addr: SocketAddr,
    }

    because the client's port might not be available. It requires to set the router in a way that you can get the connection info. It's available if you use the torrust-axum-http-tracker-server crate.

    This is the layer in the axum router to get the connection info:

    .layer(SecureClientIpSource::ConnectInfo.into_extension())
  6. added 3 commits that reference this issue on Mar 17, 2025
  7. added 2 commits that reference this issue on Mar 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Code Cleanup / Refactoring

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions