@@ -60,15 +60,15 @@ use std::net::{SocketAddr, ToSocketAddrs};
6060use std:: str:: FromStr ;
6161
6262use anyhow:: Context ;
63- use aquatic_udp_protocol:: Response :: { self , AnnounceIpv4 , AnnounceIpv6 , Scrape } ;
63+ use aquatic_udp_protocol:: Response :: { self , AnnounceIpv4 , AnnounceIpv6 , Connect , Error , Scrape } ;
6464use aquatic_udp_protocol:: { Port , TransactionId } ;
6565use clap:: { Parser , Subcommand } ;
6666use log:: { debug, LevelFilter } ;
6767use torrust_tracker_primitives:: info_hash:: InfoHash as TorrustInfoHash ;
6868use url:: Url ;
6969
7070use 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 } ;
7272
7373const ASSIGNED_BY_OS : u16 = 0 ;
7474const RANDOM_TRANSACTION_ID : i32 = -888_840_697 ;
@@ -171,6 +171,11 @@ async fn handle_scrape(tracker_socket_addr: &SocketAddr, info_hashes: &[TorrustI
171171
172172fn print_response ( response : Response ) -> anyhow:: Result < ( ) > {
173173 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+ }
174179 AnnounceIpv4 ( response) => {
175180 let pretty_json = serde_json:: to_string_pretty ( & AnnounceResponseDto :: from ( response) )
176181 . context ( "announce IPv4 response JSON serialization" ) ?;
@@ -186,7 +191,11 @@ fn print_response(response: Response) -> anyhow::Result<()> {
186191 serde_json:: to_string_pretty ( & ScrapeResponseDto :: from ( response) ) . context ( "scrape response JSON serialization" ) ?;
187192 println ! ( "{pretty_json}" ) ;
188193 }
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+ }
190199 } ;
191200
192201 Ok ( ( ) )
0 commit comments