File tree 1 file changed +21
-8
lines changed
src/packages/udp_tracker_core/services
1 file changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -46,14 +46,27 @@ pub async fn handle_announce(
46
46
let mut peer = peer_builder:: from_request ( request, & remote_client_ip) ;
47
47
let peers_wanted: PeersWanted = i32:: from ( request. peers_wanted . 0 ) . into ( ) ;
48
48
49
- let announce_data = invoke (
50
- announce_handler. clone ( ) ,
51
- opt_udp_stats_event_sender. clone ( ) ,
52
- info_hash,
53
- & mut peer,
54
- & peers_wanted,
55
- )
56
- . await ?;
49
+ let original_peer_ip = peer. peer_addr . ip ( ) ;
50
+
51
+ // The tracker could change the original peer ip
52
+ let announce_data = announce_handler
53
+ . announce ( & info_hash, & mut peer, & original_peer_ip, & peers_wanted)
54
+ . await ?;
55
+
56
+ if let Some ( udp_stats_event_sender) = opt_udp_stats_event_sender. as_deref ( ) {
57
+ match original_peer_ip {
58
+ IpAddr :: V4 ( _) => {
59
+ udp_stats_event_sender
60
+ . send_event ( udp_tracker_core:: statistics:: event:: Event :: Udp4Announce )
61
+ . await ;
62
+ }
63
+ IpAddr :: V6 ( _) => {
64
+ udp_stats_event_sender
65
+ . send_event ( udp_tracker_core:: statistics:: event:: Event :: Udp6Announce )
66
+ . await ;
67
+ }
68
+ }
69
+ }
57
70
58
71
Ok ( announce_data)
59
72
}
You can’t perform that action at this time.
0 commit comments