@@ -334,14 +334,22 @@ impl Identify {
334
334
Ok ( Some ( Ok ( payload) ) ) => payload,
335
335
} ;
336
336
337
- let info = identify_schema:: Identify :: decode ( payload. to_vec ( ) . as_slice ( ) ) ?;
337
+ let info = identify_schema:: Identify :: decode ( payload. to_vec ( ) . as_slice ( ) ) . map_err (
338
+ |err| {
339
+ tracing:: debug!( target: LOG_TARGET , ?peer, ?err, "peer identified provided undecodable identify response" ) ;
340
+ err
341
+ } ) ?;
338
342
339
343
tracing:: trace!( target: LOG_TARGET , ?peer, ?info, "peer identified" ) ;
340
344
341
345
// The check ensures the provided public key is the same one as the
342
346
// one exchanged during the connection establishment.
343
347
if let Some ( public_key) = & info. public_key {
344
- let public_key = PublicKey :: from_protobuf_encoding ( & public_key) ?;
348
+ let public_key = PublicKey :: from_protobuf_encoding ( & public_key) . map_err ( |err| {
349
+ tracing:: debug!( target: LOG_TARGET , ?peer, ?err, "peer identified provided undecodable public key" ) ;
350
+ err
351
+ } ) ?;
352
+
345
353
if public_key. to_peer_id ( ) != peer {
346
354
tracing:: debug!( target: LOG_TARGET , ?peer, "peer identified provided invalid public key" ) ;
347
355
return Err ( Error :: InvalidData ) ;
@@ -356,11 +364,12 @@ impl Identify {
356
364
357
365
// Ensure the address ends with the provided peer ID and is not empty.
358
366
if address. is_empty ( ) {
367
+ tracing:: debug!( target: LOG_TARGET , ?peer, ?address, "peer identified provided empty listen address" ) ;
359
368
return None ;
360
369
}
361
370
if let Some ( multiaddr:: Protocol :: P2p ( peer_id) ) = address. iter ( ) . last ( ) {
362
371
if peer_id != peer. into ( ) {
363
- tracing:: debug!( target: LOG_TARGET , ?peer, ?address, "peer identified provided invalid address" ) ;
372
+ tracing:: debug!( target: LOG_TARGET , ?peer, ?address, "peer identified provided invalid listen address" ) ;
364
373
return None ;
365
374
}
366
375
}
@@ -374,12 +383,13 @@ impl Identify {
374
383
let address = Multiaddr :: try_from ( address) . ok ( ) ?;
375
384
376
385
if address. is_empty ( ) {
386
+ tracing:: debug!( target: LOG_TARGET , ?peer, ?address, "peer identified provided empty observed address" ) ;
377
387
return None ;
378
388
}
379
389
380
390
if let Some ( multiaddr:: Protocol :: P2p ( peer_id) ) = address. iter ( ) . last ( ) {
381
391
if peer_id != local_peer_id. into ( ) {
382
- tracing:: debug!( target: LOG_TARGET , ?peer, ?address, "peer identified provided invalid address" ) ;
392
+ tracing:: debug!( target: LOG_TARGET , ?peer, ?address, "peer identified provided invalid observed address" ) ;
383
393
return None ;
384
394
}
385
395
}
0 commit comments