@@ -36,6 +36,7 @@ use ringbuf::StaticRb;
36
36
use tokio:: select;
37
37
use tokio:: sync:: oneshot;
38
38
use tokio:: task:: { AbortHandle , JoinHandle } ;
39
+ use url:: Url ;
39
40
40
41
use super :: UdpRequest ;
41
42
use crate :: bootstrap:: jobs:: Started ;
@@ -241,6 +242,9 @@ struct BoundSocket {
241
242
242
243
impl BoundSocket {
243
244
async fn new ( addr : SocketAddr ) -> Result < Self , Box < std:: io:: Error > > {
245
+ let bind_addr = format ! ( "udp://{addr}" ) ;
246
+ tracing:: debug!( target: UDP_TRACKER_LOG_TARGET , bind_addr, "UdpSocket::new (binding)" ) ;
247
+
244
248
let socket = tokio:: net:: UdpSocket :: bind ( addr) . await ;
245
249
246
250
let socket = match socket {
@@ -259,6 +263,10 @@ impl BoundSocket {
259
263
fn local_addr ( & self ) -> SocketAddr {
260
264
self . socket . local_addr ( ) . expect ( "it should get local address" )
261
265
}
266
+
267
+ fn url ( & self ) -> Url {
268
+ Url :: parse ( & format ! ( "udp://{}" , self . local_addr( ) ) ) . expect ( "UDP socket address should be valid" )
269
+ }
262
270
}
263
271
264
272
impl Deref for BoundSocket {
@@ -363,7 +371,7 @@ impl Udp {
363
371
} ;
364
372
365
373
let address = bound_socket. local_addr ( ) ;
366
- let local_udp_url = format ! ( "udp://{address}" ) ;
374
+ let local_udp_url = bound_socket . url ( ) . to_string ( ) ;
367
375
368
376
tracing:: info!( target: UDP_TRACKER_LOG_TARGET , "{STARTED_ON}: {local_udp_url}" ) ;
369
377
0 commit comments