Fix duplicate external addresses inserted (#927)

This commit is contained in:
Pierre Krieger
2019-02-07 13:46:39 +01:00
committed by GitHub
parent 5cac5b5573
commit 63db253566
2 changed files with 4 additions and 2 deletions

View File

@ -2,7 +2,7 @@
name = "libp2p-core" name = "libp2p-core"
edition = "2018" edition = "2018"
description = "Core traits and structs of libp2p" description = "Core traits and structs of libp2p"
version = "0.3.3" version = "0.3.4"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT" license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p" repository = "https://github.com/libp2p/rust-libp2p"

View File

@ -315,8 +315,10 @@ where TBehaviour: NetworkBehaviour,
}, },
Async::Ready(NetworkBehaviourAction::ReportObservedAddr { address }) => { Async::Ready(NetworkBehaviourAction::ReportObservedAddr { address }) => {
for addr in self.raw_swarm.nat_traversal(&address) { for addr in self.raw_swarm.nat_traversal(&address) {
if self.external_addrs.iter().all(|a| *a != addr) {
self.external_addrs.push(addr); self.external_addrs.push(addr);
} }
}
}, },
} }
} }