@@ -12,7 +12,7 @@ use std::panic::Location;
1212use std:: sync:: Arc ;
1313
1414use bittorrent_http_tracker_protocol:: v1:: requests:: announce:: { peer_from_request, Announce } ;
15- use bittorrent_http_tracker_protocol:: v1:: services:: peer_ip_resolver:: { self , ClientIpSources , PeerIpResolutionError } ;
15+ use bittorrent_http_tracker_protocol:: v1:: services:: peer_ip_resolver:: { ClientIpSources , PeerIpResolutionError } ;
1616use bittorrent_primitives:: info_hash:: InfoHash ;
1717use bittorrent_tracker_core:: announce_handler:: { AnnounceHandler , PeersWanted } ;
1818use bittorrent_tracker_core:: authentication:: service:: AuthenticationService ;
@@ -24,6 +24,7 @@ use torrust_tracker_primitives::core::AnnounceData;
2424use torrust_tracker_primitives:: peer:: PeerAnnouncement ;
2525use torrust_tracker_primitives:: service_binding:: ServiceBinding ;
2626
27+ use super :: resolve_remote_client_ip;
2728use crate :: event;
2829use crate :: event:: Event ;
2930
@@ -78,7 +79,8 @@ impl AnnounceService {
7879
7980 self . authorize ( announce_request. info_hash ) . await ?;
8081
81- let ( remote_client_ip, opt_remote_client_port) = self . resolve_remote_client_ip ( client_ip_sources) ?;
82+ let ( remote_client_ip, opt_remote_client_port) =
83+ resolve_remote_client_ip ( self . core_config . net . on_reverse_proxy , client_ip_sources) ?;
8284
8385 let mut peer = peer_from_request ( announce_request, & remote_client_ip) ;
8486
@@ -117,27 +119,6 @@ impl AnnounceService {
117119 self . whitelist_authorization . authorize ( & info_hash) . await
118120 }
119121
120- /// Resolves the client's real IP address considering proxy headers
121- fn resolve_remote_client_ip (
122- & self ,
123- client_ip_sources : & ClientIpSources ,
124- ) -> Result < ( IpAddr , Option < u16 > ) , PeerIpResolutionError > {
125- let ip = match peer_ip_resolver:: invoke ( self . core_config . net . on_reverse_proxy , client_ip_sources) {
126- Ok ( peer_ip) => Ok ( peer_ip) ,
127- Err ( error) => Err ( error) ,
128- } ?;
129-
130- let port = if client_ip_sources. connection_info_socket_address . is_some ( ) {
131- client_ip_sources
132- . connection_info_socket_address
133- . map ( |socket_addr| socket_addr. port ( ) )
134- } else {
135- None
136- } ;
137-
138- Ok ( ( ip, port) )
139- }
140-
141122 /// Determines how many peers the client wants in the response
142123 fn peers_wanted ( announce_request : & Announce ) -> PeersWanted {
143124 match announce_request. numwant {
0 commit comments