@@ -57,6 +57,7 @@ async fn spawn_relay(lab: &Lab) -> Result<(RelayMap, AbortOnDropHandle<()>)> {
5757 let relay_v6 = dev_relay. ip6 ( ) . expect ( "relay has IPv6" ) ;
5858 lab. dns_entry ( "relay.test" , relay_v4. into ( ) ) ?;
5959 lab. dns_entry ( "relay.test" , relay_v6. into ( ) ) ?;
60+ info ! ( %relay_v4, %relay_v6, "DNS entries for relay.test registered" ) ;
6061
6162 let ( relay_map_tx, relay_map_rx) = oneshot:: channel ( ) ;
6263 let task_relay = dev_relay. spawn ( async move |_ctx| {
@@ -147,13 +148,16 @@ impl Pair {
147148 let server_task = server_device. spawn ( |dev| {
148149 let barrier = barrier2;
149150 async move {
150- let endpoint = endpoint_builder ( & dev, relay_map2) . bind ( ) . await ?;
151+ let endpoint = endpoint_builder ( & dev, relay_map2) . bind ( ) . await
152+ . context ( "server endpoint bind" ) ?;
151153 info ! ( id=%endpoint. id( ) . fmt_short( ) , bound_sockets=?endpoint. bound_sockets( ) , "server endpoint bound" ) ;
152154 endpoint. online ( ) . await ;
153155 info ! ( "endpoint online" ) ;
154156 // Send address to client task. Make it a relay-only address, like in the default address lookup services.
155157 addr_tx. send ( addr_relay_only ( endpoint. addr ( ) ) ) . unwrap ( ) ;
156- let conn = endpoint. accept ( ) . await . unwrap ( ) . accept ( ) . anyerr ( ) ?. await ?;
158+ let incoming = endpoint. accept ( ) . await . context ( "server accept incoming" ) ?;
159+ let conn = incoming. accept ( ) . anyerr ( ) ?. await
160+ . context ( "server accept handshake" ) ?;
157161 info ! ( remote=%conn. remote_id( ) . fmt_short( ) , "accepted, executing run function" ) ;
158162 watch_selected_path ( & conn) ;
159163 let res = server_run ( dev. clone ( ) , endpoint. clone ( ) , conn) . await ;
@@ -172,11 +176,13 @@ impl Pair {
172176 } ) ?;
173177 let client_task = client_device. spawn ( move |dev| {
174178 async move {
175- let endpoint = endpoint_builder ( & dev, self . relay_map ) . bind ( ) . await ?;
179+ let endpoint = endpoint_builder ( & dev, self . relay_map ) . bind ( ) . await
180+ . context ( "client endpoint bind" ) ?;
176181 info ! ( id=%endpoint. id( ) . fmt_short( ) , bound_sockets=?endpoint. bound_sockets( ) , "client endpoint bound" ) ;
177182 let addr = addr_rx. await . std_context ( "server did not send its address" ) ?;
178183 info ! ( ?addr, "connecting to server" ) ;
179- let conn = endpoint. connect ( addr, TEST_ALPN ) . await ?;
184+ let conn = endpoint. connect ( addr, TEST_ALPN ) . await
185+ . context ( "client connect" ) ?;
180186 watch_selected_path ( & conn) ;
181187 info ! ( remote=%conn. remote_id( ) . fmt_short( ) , "connected, executing run function" ) ;
182188 let res = client_run ( dev. clone ( ) , endpoint. clone ( ) , conn) . await ;
@@ -256,12 +262,16 @@ pub trait PathWatcherExt {
256262
257263 /// Wait until the selected path is a direct (IP) path.
258264 async fn wait_ip ( & mut self , timeout : Duration ) -> Result < PathInfo > {
259- self . wait_selected ( timeout, PathInfo :: is_ip) . await
265+ self . wait_selected ( timeout, PathInfo :: is_ip)
266+ . await
267+ . context ( "wait_ip" )
260268 }
261269
262270 /// Wait until the selected path is a relay path.
263271 async fn wait_relay ( & mut self , timeout : Duration ) -> Result < PathInfo > {
264- self . wait_selected ( timeout, PathInfo :: is_relay) . await
272+ self . wait_selected ( timeout, PathInfo :: is_relay)
273+ . await
274+ . context ( "wait_relay" )
265275 }
266276}
267277
@@ -289,36 +299,45 @@ impl PathWatcherExt for PathWatcher {
289299 }
290300 } )
291301 . await
292- . anyerr ( ) ?
302+ . std_context ( "wait_selected timed out" ) ?
293303 }
294304}
295305
296306/// Opens a bidi stream, sends 8 bytes of data, and waits to receive the same data back.
297307pub async fn ping_open ( conn : & Connection , timeout : Duration ) -> Result {
298308 tokio:: time:: timeout ( timeout, async {
299309 let data: [ u8 ; 8 ] = rand:: random ( ) ;
310+ debug ! ( "open_bi" ) ;
300311 let ( mut send, mut recv) = conn. open_bi ( ) . await . anyerr ( ) ?;
312+ debug ! ( "write_all" ) ;
301313 send. write_all ( & data) . await . anyerr ( ) ?;
302314 send. finish ( ) . anyerr ( ) ?;
315+ debug ! ( "read_to_end" ) ;
303316 let r = recv. read_to_end ( 8 ) . await . anyerr ( ) ?;
304317 ensure_any ! ( r == data, "reply matches" ) ;
318+ debug ! ( "done" ) ;
305319 Ok ( ( ) )
306320 } )
307321 . await
308- . anyerr ( ) ?
322+ . std_context ( "ping_open timed out" ) ?
309323}
310324
311325/// Accepts a bidi stream, reads 8 bytes of data, and sends the same data back.
312326pub async fn ping_accept ( conn : & Connection , timeout : Duration ) -> Result {
313327 tokio:: time:: timeout ( timeout, async {
328+ debug ! ( "accept_bi" ) ;
314329 let ( mut send, mut recv) = conn. accept_bi ( ) . await . anyerr ( ) ?;
330+ debug ! ( "read_to_end" ) ;
315331 let data = recv. read_to_end ( 8 ) . await . anyerr ( ) ?;
332+ debug ! ( "write_all" ) ;
316333 send. write_all ( & data) . await . anyerr ( ) ?;
317334 send. finish ( ) . anyerr ( ) ?;
335+ debug ! ( "done" ) ;
318336 Ok ( ( ) )
319337 } )
338+ . instrument ( error_span ! ( "ping_accept" ) )
320339 . await
321- . anyerr ( ) ?
340+ . std_context ( "ping_accept timed out" ) ?
322341}
323342
324343fn watch_selected_path ( conn : & Connection ) {
0 commit comments