From e10ff3831886fde2db00b314f66d3359ac79b25f Mon Sep 17 00:00:00 2001 From: Pan Chasinga Date: Mon, 25 Oct 2021 14:23:47 -0700 Subject: [PATCH 01/10] Use a random alphanumeric string for mDNS peer name Fixes #2285 --- protocols/mdns/src/dns.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/protocols/mdns/src/dns.rs b/protocols/mdns/src/dns.rs index 9bd1181dd74..b7c1fa604de 100644 --- a/protocols/mdns/src/dns.rs +++ b/protocols/mdns/src/dns.rs @@ -23,6 +23,8 @@ use crate::{META_QUERY_SERVICE, SERVICE_NAME}; use libp2p_core::{Multiaddr, PeerId}; use std::{borrow::Cow, cmp, error, fmt, str, time::Duration}; +use rand::{thread_rng, Rng}; +use rand::distributions::Alphanumeric; /// Maximum size of a DNS label as per RFC1035. const MAX_LABEL_LENGTH: usize = 63; @@ -280,6 +282,14 @@ fn segment_peer_id(peer_id: String) -> String { out } +fn random_string(length: usize) -> String { + thread_rng() + .sample_iter(&Alphanumeric) + .take(length) + .map(char::from) + .collect() +} + /// Combines and encodes a `PeerId` and service name for a DNS query. fn encode_peer_id(peer_id: &PeerId) -> Vec { // DNS-safe encoding for the Peer ID @@ -287,7 +297,7 @@ fn encode_peer_id(peer_id: &PeerId) -> Vec { // ensure we don't have any labels over 63 bytes long let encoded_peer_id = segment_peer_id(raw_peer_id); let service_name = str::from_utf8(SERVICE_NAME).expect("SERVICE_NAME is always ASCII"); - let peer_name = [&encoded_peer_id, service_name].join("."); + let peer_name = random_string(32 + thread_rng().gen_range(0..32)); // allocate with a little extra padding for QNAME encoding let mut peer_id_bytes = Vec::with_capacity(peer_name.len() + 32); @@ -456,5 +466,13 @@ mod tests { assert_eq!(segment_peer_id(str_127), [&str_63, &str_63, "x"].join(".")); } + #[test] + fn test_random_string() { + let varsize = thread_rng().gen_range(0..32); + let size = 32 + varsize; + let name = random_string(size); + assert_eq!(name.len(), size); + } + // TODO: test limits and errors } From 5d563c6a0adba57f61296c48d40f08cb5284d290 Mon Sep 17 00:00:00 2001 From: Pan Chasinga Date: Sat, 30 Oct 2021 09:37:50 -0700 Subject: [PATCH 02/10] Remove unused code and rename the function Rename `encode_peer_id` to `generate_peer_id` Because `encode_peer_id` now does not encode anything. --- protocols/mdns/src/dns.rs | 56 +++++---------------------------------- 1 file changed, 6 insertions(+), 50 deletions(-) diff --git a/protocols/mdns/src/dns.rs b/protocols/mdns/src/dns.rs index b7c1fa604de..42524c68b6c 100644 --- a/protocols/mdns/src/dns.rs +++ b/protocols/mdns/src/dns.rs @@ -26,9 +26,6 @@ use std::{borrow::Cow, cmp, error, fmt, str, time::Duration}; use rand::{thread_rng, Rng}; use rand::distributions::Alphanumeric; -/// Maximum size of a DNS label as per RFC1035. -const MAX_LABEL_LENGTH: usize = 63; - /// DNS TXT records can have up to 255 characters as a single string value. /// /// Current values are usually around 170-190 bytes long, varying primarily @@ -118,7 +115,7 @@ pub fn build_query_response( // Add a limit to 2^16-1 addresses, as the protocol limits to this number. let addresses = addresses.take(65535); - let peer_id_bytes = encode_peer_id(&peer_id); + let peer_id_bytes = generate_peer_id(); debug_assert!(peer_id_bytes.len() <= 0xffff); // The accumulated response packets. @@ -262,26 +259,7 @@ fn append_u16(out: &mut Vec, value: u16) { out.push((value & 0xff) as u8); } -/// If a peer ID is longer than 63 characters, split it into segments to -/// be compatible with RFC 1035. -fn segment_peer_id(peer_id: String) -> String { - // Guard for the most common case - if peer_id.len() <= MAX_LABEL_LENGTH { - return peer_id; - } - - // This will only perform one allocation except in extreme circumstances. - let mut out = String::with_capacity(peer_id.len() + 8); - - for (idx, chr) in peer_id.chars().enumerate() { - if idx > 0 && idx % MAX_LABEL_LENGTH == 0 { - out.push('.'); - } - out.push(chr); - } - out -} - +/// Generates and returns a random alphanumeric string of `length` size. fn random_string(length: usize) -> String { thread_rng() .sample_iter(&Alphanumeric) @@ -290,13 +268,10 @@ fn random_string(length: usize) -> String { .collect() } -/// Combines and encodes a `PeerId` and service name for a DNS query. -fn encode_peer_id(peer_id: &PeerId) -> Vec { - // DNS-safe encoding for the Peer ID - let raw_peer_id = data_encoding::BASE32_DNSCURVE.encode(&peer_id.to_bytes()); - // ensure we don't have any labels over 63 bytes long - let encoded_peer_id = segment_peer_id(raw_peer_id); - let service_name = str::from_utf8(SERVICE_NAME).expect("SERVICE_NAME is always ASCII"); +/// Generates a peer ID bytes for a DNS query. +fn generate_peer_id() -> Vec { + // Use a variable-length random string for mDNS peer name. + // See discussion: https://github.com/libp2p/go-libp2p/pull/1222 let peer_name = random_string(32 + thread_rng().gen_range(0..32)); // allocate with a little extra padding for QNAME encoding @@ -447,25 +422,6 @@ mod tests { assert!(Packet::parse(&query).is_ok()); } - #[test] - fn test_segment_peer_id() { - let str_32 = String::from_utf8(vec![b'x'; 32]).unwrap(); - let str_63 = String::from_utf8(vec![b'x'; 63]).unwrap(); - let str_64 = String::from_utf8(vec![b'x'; 64]).unwrap(); - let str_126 = String::from_utf8(vec![b'x'; 126]).unwrap(); - let str_127 = String::from_utf8(vec![b'x'; 127]).unwrap(); - - assert_eq!(segment_peer_id(str_32.clone()), str_32); - assert_eq!(segment_peer_id(str_63.clone()), str_63); - - assert_eq!(segment_peer_id(str_64), [&str_63, "x"].join(".")); - assert_eq!( - segment_peer_id(str_126), - [&str_63, str_63.as_str()].join(".") - ); - assert_eq!(segment_peer_id(str_127), [&str_63, &str_63, "x"].join(".")); - } - #[test] fn test_random_string() { let varsize = thread_rng().gen_range(0..32); From 99e1cc9437f85a55490e11ee3993c1e02b0b74f1 Mon Sep 17 00:00:00 2001 From: Pan Chasinga Date: Tue, 2 Nov 2021 13:10:01 -0700 Subject: [PATCH 03/10] Update CHANGELOG Update CHANGELOG and Cargo.toml --- protocols/mdns/CHANGELOG.md | 6 ++++++ protocols/mdns/Cargo.toml | 2 +- protocols/mdns/src/dns.rs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/protocols/mdns/CHANGELOG.md b/protocols/mdns/CHANGELOG.md index 54004fd5611..da1412d6165 100644 --- a/protocols/mdns/CHANGELOG.md +++ b/protocols/mdns/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.33.1 [unreleased] + +- Use a random alphanumeric string for mDNS peer name (see [PR 2311]). + +[PR 2311]: https://github.com/libp2p/rust-libp2p/pull/2311/ + # 0.33.0 [2021-11-16] - Update dependencies. diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 4fb7eaf08bf..8ba29898e0a 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libp2p-mdns" edition = "2018" -version = "0.33.0" +version = "0.33.1" description = "Implementation of the libp2p mDNS discovery method" authors = ["Parity Technologies "] license = "MIT" diff --git a/protocols/mdns/src/dns.rs b/protocols/mdns/src/dns.rs index 42524c68b6c..b25b83ee051 100644 --- a/protocols/mdns/src/dns.rs +++ b/protocols/mdns/src/dns.rs @@ -271,7 +271,7 @@ fn random_string(length: usize) -> String { /// Generates a peer ID bytes for a DNS query. fn generate_peer_id() -> Vec { // Use a variable-length random string for mDNS peer name. - // See discussion: https://github.com/libp2p/go-libp2p/pull/1222 + // See https://github.com/libp2p/rust-libp2p/pull/2311/ let peer_name = random_string(32 + thread_rng().gen_range(0..32)); // allocate with a little extra padding for QNAME encoding From 36aa1721fd53e40babfc84754c175924a7563af2 Mon Sep 17 00:00:00 2001 From: Pan Chasinga Date: Wed, 3 Nov 2021 07:56:06 -0700 Subject: [PATCH 04/10] Rename references from peer ID to peer name Because the peer name is no longer based on peer ID. See also: https://github.com/libp2p/rust-libp2p/pull/2311#pullrequestreview-796427041 --- protocols/mdns/src/dns.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/protocols/mdns/src/dns.rs b/protocols/mdns/src/dns.rs index b25b83ee051..83a104068b5 100644 --- a/protocols/mdns/src/dns.rs +++ b/protocols/mdns/src/dns.rs @@ -115,8 +115,8 @@ pub fn build_query_response( // Add a limit to 2^16-1 addresses, as the protocol limits to this number. let addresses = addresses.take(65535); - let peer_id_bytes = generate_peer_id(); - debug_assert!(peer_id_bytes.len() <= 0xffff); + let peer_name_bytes = generate_peer_name(); + debug_assert!(peer_name_bytes.len() <= 0xffff); // The accumulated response packets. let mut packets = Vec::new(); @@ -129,7 +129,7 @@ pub fn build_query_response( for addr in addresses { let txt_to_send = format!("dnsaddr={}/p2p/{}", addr.to_string(), peer_id.to_base58()); let mut txt_record = Vec::with_capacity(txt_to_send.len()); - match append_txt_record(&mut txt_record, &peer_id_bytes, ttl, &txt_to_send) { + match append_txt_record(&mut txt_record, &peer_name_bytes, ttl, &txt_to_send) { Ok(()) => { records.push(txt_record); } @@ -139,7 +139,7 @@ pub fn build_query_response( } if records.len() == MAX_RECORDS_PER_PACKET { - packets.push(query_response_packet(id, &peer_id_bytes, &records, ttl)); + packets.push(query_response_packet(id, &peer_name_bytes, &records, ttl)); records.clear(); } } @@ -147,13 +147,13 @@ pub fn build_query_response( // If there are still unpacked records, i.e. if the number of records is not // a multiple of `MAX_RECORDS_PER_PACKET`, create a final packet. if !records.is_empty() { - packets.push(query_response_packet(id, &peer_id_bytes, &records, ttl)); + packets.push(query_response_packet(id, &peer_name_bytes, &records, ttl)); } // If no packets have been built at all, because `addresses` is empty, // construct an empty response packet. if packets.is_empty() { - packets.push(query_response_packet(id, &peer_id_bytes, &Vec::new(), ttl)); + packets.push(query_response_packet(id, &peer_name_bytes, &Vec::new(), ttl)); } packets @@ -268,17 +268,17 @@ fn random_string(length: usize) -> String { .collect() } -/// Generates a peer ID bytes for a DNS query. -fn generate_peer_id() -> Vec { +/// Generates a random peer name as bytes for a DNS query. +fn generate_peer_name() -> Vec { // Use a variable-length random string for mDNS peer name. // See https://github.com/libp2p/rust-libp2p/pull/2311/ let peer_name = random_string(32 + thread_rng().gen_range(0..32)); // allocate with a little extra padding for QNAME encoding - let mut peer_id_bytes = Vec::with_capacity(peer_name.len() + 32); - append_qname(&mut peer_id_bytes, peer_name.as_bytes()); + let mut peer_name_bytes = Vec::with_capacity(peer_name.len() + 32); + append_qname(&mut peer_name_bytes, peer_name.as_bytes()); - peer_id_bytes + peer_name_bytes } /// Appends a `QNAME` (as defined by RFC1035) to the `Vec`. From 4ffa9f41d886a1c614b06237b2684c58a097cf40 Mon Sep 17 00:00:00 2001 From: Pan Chasinga Date: Tue, 16 Nov 2021 19:45:37 -0800 Subject: [PATCH 05/10] Ignore the peer name when constructing a response - Remove the peer ID parsing logic and ignore the peer name. - Remove `my_peer_id` from `MdnsPeer::new(...)` parameters. - Ignore addresses with bad or no peer IDs, use the peer ID of the first address with a peer ID as a reference, and ignore all addresses whose peer ID does not match the first peer ID. Note that `MdnsPeer::new(...)` now returns a Result type because there is no gaurantee that there will be a peer ID to create the peer. --- protocols/mdns/src/query.rs | 97 +++++++++++++++++++++++++++---------- 1 file changed, 72 insertions(+), 25 deletions(-) diff --git a/protocols/mdns/src/query.rs b/protocols/mdns/src/query.rs index c605298a36a..b68f5724f04 100644 --- a/protocols/mdns/src/query.rs +++ b/protocols/mdns/src/query.rs @@ -159,23 +159,13 @@ impl MdnsResponse { _ => return None, }; - let mut peer_name = match record_value.rsplitn(4, |c| c == '.').last() { - Some(n) => n.to_owned(), - None => return None, - }; - - // if we have a segmented name, remove the '.' - peer_name.retain(|c| c != '.'); - - let peer_id = match data_encoding::BASE32_DNSCURVE.decode(peer_name.as_bytes()) { - Ok(bytes) => match PeerId::from_bytes(&bytes) { - Ok(id) => id, - Err(_) => return None, - }, - Err(_) => return None, - }; - - Some(MdnsPeer::new(&packet, record_value, peer_id, record.ttl)) + match MdnsPeer::new(&packet, record_value, record.ttl) { + Ok(peer) => Some(peer), + Err(err) => { + log::debug!("Creating mdns peer failed: {:?}", err); + None + } + } }) .collect(); @@ -218,9 +208,9 @@ impl MdnsPeer { pub fn new( packet: &Packet<'_>, record_value: String, - my_peer_id: PeerId, ttl: u32, - ) -> MdnsPeer { + ) -> Result { + let mut my_peer_id: Option = None; let addrs = packet .additional .iter() @@ -256,8 +246,12 @@ impl MdnsPeer { match addr.pop() { Some(Protocol::P2p(peer_id)) => { if let Ok(peer_id) = PeerId::try_from(peer_id) { - if peer_id != my_peer_id { - return None; + if let Some(pid) = &my_peer_id { + if peer_id != *pid { + return None; + } + } else { + my_peer_id.replace(peer_id); } } else { return None; @@ -269,10 +263,14 @@ impl MdnsPeer { }) .collect(); - MdnsPeer { - addrs, - peer_id: my_peer_id, - ttl, + match my_peer_id { + Some(peer_id) => + Ok(MdnsPeer { + addrs, + peer_id, + ttl, + }), + None => Err("Missing Peer ID".to_string()) } } @@ -303,3 +301,52 @@ impl fmt::Debug for MdnsPeer { .finish() } } + +#[cfg(test)] +mod tests { + + use crate::dns::build_query_response; + use super::*; + + #[test] + fn test_create_mdns_peer() -> Result<(), String> { + let ttl = 300; + let peer_id = PeerId::random(); + + let mut addr1: Multiaddr = "/ip4/1.2.3.4/tcp/5000".parse().unwrap(); + let mut addr2: Multiaddr = "/ip6/::1/udp/10000".parse().unwrap(); + addr1.push(Protocol::P2p(peer_id.clone().into())); + addr2.push(Protocol::P2p(peer_id.clone().into())); + + let packets = build_query_response( + 0xf8f8, + peer_id, + vec![addr1, addr2].into_iter(), + Duration::from_secs(60), + ); + + for bytes in packets { + let packet = Packet::parse(&bytes).unwrap(); + let record_value = packet + .answers + .iter() + .filter_map(|record| { + if record.name.to_string().as_bytes() != SERVICE_NAME { + return None; + } + let record_value = match record.data { + RData::PTR(record) => record.0.to_string(), + _ => return None, + }; + return Some(record_value); + }).next().unwrap(); + + let peer = MdnsPeer::new(&packet, record_value, ttl)?; + assert_eq!(peer.peer_id, peer_id); + } + + Ok(()) + } +} + + From f31ce25e56018e463beaf84abfe8ec1636e0ce6f Mon Sep 17 00:00:00 2001 From: Pan Chasinga Date: Wed, 17 Nov 2021 09:59:07 -0800 Subject: [PATCH 06/10] Returns an Option for MdnsPeer::new(...) Per @MarcoPolo points that an error isn't useful for the caller and following MdnsPacket API. See also: https://github.com/libp2p/rust-libp2p/pull/2311#discussion_r750870918 --- protocols/mdns/src/query.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/protocols/mdns/src/query.rs b/protocols/mdns/src/query.rs index b68f5724f04..662ecac273c 100644 --- a/protocols/mdns/src/query.rs +++ b/protocols/mdns/src/query.rs @@ -159,13 +159,7 @@ impl MdnsResponse { _ => return None, }; - match MdnsPeer::new(&packet, record_value, record.ttl) { - Ok(peer) => Some(peer), - Err(err) => { - log::debug!("Creating mdns peer failed: {:?}", err); - None - } - } + MdnsPeer::new(&packet, record_value, record.ttl) }) .collect(); @@ -209,7 +203,7 @@ impl MdnsPeer { packet: &Packet<'_>, record_value: String, ttl: u32, - ) -> Result { + ) -> Option { let mut my_peer_id: Option = None; let addrs = packet .additional @@ -265,12 +259,12 @@ impl MdnsPeer { match my_peer_id { Some(peer_id) => - Ok(MdnsPeer { + Some(MdnsPeer { addrs, peer_id, ttl, }), - None => Err("Missing Peer ID".to_string()) + None => None, } } @@ -309,7 +303,7 @@ mod tests { use super::*; #[test] - fn test_create_mdns_peer() -> Result<(), String> { + fn test_create_mdns_peer() { let ttl = 300; let peer_id = PeerId::random(); @@ -341,11 +335,9 @@ mod tests { return Some(record_value); }).next().unwrap(); - let peer = MdnsPeer::new(&packet, record_value, ttl)?; + let peer = MdnsPeer::new(&packet, record_value, ttl).unwrap(); assert_eq!(peer.peer_id, peer_id); } - - Ok(()) } } From 4a005e0ff62830e7a8eb75905f04b7973847a990 Mon Sep 17 00:00:00 2001 From: Pan Chasinga Date: Fri, 19 Nov 2021 10:25:32 -0800 Subject: [PATCH 07/10] Clean up with rustfmt --- protocols/mdns/src/dns.rs | 11 ++++++++--- protocols/mdns/src/query.rs | 25 ++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/protocols/mdns/src/dns.rs b/protocols/mdns/src/dns.rs index 83a104068b5..78b8f9e7c57 100644 --- a/protocols/mdns/src/dns.rs +++ b/protocols/mdns/src/dns.rs @@ -22,9 +22,9 @@ use crate::{META_QUERY_SERVICE, SERVICE_NAME}; use libp2p_core::{Multiaddr, PeerId}; -use std::{borrow::Cow, cmp, error, fmt, str, time::Duration}; -use rand::{thread_rng, Rng}; use rand::distributions::Alphanumeric; +use rand::{thread_rng, Rng}; +use std::{borrow::Cow, cmp, error, fmt, str, time::Duration}; /// DNS TXT records can have up to 255 characters as a single string value. /// @@ -153,7 +153,12 @@ pub fn build_query_response( // If no packets have been built at all, because `addresses` is empty, // construct an empty response packet. if packets.is_empty() { - packets.push(query_response_packet(id, &peer_name_bytes, &Vec::new(), ttl)); + packets.push(query_response_packet( + id, + &peer_name_bytes, + &Vec::new(), + ttl, + )); } packets diff --git a/protocols/mdns/src/query.rs b/protocols/mdns/src/query.rs index 662ecac273c..99b19225365 100644 --- a/protocols/mdns/src/query.rs +++ b/protocols/mdns/src/query.rs @@ -199,11 +199,7 @@ pub struct MdnsPeer { impl MdnsPeer { /// Creates a new `MdnsPeer` based on the provided `Packet`. - pub fn new( - packet: &Packet<'_>, - record_value: String, - ttl: u32, - ) -> Option { + pub fn new(packet: &Packet<'_>, record_value: String, ttl: u32) -> Option { let mut my_peer_id: Option = None; let addrs = packet .additional @@ -258,12 +254,11 @@ impl MdnsPeer { .collect(); match my_peer_id { - Some(peer_id) => - Some(MdnsPeer { - addrs, - peer_id, - ttl, - }), + Some(peer_id) => Some(MdnsPeer { + addrs, + peer_id, + ttl, + }), None => None, } } @@ -299,8 +294,8 @@ impl fmt::Debug for MdnsPeer { #[cfg(test)] mod tests { - use crate::dns::build_query_response; use super::*; + use crate::dns::build_query_response; #[test] fn test_create_mdns_peer() { @@ -333,12 +328,12 @@ mod tests { _ => return None, }; return Some(record_value); - }).next().unwrap(); + }) + .next() + .unwrap(); let peer = MdnsPeer::new(&packet, record_value, ttl).unwrap(); assert_eq!(peer.peer_id, peer_id); } } } - - From 25f717649815d2dcb67abc65d8b749cee0eb5fed Mon Sep 17 00:00:00 2001 From: Pan Chasinga Date: Fri, 19 Nov 2021 12:07:49 -0800 Subject: [PATCH 08/10] Minor refactor Refactor match statement to map since it's more idiomatic and concise. Use expect in tests for better cue in the test. --- protocols/mdns/src/query.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/protocols/mdns/src/query.rs b/protocols/mdns/src/query.rs index 99b19225365..12e2748ba75 100644 --- a/protocols/mdns/src/query.rs +++ b/protocols/mdns/src/query.rs @@ -253,14 +253,11 @@ impl MdnsPeer { }) .collect(); - match my_peer_id { - Some(peer_id) => Some(MdnsPeer { - addrs, - peer_id, - ttl, - }), - None => None, - } + my_peer_id.map(|peer_id| MdnsPeer { + addrs, + peer_id, + ttl, + }) } /// Returns the id of the peer. @@ -302,8 +299,8 @@ mod tests { let ttl = 300; let peer_id = PeerId::random(); - let mut addr1: Multiaddr = "/ip4/1.2.3.4/tcp/5000".parse().unwrap(); - let mut addr2: Multiaddr = "/ip6/::1/udp/10000".parse().unwrap(); + let mut addr1: Multiaddr = "/ip4/1.2.3.4/tcp/5000".parse().expect("bad multiaddress"); + let mut addr2: Multiaddr = "/ip6/::1/udp/10000".parse().expect("bad multiaddress"); addr1.push(Protocol::P2p(peer_id.clone().into())); addr2.push(Protocol::P2p(peer_id.clone().into())); @@ -315,7 +312,7 @@ mod tests { ); for bytes in packets { - let packet = Packet::parse(&bytes).unwrap(); + let packet = Packet::parse(&bytes).expect("unable to parse packet"); let record_value = packet .answers .iter() @@ -330,9 +327,9 @@ mod tests { return Some(record_value); }) .next() - .unwrap(); + .expect("empty record value"); - let peer = MdnsPeer::new(&packet, record_value, ttl).unwrap(); + let peer = MdnsPeer::new(&packet, record_value, ttl).expect("fail to create peer"); assert_eq!(peer.peer_id, peer_id); } } From 36d3c2f502f4d25874721895602c072907d05b63 Mon Sep 17 00:00:00 2001 From: Pancy Date: Tue, 23 Nov 2021 14:49:49 -0800 Subject: [PATCH 09/10] Apply suggestions on release version Co-authored-by: Max Inden --- protocols/mdns/CHANGELOG.md | 7 ++++++- protocols/mdns/Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/protocols/mdns/CHANGELOG.md b/protocols/mdns/CHANGELOG.md index da1412d6165..df2b34fce2c 100644 --- a/protocols/mdns/CHANGELOG.md +++ b/protocols/mdns/CHANGELOG.md @@ -1,6 +1,11 @@ # 0.33.1 [unreleased] -- Use a random alphanumeric string for mDNS peer name (see [PR 2311]). +- Use a random alphanumeric string instead of the local peer ID for mDNS peer + name (see [PR 2311]). + + Note that previous versions of `libp2p-mdns` expect the peer name to be a + valid peer ID. Thus they will be unable to discover nodes running this new + version of `libp2p-mdns`. [PR 2311]: https://github.com/libp2p/rust-libp2p/pull/2311/ diff --git a/protocols/mdns/Cargo.toml b/protocols/mdns/Cargo.toml index 8ba29898e0a..44781bc5be1 100644 --- a/protocols/mdns/Cargo.toml +++ b/protocols/mdns/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "libp2p-mdns" edition = "2018" -version = "0.33.1" +version = "0.34.0" description = "Implementation of the libp2p mDNS discovery method" authors = ["Parity Technologies "] license = "MIT" From d769fd6c8cd6f47e7540a582fe2f6f30a8968c7d Mon Sep 17 00:00:00 2001 From: Max Inden Date: Thu, 25 Nov 2021 15:22:48 +0100 Subject: [PATCH 10/10] *: Fix libp2p-mdns version and changelog entries --- CHANGELOG.md | 1 + Cargo.toml | 2 +- protocols/mdns/CHANGELOG.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3112024c21..6ad6c1e07b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ - Update individual crates. - `libp2p-swarm-derive` + - `libp2p-mdns` (breaking compatibility with previous versions) ## Version 0.41.0 [2021-11-16] diff --git a/Cargo.toml b/Cargo.toml index 7a013d18843..5b0f959db7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,7 +99,7 @@ smallvec = "1.6.1" [target.'cfg(not(any(target_os = "emscripten", target_os = "wasi", target_os = "unknown")))'.dependencies] libp2p-deflate = { version = "0.30.0", path = "transports/deflate", optional = true } libp2p-dns = { version = "0.30.0", path = "transports/dns", optional = true, default-features = false } -libp2p-mdns = { version = "0.33.0", path = "protocols/mdns", optional = true } +libp2p-mdns = { version = "0.34.0", path = "protocols/mdns", optional = true } libp2p-tcp = { version = "0.30.0", path = "transports/tcp", default-features = false, optional = true } libp2p-websocket = { version = "0.32.0", path = "transports/websocket", optional = true } diff --git a/protocols/mdns/CHANGELOG.md b/protocols/mdns/CHANGELOG.md index df2b34fce2c..4ea91394762 100644 --- a/protocols/mdns/CHANGELOG.md +++ b/protocols/mdns/CHANGELOG.md @@ -1,4 +1,4 @@ -# 0.33.1 [unreleased] +# 0.34.0 [unreleased] - Use a random alphanumeric string instead of the local peer ID for mDNS peer name (see [PR 2311]).