Skip to content

Commit

Permalink
protocols/mdns: Fix timely discovery after listening on new address (#…
Browse files Browse the repository at this point in the history
…2053)

If you start listening after mdns joined a multicast group, the peers may not
discover eachother until the 5min timeout expires.

Co-authored-by: Max Inden <mail@max-inden.de>
  • Loading branch information
dvc94ch and mxinden authored Apr 21, 2021
1 parent 40c4287 commit 29d969b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions protocols/mdns/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.30.1 [2021-04-21]

- Fix timely discovery of peers after listening on a new address.
[PR 2053](https://github.com/libp2p/rust-libp2p/pull/2053/)

# 0.30.0 [2021-04-13]

- Derive `Debug` and `Clone` for `MdnsConfig`.
Expand Down
2 changes: 1 addition & 1 deletion protocols/mdns/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "libp2p-mdns"
edition = "2018"
version = "0.30.0"
version = "0.30.1"
description = "Implementation of the libp2p mDNS discovery method"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
Expand Down
5 changes: 5 additions & 0 deletions protocols/mdns/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use lazy_static::lazy_static;
use libp2p_core::{
address_translation, connection::ConnectionId, multiaddr::Protocol, Multiaddr, PeerId,
};
use libp2p_core::connection::ListenerId;
use libp2p_swarm::{
protocols_handler::DummyProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction,
PollParameters, ProtocolsHandler,
Expand Down Expand Up @@ -269,6 +270,10 @@ impl NetworkBehaviour for Mdns {
void::unreachable(ev)
}

fn inject_new_listen_addr(&mut self, _id: ListenerId, _addr: &Multiaddr) {
self.send_buffer.push_back(build_query());
}

fn poll(
&mut self,
cx: &mut Context<'_>,
Expand Down

0 comments on commit 29d969b

Please sign in to comment.