@@ -60,15 +60,15 @@ use std::net::{SocketAddr, ToSocketAddrs};
60
60
use std:: str:: FromStr ;
61
61
62
62
use anyhow:: Context ;
63
- use aquatic_udp_protocol:: Response :: { self , AnnounceIpv4 , AnnounceIpv6 , Scrape } ;
63
+ use aquatic_udp_protocol:: Response :: { self , AnnounceIpv4 , AnnounceIpv6 , Connect , Error , Scrape } ;
64
64
use aquatic_udp_protocol:: { Port , TransactionId } ;
65
65
use clap:: { Parser , Subcommand } ;
66
66
use log:: { debug, LevelFilter } ;
67
67
use torrust_tracker_primitives:: info_hash:: InfoHash as TorrustInfoHash ;
68
68
use url:: Url ;
69
69
70
70
use crate :: console:: clients:: udp:: checker;
71
- use crate :: console:: clients:: udp:: responses:: { AnnounceResponseDto , ScrapeResponseDto } ;
71
+ use crate :: console:: clients:: udp:: responses:: { AnnounceResponseDto , ConnectResponseDto , ErrorResponseDto , ScrapeResponseDto } ;
72
72
73
73
const ASSIGNED_BY_OS : u16 = 0 ;
74
74
const RANDOM_TRANSACTION_ID : i32 = -888_840_697 ;
@@ -171,6 +171,11 @@ async fn handle_scrape(tracker_socket_addr: &SocketAddr, info_hashes: &[TorrustI
171
171
172
172
fn print_response ( response : Response ) -> anyhow:: Result < ( ) > {
173
173
match response {
174
+ Connect ( response) => {
175
+ let pretty_json = serde_json:: to_string_pretty ( & ConnectResponseDto :: from ( response) )
176
+ . context ( "connect response JSON serialization" ) ?;
177
+ println ! ( "{pretty_json}" ) ;
178
+ }
174
179
AnnounceIpv4 ( response) => {
175
180
let pretty_json = serde_json:: to_string_pretty ( & AnnounceResponseDto :: from ( response) )
176
181
. context ( "announce IPv4 response JSON serialization" ) ?;
@@ -186,7 +191,11 @@ fn print_response(response: Response) -> anyhow::Result<()> {
186
191
serde_json:: to_string_pretty ( & ScrapeResponseDto :: from ( response) ) . context ( "scrape response JSON serialization" ) ?;
187
192
println ! ( "{pretty_json}" ) ;
188
193
}
189
- _ => println ! ( "{response:#?}" ) , // todo: serialize to JSON all aquatic responses.
194
+ Error ( response) => {
195
+ let pretty_json =
196
+ serde_json:: to_string_pretty ( & ErrorResponseDto :: from ( response) ) . context ( "error response JSON serialization" ) ?;
197
+ println ! ( "{pretty_json}" ) ;
198
+ }
190
199
} ;
191
200
192
201
Ok ( ( ) )
0 commit comments