@@ -5,13 +5,13 @@ pub mod listener;
5
5
pub mod sender;
6
6
7
7
/// An statistics event. It is used to collect tracker metrics.
8
- #[ derive( Debug , PartialEq , Eq ) ]
8
+ #[ derive( Debug , PartialEq , Eq , Clone ) ]
9
9
pub enum Event {
10
10
TcpAnnounce { connection : ConnectionContext } ,
11
11
TcpScrape { connection : ConnectionContext } ,
12
12
}
13
13
14
- #[ derive( Debug , PartialEq , Eq ) ]
14
+ #[ derive( Debug , PartialEq , Eq , Clone ) ]
15
15
pub struct ConnectionContext {
16
16
client : ClientConnectionContext ,
17
17
server : ServerConnectionContext ,
@@ -35,17 +35,27 @@ impl ConnectionContext {
35
35
pub fn client_ip_addr ( & self ) -> IpAddr {
36
36
self . client . ip_addr
37
37
}
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
+ }
38
48
}
39
49
40
- #[ derive( Debug , PartialEq , Eq ) ]
50
+ #[ derive( Debug , PartialEq , Eq , Clone ) ]
41
51
pub struct ClientConnectionContext {
42
52
ip_addr : IpAddr ,
43
53
44
54
/// It's provided if you use the `torrust-axum-http-tracker-server` crate.
45
55
port : Option < u16 > ,
46
56
}
47
57
48
- #[ derive( Debug , PartialEq , Eq ) ]
58
+ #[ derive( Debug , PartialEq , Eq , Clone ) ]
49
59
pub struct ServerConnectionContext {
50
60
socket_addr : SocketAddr ,
51
61
}
0 commit comments