protocols/mdns: Fix timely discovery after listening on new address (#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>
This commit is contained in:
David Craven
2021-04-21 16:07:38 +02:00
committed by GitHub
parent 40c4287bc9
commit 29d969be34
3 changed files with 11 additions and 1 deletions

View File

@ -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] # 0.30.0 [2021-04-13]
- Derive `Debug` and `Clone` for `MdnsConfig`. - Derive `Debug` and `Clone` for `MdnsConfig`.

View File

@ -1,7 +1,7 @@
[package] [package]
name = "libp2p-mdns" name = "libp2p-mdns"
edition = "2018" edition = "2018"
version = "0.30.0" version = "0.30.1"
description = "Implementation of the libp2p mDNS discovery method" description = "Implementation of the libp2p mDNS discovery method"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT" license = "MIT"

View File

@ -27,6 +27,7 @@ use lazy_static::lazy_static;
use libp2p_core::{ use libp2p_core::{
address_translation, connection::ConnectionId, multiaddr::Protocol, Multiaddr, PeerId, address_translation, connection::ConnectionId, multiaddr::Protocol, Multiaddr, PeerId,
}; };
use libp2p_core::connection::ListenerId;
use libp2p_swarm::{ use libp2p_swarm::{
protocols_handler::DummyProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction, protocols_handler::DummyProtocolsHandler, NetworkBehaviour, NetworkBehaviourAction,
PollParameters, ProtocolsHandler, PollParameters, ProtocolsHandler,
@ -269,6 +270,10 @@ impl NetworkBehaviour for Mdns {
void::unreachable(ev) void::unreachable(ev)
} }
fn inject_new_listen_addr(&mut self, _id: ListenerId, _addr: &Multiaddr) {
self.send_buffer.push_back(build_query());
}
fn poll( fn poll(
&mut self, &mut self,
cx: &mut Context<'_>, cx: &mut Context<'_>,