mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-21 05:41:33 +00:00
protocols/mdns/: Generate peer expiry and fix IPv6 support (#2359)
Co-authored-by: Victor Ermolaev <victorermolaev@gmail.com> Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
@ -144,12 +144,12 @@ impl Mdns {
|
||||
}
|
||||
};
|
||||
let send_socket = {
|
||||
let addrs = [
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 0),
|
||||
SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), 0),
|
||||
];
|
||||
let addr = match config.multicast_addr {
|
||||
IpAddr::V4(_) => SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), 0),
|
||||
IpAddr::V6(_) => SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), 0),
|
||||
};
|
||||
|
||||
let socket = std::net::UdpSocket::bind(&addrs[..])?;
|
||||
let socket = std::net::UdpSocket::bind(addr)?;
|
||||
Async::new(socket)?
|
||||
};
|
||||
let if_watch = if_watch::IfWatcher::new().await?;
|
||||
@ -406,7 +406,7 @@ impl NetworkBehaviour for Mdns {
|
||||
while let Some(pos) = self
|
||||
.discovered_nodes
|
||||
.iter()
|
||||
.position(|(_, _, exp)| *exp < now)
|
||||
.position(|(_, _, exp)| *exp <= now)
|
||||
{
|
||||
let (peer_id, addr, _) = self.discovered_nodes.remove(pos);
|
||||
expired.push((peer_id, addr));
|
||||
|
Reference in New Issue
Block a user