@@ -6,13 +6,11 @@ use std::sync::Arc;
6
6
use aquatic_udp_protocol:: {
7
7
NumberOfDownloads , NumberOfPeers , Response , ScrapeRequest , ScrapeResponse , TorrentScrapeStatistics , TransactionId ,
8
8
} ;
9
- use bittorrent_primitives:: info_hash:: InfoHash ;
10
9
use bittorrent_tracker_core:: scrape_handler:: ScrapeHandler ;
11
10
use tracing:: { instrument, Level } ;
12
11
use zerocopy:: network_endian:: I32 ;
13
12
14
13
use crate :: packages:: udp_tracker_core;
15
- use crate :: packages:: udp_tracker_core:: services;
16
14
use crate :: servers:: udp:: connection_cookie:: check;
17
15
use crate :: servers:: udp:: error:: Error ;
18
16
use crate :: servers:: udp:: handlers:: gen_remote_fingerprint;
@@ -37,20 +35,19 @@ pub async fn handle_scrape(
37
35
38
36
tracing:: trace!( "handle scrape" ) ;
39
37
38
+ // todo: move authentication to `udp_tracker_core::services::scrape::handle_scrape`
39
+
40
40
check (
41
41
& request. connection_id ,
42
42
gen_remote_fingerprint ( & remote_addr) ,
43
43
cookie_valid_range,
44
44
)
45
45
. map_err ( |e| ( e, request. transaction_id ) ) ?;
46
46
47
- // Convert from aquatic infohashes
48
- let mut info_hashes: Vec < InfoHash > = vec ! [ ] ;
49
- for info_hash in & request. info_hashes {
50
- info_hashes. push ( ( * info_hash) . into ( ) ) ;
51
- }
47
+ let scrape_data =
48
+ udp_tracker_core:: services:: scrape:: handle_scrape ( remote_addr, request, scrape_handler, opt_udp_stats_event_sender) . await ;
52
49
53
- let scrape_data = services :: scrape :: invoke ( scrape_handler , opt_udp_stats_event_sender , & info_hashes , remote_addr ) . await ;
50
+ // todo: extract `build_response` function.
54
51
55
52
let mut torrent_stats: Vec < TorrentScrapeStatistics > = Vec :: new ( ) ;
56
53
0 commit comments