From 4870f2fe163e0d6adefbc1acbfce8d4b5dcdc629 Mon Sep 17 00:00:00 2001 From: skaunov Date: Fri, 26 Sep 2025 18:58:20 +0300 Subject: [PATCH 1/6] fix(autonat::v2::client): visibility --- protocols/autonat/src/v2/client.rs | 1 + protocols/autonat/src/v2/client/behaviour.rs | 22 +++----------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/protocols/autonat/src/v2/client.rs b/protocols/autonat/src/v2/client.rs index 11ddb792839..816fbfbc71c 100644 --- a/protocols/autonat/src/v2/client.rs +++ b/protocols/autonat/src/v2/client.rs @@ -2,3 +2,4 @@ mod behaviour; mod handler; pub use behaviour::{Behaviour, Config, Event}; +pub use handler::dial_request::DialBackError; diff --git a/protocols/autonat/src/v2/client/behaviour.rs b/protocols/autonat/src/v2/client/behaviour.rs index 8e238fc9be4..5b8dbbb8df3 100644 --- a/protocols/autonat/src/v2/client/behaviour.rs +++ b/protocols/autonat/src/v2/client/behaviour.rs @@ -1,6 +1,6 @@ use std::{ collections::{HashMap, VecDeque}, - fmt::{Debug, Display, Formatter}, + fmt::Debug, task::{Context, Poll}, time::Duration, }; @@ -239,7 +239,7 @@ where tested_addr, bytes_sent, server: peer_id, - result: result.map_err(|e| Error { inner: e }), + result, })); } @@ -374,22 +374,6 @@ impl Default for Behaviour { } } -pub struct Error { - pub(crate) inner: dial_request::DialBackError, -} - -impl Display for Error { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - Display::fmt(&self.inner, f) - } -} - -impl Debug for Error { - fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - Debug::fmt(&self.inner, f) - } -} - #[derive(Debug)] pub struct Event { /// The address that was selected for testing. @@ -402,7 +386,7 @@ pub struct Event { pub server: PeerId, /// The result of the test. If the test was successful, this is `Ok(())`. /// Otherwise it's an error. - pub result: Result<(), Error>, + pub result: Result<(), dial_request::DialBackError>, } struct ConnectionInfo { From bb96556d66d423beafeae8d1aab5e1759dab62c8 Mon Sep 17 00:00:00 2001 From: skaunov Date: Fri, 26 Sep 2025 19:11:38 +0300 Subject: [PATCH 2/6] docstrings --- protocols/autonat/src/v2/client/handler/dial_request.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/protocols/autonat/src/v2/client/handler/dial_request.rs b/protocols/autonat/src/v2/client/handler/dial_request.rs index bafdd9d818c..d8848e99551 100644 --- a/protocols/autonat/src/v2/client/handler/dial_request.rs +++ b/protocols/autonat/src/v2/client/handler/dial_request.rs @@ -62,8 +62,10 @@ impl From for Error { #[derive(thiserror::Error, Debug)] pub enum DialBackError { + /// Tells that the client is actually behind NAT for this connection. #[error("server failed to establish a connection")] NoConnection, + /// Can't tell new information as dialing back couldn't be finished for a lower level reason. #[error("dial back stream failed")] StreamFailed, } From c017f34ca3acae4c7b35c3cd5a4b493d46314a18 Mon Sep 17 00:00:00 2001 From: skaunov Date: Fri, 26 Sep 2025 19:13:33 +0300 Subject: [PATCH 3/6] changelog entry --- protocols/autonat/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/protocols/autonat/CHANGELOG.md b/protocols/autonat/CHANGELOG.md index 1ef95957e92..b36b9690abf 100644 --- a/protocols/autonat/CHANGELOG.md +++ b/protocols/autonat/CHANGELOG.md @@ -1,3 +1,5 @@ +- Fix `DialBackError` visibility so downstream could differentiate between `NoConnection` and `StreamFailed`. + ## 0.15.0 - Fix infinity loop on wrong `nonce` when performing `dial_back`. From 7e9d65e6b8aa213d61b4897a9331948f582275cc Mon Sep 17 00:00:00 2001 From: skaunov Date: Fri, 26 Sep 2025 19:17:40 +0300 Subject: [PATCH 4/6] "bump the crate versions if needed" --- protocols/autonat/CHANGELOG.md | 1 + protocols/autonat/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/protocols/autonat/CHANGELOG.md b/protocols/autonat/CHANGELOG.md index b36b9690abf..c1a36eb5b40 100644 --- a/protocols/autonat/CHANGELOG.md +++ b/protocols/autonat/CHANGELOG.md @@ -1,3 +1,4 @@ +## 0.16.0 - Fix `DialBackError` visibility so downstream could differentiate between `NoConnection` and `StreamFailed`. ## 0.15.0 diff --git a/protocols/autonat/Cargo.toml b/protocols/autonat/Cargo.toml index 9a2f227d412..a7e0fb98c1c 100644 --- a/protocols/autonat/Cargo.toml +++ b/protocols/autonat/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-autonat" edition.workspace = true rust-version = { workspace = true } description = "NAT and firewall detection for libp2p" -version = "0.15.0" +version = "0.16.0" authors = [ "David Craven ", "Elena Frank ", From d4eb99d04dd63f917da5c19db25fa14408fcf825 Mon Sep 17 00:00:00 2001 From: skaunov Date: Fri, 26 Sep 2025 19:30:08 +0300 Subject: [PATCH 5/6] propagate the version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2eeaab5bb83..3784ff96a21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2476,7 +2476,7 @@ dependencies = [ [[package]] name = "libp2p-autonat" -version = "0.15.0" +version = "0.16.0" dependencies = [ "async-trait", "asynchronous-codec", diff --git a/Cargo.toml b/Cargo.toml index e51faa159be..6802a028202 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,7 +76,7 @@ edition = "2021" [workspace.dependencies] libp2p = { version = "0.56.0", path = "libp2p" } libp2p-allow-block-list = { version = "0.6.0", path = "misc/allow-block-list" } -libp2p-autonat = { version = "0.15.0", path = "protocols/autonat" } +libp2p-autonat = { version = "0.16.0", path = "protocols/autonat" } libp2p-connection-limits = { version = "0.6.0", path = "misc/connection-limits" } libp2p-core = { version = "0.43.1", path = "core" } libp2p-dcutr = { version = "0.14.0", path = "protocols/dcutr" } From 67a63e60f0e4b5314acc2dc5f7f540de84fb0391 Mon Sep 17 00:00:00 2001 From: Sergey Kaunov Date: Sat, 27 Sep 2025 01:39:06 +0300 Subject: [PATCH 6/6] Update protocols/autonat/CHANGELOG.md Co-authored-by: Darius Clark --- protocols/autonat/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/autonat/CHANGELOG.md b/protocols/autonat/CHANGELOG.md index c1a36eb5b40..0beeddbdabc 100644 --- a/protocols/autonat/CHANGELOG.md +++ b/protocols/autonat/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.16.0 - Fix `DialBackError` visibility so downstream could differentiate between `NoConnection` and `StreamFailed`. - + See [PR 6168](https://github.com/libp2p/rust-libp2p/pull/6168). ## 0.15.0 - Fix infinity loop on wrong `nonce` when performing `dial_back`.