Skip to content

Commit 2283b42

Browse files
committed
fix(upnp): skip port mapping when an active port mapping is present
1 parent e29dad6 commit 2283b42

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

protocols/upnp/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.6.0
2+
3+
- Skip port mapping when an active port mapping is present.
4+
Previously, the behavior would skip creating new mappings if any mapping
5+
(active or inactive or pending) existed for the same port. Now it correctly only
6+
checks active mappings on the gateway.
7+
See [PR XXXX](https://github.com/libp2p/rust-libp2p/pull/XXXX).
8+
19
## 0.5.0
210

311
- update igd-next to 0.16.1

protocols/upnp/src/behaviour.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,14 @@ impl NetworkBehaviour for Behaviour {
270270
return;
271271
};
272272

273-
if let Some((mapping, _state)) = self
274-
.mappings
275-
.iter()
276-
.find(|(mapping, _state)| mapping.internal_addr.port() == addr.port())
277-
{
273+
if let Some((mapping, _state)) = self.mappings.iter().find(|(mapping, state)| {
274+
matches!(state, MappingState::Active(_))
275+
&& mapping.internal_addr.port() == addr.port()
276+
}) {
278277
tracing::debug!(
279278
multiaddress=%multiaddr,
280279
mapped_multiaddress=%mapping.multiaddr,
281-
"port from multiaddress is already being mapped"
280+
"port from multiaddress is already mapped on the gateway"
282281
);
283282
return;
284283
}

0 commit comments

Comments
 (0)