Skip to content

Commit 64c7b21

Browse files
committed
refactor: [#1388] minor changes to HTTP core events
1 parent 3ee074f commit 64c7b21

File tree

1 file changed

+14
-4
lines changed
  • packages/http-tracker-core/src/statistics/event

1 file changed

+14
-4
lines changed

packages/http-tracker-core/src/statistics/event/mod.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ pub mod listener;
55
pub mod sender;
66

77
/// An statistics event. It is used to collect tracker metrics.
8-
#[derive(Debug, PartialEq, Eq)]
8+
#[derive(Debug, PartialEq, Eq, Clone)]
99
pub enum Event {
1010
TcpAnnounce { connection: ConnectionContext },
1111
TcpScrape { connection: ConnectionContext },
1212
}
1313

14-
#[derive(Debug, PartialEq, Eq)]
14+
#[derive(Debug, PartialEq, Eq, Clone)]
1515
pub struct ConnectionContext {
1616
client: ClientConnectionContext,
1717
server: ServerConnectionContext,
@@ -35,17 +35,27 @@ impl ConnectionContext {
3535
pub fn client_ip_addr(&self) -> IpAddr {
3636
self.client.ip_addr
3737
}
38+
39+
#[must_use]
40+
pub fn client_port(&self) -> Option<u16> {
41+
self.client.port
42+
}
43+
44+
#[must_use]
45+
pub fn server_socket_addr(&self) -> SocketAddr {
46+
self.server.socket_addr
47+
}
3848
}
3949

40-
#[derive(Debug, PartialEq, Eq)]
50+
#[derive(Debug, PartialEq, Eq, Clone)]
4151
pub struct ClientConnectionContext {
4252
ip_addr: IpAddr,
4353

4454
/// It's provided if you use the `torrust-axum-http-tracker-server` crate.
4555
port: Option<u16>,
4656
}
4757

48-
#[derive(Debug, PartialEq, Eq)]
58+
#[derive(Debug, PartialEq, Eq, Clone)]
4959
pub struct ServerConnectionContext {
5060
socket_addr: SocketAddr,
5161
}

0 commit comments

Comments
 (0)