Skip to content

Commit 6fe8fd5

Browse files
committed
fix(mdns): hotfix dialing loopback adresses
1 parent bec08cc commit 6fe8fd5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

swarm/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ pub use handler::{
121121
};
122122
use libp2p_core::{
123123
connection::ConnectedPoint,
124+
multiaddr::Protocol,
124125
muxing::StreamMuxerBox,
125126
transport::{self, ListenerId, TransportError, TransportEvent},
126127
Multiaddr, Transport,
@@ -494,7 +495,11 @@ where
494495
let mut unique_addresses = HashSet::new();
495496
addresses_from_opts.retain(|addr| {
496497
!self.listened_addrs.values().flatten().any(|a| a == addr)
497-
&& unique_addresses.insert(addr.clone())
498+
&& unique_addresses.insert(addr.clone()) && !addr.iter().any(|p| match p {
499+
Protocol::Ip4(ip) => ip.is_loopback(),
500+
Protocol::Ip6(ip) => ip.is_loopback(),
501+
_ => false,
502+
})
498503
});
499504

500505
if addresses_from_opts.is_empty() {

0 commit comments

Comments
 (0)