diff --git a/Cargo.lock b/Cargo.lock index 23efd1eb251..b088d0da44f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3172,7 +3172,7 @@ dependencies = [ [[package]] name = "libp2p-upnp" -version = "0.5.0" +version = "0.5.1" dependencies = [ "futures", "futures-timer", diff --git a/Cargo.toml b/Cargo.toml index e5bfab59b58..527d20c27e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -108,7 +108,7 @@ libp2p-swarm-test = { version = "0.6.0", path = "swarm-test" } libp2p-tcp = { version = "0.44.0", path = "transports/tcp" } libp2p-tls = { version = "0.6.2", path = "transports/tls" } libp2p-uds = { version = "0.43.0", path = "transports/uds" } -libp2p-upnp = { version = "0.5.0", path = "protocols/upnp" } +libp2p-upnp = { version = "0.5.1", path = "protocols/upnp" } libp2p-webrtc = { version = "0.9.0-alpha.1", path = "transports/webrtc" } libp2p-webrtc-utils = { version = "0.4.0", path = "misc/webrtc-utils" } libp2p-webrtc-websys = { version = "0.4.0", path = "transports/webrtc-websys" } diff --git a/protocols/upnp/CHANGELOG.md b/protocols/upnp/CHANGELOG.md index 9a226af4dc7..24735db8433 100644 --- a/protocols/upnp/CHANGELOG.md +++ b/protocols/upnp/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.5.1 + +- Skip port mapping when an active port mapping is present. + Previously, the behavior would skip creating new mappings if any mapping + (active or inactive or pending) existed for the same port. Now it correctly only + checks active mappings on the gateway. + See [PR 6127](https://github.com/libp2p/rust-libp2p/pull/6127). + ## 0.5.0 - update igd-next to 0.16.1 diff --git a/protocols/upnp/Cargo.toml b/protocols/upnp/Cargo.toml index 31c12a52bb0..5e29e1aaa8c 100644 --- a/protocols/upnp/Cargo.toml +++ b/protocols/upnp/Cargo.toml @@ -3,7 +3,7 @@ name = "libp2p-upnp" edition.workspace = true rust-version.workspace = true description = "UPnP support for libp2p transports" -version = "0.5.0" +version = "0.5.1" license = "MIT" repository = "https://github.com/libp2p/rust-libp2p" keywords = ["peer-to-peer", "libp2p", "networking"] diff --git a/protocols/upnp/src/behaviour.rs b/protocols/upnp/src/behaviour.rs index 6f66c949e82..4bf80cb1c2a 100644 --- a/protocols/upnp/src/behaviour.rs +++ b/protocols/upnp/src/behaviour.rs @@ -270,15 +270,14 @@ impl NetworkBehaviour for Behaviour { return; }; - if let Some((mapping, _state)) = self - .mappings - .iter() - .find(|(mapping, _state)| mapping.internal_addr.port() == addr.port()) - { + if let Some((mapping, _state)) = self.mappings.iter().find(|(mapping, state)| { + matches!(state, MappingState::Active(_)) + && mapping.internal_addr.port() == addr.port() + }) { tracing::debug!( multiaddress=%multiaddr, mapped_multiaddress=%mapping.multiaddr, - "port from multiaddress is already being mapped" + "port from multiaddress is already mapped on the gateway" ); return; }