From a799bf88e0e26763f8cb072500b10f3cc3102e87 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 1 Nov 2026 19:51:08 +0100 Subject: libp2p: remember wrong addresses --- src/transport/libp2p/driver.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/transport/libp2p/driver.rs') diff --git a/src/transport/libp2p/driver.rs b/src/transport/libp2p/driver.rs index c89a784..39a2a5d 100644 --- a/src/transport/libp2p/driver.rs +++ b/src/transport/libp2p/driver.rs @@ -272,6 +272,19 @@ pub(super) async fn run( } SwarmEvent::OutgoingConnectionError { connection_id, peer_id, error } => { count_dial_failure(&mut lock(&book).counts.dial_failures, &error); + // Another peer there: not this one's address, though it said so (a + // NATed peer's LAN address, the same range as ours). + if let (Some(peer), ::libp2p::swarm::DialError::WrongPeerId { obtained, address }) = + (peer_id, &error) + { + debug!( + peer = %Addressed(SCHEME, &peer), + address = %address, + obtained = %obtained, + "Another peer at an address of this one; not dialling it there again" + ); + lock(&book).not_theirs(peer, address.clone()); + } if let Some((_, done)) = identifying.remove(&connection_id) { let _ = done.send(Err(describe_dial_error(&error))); } -- cgit v1.3.1