@@ -5,13 +5,13 @@ pub mod listener;
55pub 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 ) ]
99pub enum Event {
1010 TcpAnnounce { connection : ConnectionContext } ,
1111 TcpScrape { connection : ConnectionContext } ,
1212}
1313
14- #[ derive( Debug , PartialEq , Eq ) ]
14+ #[ derive( Debug , PartialEq , Eq , Clone ) ]
1515pub 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 ) ]
4151pub 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 ) ]
4959pub struct ServerConnectionContext {
5060 socket_addr : SocketAddr ,
5161}
0 commit comments