Cherry-pick commits from master to stable-futures (#1296)

* Implement Debug for (ed25519|secp256k1)::(Keypair|SecretKey) (#1285)

* Fix possible arithmetic overflow in libp2p-kad. (#1291)

When the number of active queries exceeds the (internal)
JOBS_MAX_QUERIES limit, which is only supposed to bound
the number of concurrent queries relating to background
jobs, an arithmetic overflow occurs. This is fixed by
using saturating subtraction.

* protocols/plaintext: Add example on how to upgrade with PlainTextConfig1 (#1286)

* [mdns] - Support for long mDNS names (Bug #1232) (#1287)

* Dead code -- commenting out with a note referencing future implementation

* Adding "std" feature so that cargo can build in other directories (notably `misc/mdns`, so that I could run these tests)

* Permitting `PeerID` to be built from an `Identity` multihash

* The length limit for DNS labels is 63 characters, as per RFC1035

* Allocates the vector with capacity for the service name plus additional QNAME encoding bytes

* Added support for encoding/decoding peer IDs with an encoded length greater than 63 characters

* Removing "std" from ring features

Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>

* Retaining MAX_INLINE_KEY_LENGTH with comment about future usage

* `segment_peer_id` consumes `peer_id` ... plus an early return for IDs that don't need to be segmented

* Fixing logic

* Bump most dependencies (#1268)

* Bump most dependencies

This actually builds 😊.

* Bump all dependencies

Includes the excellent work of @rschulman in #1265.

* Remove use of ed25519-dalek fork

* Monomorphize more dependencies

* Add compatibility hack for rand

Cargo allows a crate to depend on multiple versions of another, but
`cargo-web` panics in that situation.  Use a wrapper crate to work
around the panic.

* Use @tomaka’s idea for using a newer `rand`

instead of my own ugly hack.

* Switch to Parity master

as its dependency-bumping PR has been merged.

* Update some depenendencies again

* Remove unwraps and `#[allow(deprecated)]`.

* Remove spurious changes to dependencies

Bumping minor or patch versions is not needed, and increases likelyhood
of merge conflicts.

* Remove some redundant Cargo.toml changes

* Replace a retry loop with an expect

`ed25519::SecretKey::from_bytes` will never fail for 32-byte inputs.

* Revert changes that don’t belong in this PR

* Remove using void to bypass ICE (#1295)

* Publish 0.13.0 (#1294)
This commit is contained in:
Pierre Krieger
2019-11-06 16:09:15 +01:00
committed by GitHub
parent 7eb4165d44
commit c1226b203a
36 changed files with 322 additions and 170 deletions

View File

@ -1,3 +1,16 @@
# Version 0.13.0 (2019-11-05)
- Reworked the transport upgrade API. See https://github.com/libp2p/rust-libp2p/pull/1240 for more information.
- Added a parameter allowing to choose the protocol negotiation protocol when upgrading a connection or a substream. See https://github.com/libp2p/rust-libp2p/pull/1245 for more information.
- Added an alternative `multistream-select` protocol called `V1Lazy`.
- Added `PlainText2Config` that implements the `/plaintext/2.0.0` protocol.
- Refactored `libp2p-identify`. Some items have been renamed.
- Now accepting `PeerId`s using the `identity` hashing algorithm as valid.
- Removed `libp2p-observed` and `libp2p-ratelimit`.
- Fixed mDNS long peer IDs not being transmitted properly.
- Added some `Debug` trait implementations.
- Fixed potential arithmetic overflows in `libp2p-kad` and `multistream-select`.
# Version 0.12.0 (2019-08-15)
- In some situations, `multistream-select` will now assume that protocol negotiation immediately succeeds. If it turns out that it failed, an error is generated when reading or writing from/to the stream.

View File

@ -2,7 +2,7 @@
name = "libp2p"
edition = "2018"
description = "Peer-to-peer networking library"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -16,23 +16,23 @@ secp256k1 = ["libp2p-core/secp256k1", "libp2p-secio/secp256k1"]
[dependencies]
bytes = "0.4"
futures = "0.1"
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "misc/multiaddr" }
multihash = { package = "parity-multihash", version = "0.1.0", path = "misc/multihash" }
multiaddr = { package = "parity-multiaddr", version = "0.5.1", path = "misc/multiaddr" }
multihash = { package = "parity-multihash", version = "0.1.4", path = "misc/multihash" }
lazy_static = "1.2"
libp2p-mplex = { version = "0.12.0", path = "muxers/mplex" }
libp2p-identify = { version = "0.12.0", path = "protocols/identify" }
libp2p-kad = { version = "0.12.0", path = "protocols/kad" }
libp2p-floodsub = { version = "0.12.0", path = "protocols/floodsub" }
libp2p-ping = { version = "0.12.0", path = "protocols/ping" }
libp2p-plaintext = { version = "0.12.0", path = "protocols/plaintext" }
libp2p-core = { version = "0.12.0", path = "core" }
libp2p-core-derive = { version = "0.12.0", path = "misc/core-derive" }
libp2p-secio = { version = "0.12.0", path = "protocols/secio", default-features = false }
libp2p-swarm = { version = "0.2.0", path = "swarm" }
libp2p-uds = { version = "0.12.0", path = "transports/uds" }
libp2p-wasm-ext = { version = "0.5.0", path = "transports/wasm-ext" }
libp2p-yamux = { version = "0.12.0", path = "muxers/yamux" }
parking_lot = "0.8"
libp2p-mplex = { version = "0.13.0", path = "muxers/mplex" }
libp2p-identify = { version = "0.13.0", path = "protocols/identify" }
libp2p-kad = { version = "0.13.0", path = "protocols/kad" }
libp2p-floodsub = { version = "0.13.0", path = "protocols/floodsub" }
libp2p-ping = { version = "0.13.0", path = "protocols/ping" }
libp2p-plaintext = { version = "0.13.0", path = "protocols/plaintext" }
libp2p-core = { version = "0.13.0", path = "core" }
libp2p-core-derive = { version = "0.13.0", path = "misc/core-derive" }
libp2p-secio = { version = "0.13.0", path = "protocols/secio", default-features = false }
libp2p-swarm = { version = "0.3.0", path = "swarm" }
libp2p-uds = { version = "0.13.0", path = "transports/uds" }
libp2p-wasm-ext = { version = "0.6.0", path = "transports/wasm-ext" }
libp2p-yamux = { version = "0.13.0", path = "muxers/yamux" }
parking_lot = "0.9.0"
smallvec = "0.6"
tokio-codec = "0.1"
tokio-executor = "0.1"
@ -40,15 +40,15 @@ tokio-io = "0.1"
wasm-timer = "0.1"
[target.'cfg(not(any(target_os = "emscripten", target_os = "unknown")))'.dependencies]
libp2p-deflate = { version = "0.4.0", path = "protocols/deflate" }
libp2p-dns = { version = "0.12.0", path = "transports/dns" }
libp2p-mdns = { version = "0.12.0", path = "misc/mdns" }
libp2p-noise = { version = "0.10.0", path = "protocols/noise" }
libp2p-tcp = { version = "0.12.0", path = "transports/tcp" }
libp2p-websocket = { version = "0.12.0", path = "transports/websocket", optional = true }
libp2p-deflate = { version = "0.5.0", path = "protocols/deflate" }
libp2p-dns = { version = "0.13.0", path = "transports/dns" }
libp2p-mdns = { version = "0.13.0", path = "misc/mdns" }
libp2p-noise = { version = "0.11.0", path = "protocols/noise" }
libp2p-tcp = { version = "0.13.0", path = "transports/tcp" }
libp2p-websocket = { version = "0.13.0", path = "transports/websocket", optional = true }
[dev-dependencies]
env_logger = "0.6.0"
env_logger = "0.7.1"
tokio = "0.1"
tokio-stdin-stdout = "0.1"

View File

@ -2,7 +2,7 @@
name = "libp2p-core"
edition = "2018"
description = "Core traits and structs of libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -11,22 +11,22 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
asn1_der = "0.6.1"
bs58 = "0.2.0"
bs58 = "0.3.0"
bytes = "0.4"
ed25519-dalek = "1.0.0-pre.1"
ed25519-dalek = "1.0.0-pre.2"
failure = "0.1"
fnv = "1.0"
futures-timer = "0.3"
lazy_static = "1.2"
log = "0.4"
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../misc/multiaddr" }
multihash = { package = "parity-multihash", version = "0.1.0", path = "../misc/multihash" }
multistream-select = { version = "0.5.0", path = "../misc/multistream-select" }
multihash = { package = "parity-multihash", version = "0.1.4", path = "../misc/multihash" }
multistream-select = { version = "0.6.0", path = "../misc/multistream-select" }
futures-preview = { version = "0.3.0-alpha.18", features = ["compat", "io-compat"] }
parking_lot = "0.8"
parking_lot = "0.9.0"
protobuf = "2.8"
quick-error = "1.2"
rand = "0.6"
rand = "0.7"
rw-stream-sink = { version = "0.1.1", path = "../misc/rw-stream-sink" }
libsecp256k1 = { version = "0.3.1", optional = true }
sha2 = "0.8.0"
@ -37,17 +37,17 @@ void = "1"
zeroize = "1"
[target.'cfg(not(any(target_os = "emscripten", target_os = "unknown")))'.dependencies]
ring = { version = "^0.16", features = ["alloc", "std"], default-features = false }
untrusted = { version = "0.6" }
ring = { version = "0.16.9", features = ["alloc", "std"], default-features = false }
untrusted = "0.7.0"
[dev-dependencies]
async-std = "0.99"
libp2p-swarm = { version = "0.2.0", path = "../swarm" }
libp2p-tcp = { version = "0.12.0", path = "../transports/tcp" }
libp2p-mplex = { version = "0.12.0", path = "../muxers/mplex" }
libp2p-secio = { version = "0.12.0", path = "../protocols/secio" }
rand = "0.6"
quickcheck = "0.8"
libp2p-swarm = { version = "0.3.0", path = "../swarm" }
libp2p-tcp = { version = "0.13.0", path = "../transports/tcp" }
libp2p-mplex = { version = "0.13.0", path = "../muxers/mplex" }
libp2p-secio = { version = "0.13.0", path = "../protocols/secio" }
rand = "0.7.2"
quickcheck = "0.9.0"
wasm-timer = "0.2"
assert_matches = "1.3"

View File

@ -22,8 +22,10 @@
use ed25519_dalek as ed25519;
use failure::Fail;
use rand::RngCore;
use super::error::DecodingError;
use zeroize::Zeroize;
use core::fmt;
/// An Ed25519 keypair.
pub struct Keypair(ed25519::Keypair);
@ -31,7 +33,7 @@ pub struct Keypair(ed25519::Keypair);
impl Keypair {
/// Generate a new Ed25519 keypair.
pub fn generate() -> Keypair {
Keypair(ed25519::Keypair::generate(&mut rand::thread_rng()))
Keypair::from(SecretKey::generate())
}
/// Encode the keypair into a byte array by concatenating the bytes
@ -66,6 +68,12 @@ impl Keypair {
}
}
impl fmt::Debug for Keypair {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Keypair").field("public", &self.0.public).finish()
}
}
impl Clone for Keypair {
fn clone(&self) -> Keypair {
let mut sk_bytes = self.0.secret.to_bytes();
@ -87,9 +95,9 @@ impl From<Keypair> for SecretKey {
/// Promote an Ed25519 secret key into a keypair.
impl From<SecretKey> for Keypair {
fn from(sk: SecretKey) -> Keypair {
let secret = sk.0;
let secret: ed25519::ExpandedSecretKey = (&sk.0).into();
let public = ed25519::PublicKey::from(&secret);
Keypair(ed25519::Keypair { secret, public })
Keypair(ed25519::Keypair { secret: sk.0, public })
}
}
@ -135,10 +143,19 @@ impl Clone for SecretKey {
}
}
impl fmt::Debug for SecretKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "SecretKey")
}
}
impl SecretKey {
/// Generate a new Ed25519 secret key.
pub fn generate() -> SecretKey {
SecretKey(ed25519::SecretKey::generate(&mut rand::thread_rng()))
let mut bytes = [0u8; 32];
rand::thread_rng().fill_bytes(&mut bytes);
SecretKey(ed25519::SecretKey::from_bytes(&bytes)
.expect("this returns `Err` only if the length is wrong; the length is correct; qed"))
}
/// Create an Ed25519 secret key from a byte slice, zeroing the input on success.

View File

@ -26,6 +26,7 @@ use sha2::{Digest as ShaDigestTrait, Sha256};
use secp256k1::{Message, Signature};
use super::error::{DecodingError, SigningError};
use zeroize::Zeroize;
use core::fmt;
/// A Secp256k1 keypair.
#[derive(Clone)]
@ -51,6 +52,12 @@ impl Keypair {
}
}
impl fmt::Debug for Keypair {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Keypair").field("public", &self.public).finish()
}
}
/// Promote a Secp256k1 secret key into a keypair.
impl From<SecretKey> for Keypair {
fn from(secret: SecretKey) -> Keypair {
@ -70,6 +77,12 @@ impl From<Keypair> for SecretKey {
#[derive(Clone)]
pub struct SecretKey(secp256k1::SecretKey);
impl fmt::Debug for SecretKey {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "SecretKey")
}
}
impl SecretKey {
/// Generate a new Secp256k1 secret key.
pub fn generate() -> SecretKey {

View File

@ -26,6 +26,8 @@ use std::{convert::TryFrom, fmt, str::FromStr};
/// Public keys with byte-lengths smaller than `MAX_INLINE_KEY_LENGTH` will be
/// automatically used as the peer id using an identity multihash.
//
// Note: see `from_public_key` for how this value will be used in the future.
const MAX_INLINE_KEY_LENGTH: usize = 42;
/// Identifier of a peer of the network.
@ -98,7 +100,7 @@ impl PeerId {
/// returns back the data as an error.
#[inline]
pub fn from_multihash(data: multihash::Multihash) -> Result<PeerId, multihash::Multihash> {
if data.algorithm() == multihash::Hash::SHA2256 {
if data.algorithm() == multihash::Hash::SHA2256 || data.algorithm() == multihash::Hash::Identity {
Ok(PeerId { multihash: data })
} else {
Err(data)

View File

@ -2,7 +2,7 @@
name = "libp2p-core-derive"
edition = "2018"
description = "Procedural macros of libp2p-core"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -17,4 +17,4 @@ syn = { version = "0.15.22", default-features = false, features = ["clone-impls"
quote = "0.6"
[dev-dependencies]
libp2p = { version = "0.12.0", path = "../.." }
libp2p = { version = "0.13.0", path = "../.." }

View File

@ -1,7 +1,7 @@
[package]
name = "libp2p-mdns"
edition = "2018"
version = "0.12.0"
version = "0.13.0"
description = "Implementation of the libp2p mDNS discovery method"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
@ -14,8 +14,8 @@ async-std = "0.99"
data-encoding = "2.0"
dns-parser = "0.8"
futures-preview = "0.3.0-alpha.18"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-swarm = { version = "0.2.0", path = "../../swarm" }
libp2p-core = { version = "0.13.0", path = "../../core" }
libp2p-swarm = { version = "0.3.0", path = "../../swarm" }
log = "0.4"
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../multiaddr" }
net2 = "0.2"

View File

@ -27,6 +27,9 @@ use libp2p_core::{Multiaddr, PeerId};
use rand;
use std::{borrow::Cow, cmp, error, fmt, str, time::Duration};
/// Maximum size of a DNS label as per RFC1035
const MAX_LABEL_LENGTH: usize = 63;
/// Decodes a `<character-string>` (as defined by RFC1035) into a `Vec` of ASCII characters.
// TODO: better error type?
pub fn decode_character_string(mut from: &[u8]) -> Result<Cow<'_, [u8]>, ()> {
@ -117,23 +120,15 @@ pub fn build_query_response(
// TTL for the answer
append_u32(&mut out, ttl);
let peer_id_base58 = peer_id.to_base58();
// Peer Id.
let peer_name = format!(
"{}.{}",
data_encoding::BASE32_DNSCURVE.encode(&peer_id.into_bytes()),
str::from_utf8(SERVICE_NAME).expect("SERVICE_NAME is always ASCII")
);
let mut peer_id_bytes = Vec::with_capacity(64);
append_qname(&mut peer_id_bytes, peer_name.as_bytes());
let peer_id_bytes = encode_peer_id(&peer_id);
debug_assert!(peer_id_bytes.len() <= 0xffff);
append_u16(&mut out, peer_id_bytes.len() as u16);
out.extend_from_slice(&peer_id_bytes);
// The TXT records for answers.
for addr in addresses {
let txt_to_send = format!("dnsaddr={}/p2p/{}", addr.to_string(), peer_id_base58);
let txt_to_send = format!("dnsaddr={}/p2p/{}", addr.to_string(), peer_id.to_base58());
let mut txt_to_send_bytes = Vec::with_capacity(txt_to_send.len());
append_character_string(&mut txt_to_send_bytes, txt_to_send.as_bytes())?;
append_txt_record(&mut out, &peer_id_bytes, ttl, Some(&txt_to_send_bytes[..]))?;
@ -177,7 +172,7 @@ pub fn build_service_discovery_response(id: u16, ttl: Duration) -> Vec<u8> {
// Service name.
{
let mut name = Vec::new();
let mut name = Vec::with_capacity(SERVICE_NAME.len() + 2);
append_qname(&mut name, SERVICE_NAME);
append_u16(&mut out, name.len() as u16);
out.extend_from_slice(&name);
@ -211,6 +206,40 @@ fn append_u16(out: &mut Vec<u8>, 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
}
/// Combines and encodes a `PeerId` and service name for a DNS query.
fn encode_peer_id(peer_id: &PeerId) -> Vec<u8> {
// DNS-safe encoding for the Peer ID
let raw_peer_id = data_encoding::BASE32_DNSCURVE.encode(&peer_id.as_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");
let peer_name = [&encoded_peer_id, service_name].join(".");
// 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());
peer_id_bytes
}
/// Appends a `QNAME` (as defined by RFC1035) to the `Vec`.
///
/// # Panic
@ -223,7 +252,7 @@ fn append_qname(out: &mut Vec<u8>, name: &[u8]) {
debug_assert!(name.is_ascii());
for element in name.split(|&c| c == b'.') {
assert!(element.len() < 256, "Service name has a label too long");
assert!(element.len() < 64, "Service name has a label too long");
assert_ne!(element.len(), 0, "Service name contains zero length label");
out.push(element.len() as u8);
for chr in element.iter() {
@ -367,5 +396,21 @@ 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("."));
}
// TODO: test limits and errors
}

View File

@ -394,18 +394,14 @@ impl<'a> MdnsResponse<'a> {
_ => return None,
};
let peer_name = {
let mut iter = record_value.splitn(2, |c| c == '.');
let name = match iter.next() {
Some(n) => n.to_owned(),
None => return None,
};
if iter.next().map(|v| v.as_bytes()) != Some(SERVICE_NAME) {
return None;
}
name
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,
@ -524,11 +520,10 @@ mod tests {
use libp2p_core::PeerId;
use std::{io, task::Poll, time::Duration};
use crate::service::{MdnsPacket, MdnsService};
use multiaddr::multihash::*;
#[test]
fn discover_ourselves() {
fn discover(peer_id: PeerId) {
let mut service = MdnsService::new().unwrap();
let peer_id = PeerId::random();
let stream = stream::poll_fn(move |cx| -> Poll<Option<Result<(), io::Error>>> {
loop {
let packet = match service.poll(cx) {
@ -558,4 +553,16 @@ mod tests {
.for_each(|_| future::ready(())),
);
}
#[test]
fn discover_normal_peer_id() {
discover(PeerId::random())
}
#[test]
fn discover_long_peer_id() {
let max_value = String::from_utf8(vec![b'f'; 42]).unwrap();
let hash = encode(Hash::Identity, max_value.as_ref()).unwrap();
discover(PeerId::from_multihash(hash).unwrap())
}
}

View File

@ -6,15 +6,15 @@ description = "Implementation of the multiaddr format"
homepage = "https://github.com/libp2p/rust-libp2p"
keywords = ["multiaddr", "ipfs"]
license = "MIT"
version = "0.5.0"
version = "0.5.1"
[dependencies]
arrayref = "0.3"
bs58 = "0.2.0"
bs58 = "0.3.0"
byteorder = "1.3.1"
bytes = "0.4.12"
data-encoding = "2.1"
multihash = { package = "parity-multihash", version = "0.1.0", path = "../multihash" }
multihash = { package = "parity-multihash", version = "0.1.4", path = "../multihash" }
percent-encoding = "2.1.0"
serde = "1.0.70"
unsigned-varint = "0.2"
@ -22,8 +22,8 @@ url = { version = "2.1.0", default-features = false }
[dev-dependencies]
bincode = "1"
bs58 = "0.2.0"
bs58 = "0.3.0"
data-encoding = "2"
quickcheck = "0.8.1"
rand = "0.6.5"
quickcheck = "0.9.0"
rand = "0.7.2"
serde_json = "1.0"

View File

@ -4,7 +4,7 @@ edition = "2018"
description = "Implementation of the multihash format"
repository = "https://github.com/libp2p/rust-libp2p"
keywords = ["multihash", "ipfs"]
version = "0.1.3"
version = "0.1.4"
authors = ["dignifiedquire <dignifiedquire@gmail.com>", "Parity Technologies <admin@parity.io>"]
license = "MIT"
documentation = "https://docs.rs/parity-multihash/"

View File

@ -1,7 +1,7 @@
[package]
name = "multistream-select"
description = "Multistream-select negotiation protocol for libp2p"
version = "0.5.1"
version = "0.6.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -11,14 +11,14 @@ edition = "2018"
[dependencies]
bytes = "0.4"
futures = { version = "0.1" }
futures = "0.1"
log = "0.4"
smallvec = "0.6"
tokio-io = "0.1"
unsigned-varint = { version = "0.2.2" }
unsigned-varint = "0.2.2"
[dev-dependencies]
tokio = "0.1"
tokio-tcp = "0.1"
quickcheck = "0.8"
rand = "0.6"
quickcheck = "0.9.0"
rand = "0.7.2"

View File

@ -11,5 +11,5 @@ categories = ["network-programming", "asynchronous"]
publish = false
[dependencies]
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
num_cpus = "1.8"

View File

@ -2,7 +2,7 @@
name = "libp2p-mplex"
edition = "2018"
description = "Mplex multiplexing protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -14,10 +14,10 @@ bytes = "0.4.5"
fnv = "1.0"
futures_codec = "0.3.0"
futures-preview = "0.3.0-alpha.18"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4"
parking_lot = "0.8"
unsigned-varint = { version = "0.2.3", features = ["futures-codec"] }
[dev-dependencies]
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }

View File

@ -2,7 +2,7 @@
name = "libp2p-yamux"
edition = "2018"
description = "Yamux multiplexing protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -11,7 +11,7 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
futures = "0.1"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4"
tokio-io = "0.1"
yamux = "0.2.1"

View File

@ -2,7 +2,7 @@
name = "libp2p-deflate"
edition = "2018"
description = "Deflate encryption protocol for libp2p"
version = "0.4.0"
version = "0.5.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -11,12 +11,12 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
futures-preview = "0.3.0-alpha.18"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
flate2 = "1.0"
[dev-dependencies]
async-std = "0.99"
env_logger = "0.6"
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
env_logger = "0.7.1"
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
rand = "0.7"
quickcheck = "0.8"
quickcheck = "0.9.0"

View File

@ -2,7 +2,7 @@
name = "libp2p-floodsub"
edition = "2018"
description = "Floodsub protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -10,13 +10,13 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]
[dependencies]
bs58 = "0.2.0"
bs58 = "0.3.0"
bytes = "0.4"
cuckoofilter = "0.3.2"
fnv = "1.0"
futures-preview = "0.3.0-alpha.18"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-swarm = { version = "0.2.0", path = "../../swarm" }
libp2p-core = { version = "0.13.0", path = "../../core" }
libp2p-swarm = { version = "0.3.0", path = "../../swarm" }
protobuf = "2.8"
rand = "0.6"
smallvec = "0.6.5"

View File

@ -2,7 +2,7 @@
name = "libp2p-identify"
edition = "2018"
description = "Nodes identifcation protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -13,18 +13,17 @@ categories = ["network-programming", "asynchronous"]
bytes = "0.4"
futures_codec = "0.3.0"
futures-preview = "0.3.0-alpha.18"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-swarm = { version = "0.2.0", path = "../../swarm" }
libp2p-core = { version = "0.13.0", path = "../../core" }
libp2p-swarm = { version = "0.3.0", path = "../../swarm" }
log = "0.4.1"
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../../misc/multiaddr" }
protobuf = "2.8"
smallvec = "0.6"
wasm-timer = "0.2"
unsigned-varint = { version = "0.2.3", features = ["futures-codec"] }
void = "1.0"
[dev-dependencies]
libp2p-mplex = { version = "0.12.0", path = "../../muxers/mplex" }
libp2p-secio = { version = "0.12.0", path = "../../protocols/secio" }
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
libp2p-mplex = { version = "0.13.0", path = "../../muxers/mplex" }
libp2p-secio = { version = "0.13.0", path = "../../protocols/secio" }
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
rand = "0.6"

View File

@ -36,7 +36,6 @@ use libp2p_swarm::{
use smallvec::SmallVec;
use std::{marker::PhantomData, pin::Pin, task::Context, task::Poll, time::Duration};
use wasm_timer::Delay;
use void::Void;
/// Delay between the moment we connect and the first time we identify.
const DELAY_TO_FIRST_ID: Duration = Duration::from_millis(500);
@ -95,7 +94,7 @@ impl<TSubstream> ProtocolsHandler for IdentifyHandler<TSubstream>
where
TSubstream: AsyncRead + AsyncWrite + Unpin + 'static,
{
type InEvent = Void;
type InEvent = ();
type OutEvent = IdentifyHandlerEvent<TSubstream>;
type Error = ReadOneError;
type Substream = TSubstream;

View File

@ -36,7 +36,6 @@ use libp2p_swarm::{
ProtocolsHandlerUpgrErr
};
use std::{collections::HashMap, collections::VecDeque, io, pin::Pin, task::Context, task::Poll};
use void::Void;
/// Network behaviour that automatically identifies nodes periodically, returns information
/// about them, and answers identify queries from other nodes.
@ -52,7 +51,7 @@ pub struct Identify<TSubstream> {
/// Pending replies to send.
pending_replies: VecDeque<Reply<TSubstream>>,
/// Pending events to be emitted when polled.
events: VecDeque<NetworkBehaviourAction<Void, IdentifyEvent>>,
events: VecDeque<NetworkBehaviourAction<(), IdentifyEvent>>,
}
/// A pending reply to an inbound identification request.

View File

@ -2,7 +2,7 @@
name = "libp2p-kad"
edition = "2018"
description = "Kademlia protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -10,19 +10,19 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]
[dependencies]
arrayvec = "0.4.7"
arrayvec = "0.5.1"
bytes = "0.4"
either = "1.5"
fnv = "1.0"
futures_codec = "0.3.0"
futures-preview = "0.3.0-alpha.18"
log = "0.4"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-swarm = { version = "0.2.0", path = "../../swarm" }
libp2p-core = { version = "0.13.0", path = "../../core" }
libp2p-swarm = { version = "0.3.0", path = "../../swarm" }
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../../misc/multiaddr" }
multihash = { package = "parity-multihash", version = "0.1.0", path = "../../misc/multihash" }
multihash = { package = "parity-multihash", version = "0.1.4", path = "../../misc/multihash" }
protobuf = "2.8"
rand = "0.6.0"
rand = "0.7.2"
sha2 = "0.8.0"
smallvec = "0.6"
wasm-timer = "0.2"
@ -31,8 +31,8 @@ unsigned-varint = { version = "0.2.3", features = ["futures-codec"] }
void = "1.0"
[dev-dependencies]
libp2p-secio = { version = "0.12.0", path = "../secio" }
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
libp2p-yamux = { version = "0.12.0", path = "../../muxers/yamux" }
quickcheck = "0.8"
rand = "0.6.0"
libp2p-secio = { version = "0.13.0", path = "../secio" }
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
libp2p-yamux = { version = "0.13.0", path = "../../muxers/yamux" }
quickcheck = "0.9.0"
rand = "0.7.2"

View File

@ -1313,7 +1313,7 @@ where
let now = Instant::now();
// Calculate the available capacity for queries triggered by background jobs.
let mut jobs_query_capacity = JOBS_MAX_QUERIES - self.queries.size();
let mut jobs_query_capacity = JOBS_MAX_QUERIES.saturating_sub(self.queries.size());
// Run the periodic provider announcement job.
if let Some(mut job) = self.add_provider_job.take() {

View File

@ -623,3 +623,34 @@ fn add_provider() {
QuickCheck::new().tests(3).quickcheck(prop as fn(_,_))
}
/// User code should be able to start queries beyond the internal
/// query limit for background jobs. Originally this even produced an
/// arithmetic overflow, see https://github.com/libp2p/rust-libp2p/issues/1290.
#[test]
fn exceed_jobs_max_queries() {
let (_, mut swarms) = build_nodes(1);
let num = JOBS_MAX_QUERIES + 1;
for _ in 0 .. num {
swarms[0].bootstrap();
}
assert_eq!(swarms[0].queries.size(), num);
current_thread::run(
future::poll_fn(move || {
for _ in 0 .. num {
// There are no other nodes, so the queries finish instantly.
if let Ok(Async::Ready(Some(e))) = swarms[0].poll() {
if let KademliaEvent::BootstrapResult(r) = e {
assert!(r.is_ok(), "Unexpected error")
} else {
panic!("Unexpected event: {:?}", e)
}
} else {
panic!("Expected event")
}
}
Ok(Async::Ready(()))
}))
}

View File

@ -1,7 +1,7 @@
[package]
name = "libp2p-noise"
description = "Cryptographic handshake protocol using the noise framework."
version = "0.10.0"
version = "0.11.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -12,19 +12,19 @@ bytes = "0.4"
curve25519-dalek = "1"
futures-preview = "0.3.0-alpha.18"
lazy_static = "1.2"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4"
protobuf = "2.8"
rand = "^0.7"
ring = { version = "^0.16", features = ["alloc"], default-features = false }
rand = "^0.7.2"
ring = { version = "0.16.9", features = ["alloc"], default-features = false }
snow = { version = "0.6.1", features = ["ring-resolver"], default-features = false }
tokio-io = "0.1"
x25519-dalek = "0.5"
zeroize = "1"
[dev-dependencies]
env_logger = "0.6"
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
quickcheck = "0.8"
env_logger = "0.7.1"
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
quickcheck = "0.9.0"
tokio = "0.1"
sodiumoxide = "^0.2.5"

View File

@ -252,4 +252,3 @@ impl rand::RngCore for Rng {
impl rand::CryptoRng for Rng {}
impl snow::types::Random for Rng {}

View File

@ -2,7 +2,7 @@
name = "libp2p-ping"
edition = "2018"
description = "Ping protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -11,19 +11,19 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
bytes = "0.4"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-swarm = { version = "0.2.0", path = "../../swarm" }
libp2p-core = { version = "0.13.0", path = "../../core" }
libp2p-swarm = { version = "0.3.0", path = "../../swarm" }
log = "0.4.1"
multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../../misc/multiaddr" }
futures-preview = "0.3.0-alpha.18"
rand = "0.6"
rand = "0.7.2"
wasm-timer = "0.2"
void = "1.0"
[dev-dependencies]
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
libp2p-secio = { version = "0.12.0", path = "../../protocols/secio" }
libp2p-yamux = { version = "0.12.0", path = "../../muxers/yamux" }
quickcheck = "0.8"
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
libp2p-secio = { version = "0.13.0", path = "../../protocols/secio" }
libp2p-yamux = { version = "0.13.0", path = "../../muxers/yamux" }
quickcheck = "0.9.0"
tokio = "0.1"
tokio-tcp = "0.1"

View File

@ -2,7 +2,7 @@
name = "libp2p-plaintext"
edition = "2018"
description = "Plaintext encryption dummy protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -10,11 +10,11 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]
[dependencies]
bytes = "0.4"
futures-preview = "0.3.0-alpha.18"
libp2p-core = { version = "0.12.0", path = "../../core" }
log = "0.4.6"
void = "1"
libp2p-core = { version = "0.13.0", path = "../../core" }
bytes = "0.4.12"
log = "0.4.8"
void = "1.0.2"
tokio-io = "0.1.12"
protobuf = "2.3"
protobuf = "2.8.1"
rw-stream-sink = { version = "0.1.1", path = "../../misc/rw-stream-sink" }

View File

@ -32,6 +32,32 @@ mod error;
mod handshake;
mod pb;
/// `PlainText1Config` is an insecure connection handshake for testing purposes only.
///
/// > **Note**: Given that `PlainText1Config` has no notion of exchanging peer identity information it is not compatible
/// > with the `libp2p_core::transport::upgrade::Builder` pattern. See
/// > [`PlainText2Config`](struct.PlainText2Config.html) if compatibility is needed. Even though not compatible with the
/// > Builder pattern one can still do an upgrade *manually*:
///
/// ```
/// # use libp2p_core::transport::{ Transport, memory::MemoryTransport };
/// # use libp2p_plaintext::PlainText1Config;
/// #
/// MemoryTransport::default()
/// .and_then(move |io, endpoint| {
/// libp2p_core::upgrade::apply(
/// io,
/// PlainText1Config{},
/// endpoint,
/// libp2p_core::transport::upgrade::Version::V1,
/// )
/// })
/// .map(|plaintext, _endpoint| {
/// unimplemented!();
/// // let peer_id = somehow_derive_peer_id();
/// // return (peer_id, plaintext);
/// });
/// ```
#[derive(Debug, Copy, Clone)]
pub struct PlainText1Config;
@ -64,6 +90,8 @@ impl<C> OutboundUpgrade<C> for PlainText1Config {
}
}
/// `PlainText2Config` is an insecure connection handshake for testing purposes only, implementing
/// the libp2p plaintext connection handshake specification.
#[derive(Clone)]
pub struct PlainText2Config {
pub local_public_key: identity::PublicKey,

View File

@ -2,7 +2,7 @@
name = "libp2p-secio"
edition = "2018"
description = "Secio encryption protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -13,7 +13,7 @@ categories = ["network-programming", "asynchronous"]
bytes = "0.4"
futures-preview = "0.3.0-alpha.18"
futures_codec = "0.3.0"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4.6"
protobuf = "2.8"
rand = "0.6.5"
@ -28,8 +28,8 @@ hmac = "0.7.0"
unsigned-varint = { version = "0.2.3", features = ["futures-codec"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
ring = { version = "^0.16", features = ["alloc"], default-features = false }
untrusted = { version = "0.6" }
ring = { version = "0.16.9", features = ["alloc"], default-features = false }
untrusted = "0.7.0"
[target.'cfg(target_arch = "wasm32")'.dependencies]
js-sys = "0.3.10"
@ -45,9 +45,9 @@ aes-all = ["aesni"]
[dev-dependencies]
async-std = "0.99"
criterion = "0.2"
libp2p-mplex = { version = "0.12.0", path = "../../muxers/mplex" }
libp2p-tcp = { version = "0.12.0", path = "../../transports/tcp" }
criterion = "0.3.0"
libp2p-mplex = { version = "0.13.0", path = "../../muxers/mplex" }
libp2p-tcp = { version = "0.13.0", path = "../../transports/tcp" }
[[bench]]
name = "bench"

View File

@ -2,7 +2,7 @@
name = "libp2p-swarm"
edition = "2018"
description = "The libp2p swarm"
version = "0.2.0"
version = "0.3.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -11,12 +11,12 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
futures-preview = "0.3.0-alpha.18"
libp2p-core = { version = "0.12.0", path = "../core" }
libp2p-core = { version = "0.13.0", path = "../core" }
smallvec = "0.6"
wasm-timer = "0.2"
void = "1"
[dev-dependencies]
libp2p-mplex = { version = "0.12.0", path = "../muxers/mplex" }
quickcheck = "0.8"
rand = "0.6"
libp2p-mplex = { version = "0.13.0", path = "../muxers/mplex" }
quickcheck = "0.9.0"
rand = "0.7.2"

View File

@ -2,7 +2,7 @@
name = "libp2p-dns"
edition = "2018"
description = "DNS transport implementation for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -10,6 +10,6 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]
[dependencies]
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4.1"
futures-preview = "0.3.0-alpha.18"

View File

@ -2,7 +2,7 @@
name = "libp2p-tcp"
edition = "2018"
description = "TCP/IP transport protocol for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -14,7 +14,7 @@ async-std = "0.99"
bytes = "0.4"
get_if_addrs = "0.5.3"
ipnet = "2.0.0"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4.1"
futures-preview = "0.3.0-alpha.18"
futures-timer = "0.3"

View File

@ -2,7 +2,7 @@
name = "libp2p-uds"
edition = "2018"
description = "Unix domain sockets transport for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -10,7 +10,7 @@ keywords = ["peer-to-peer", "libp2p", "networking"]
categories = ["network-programming", "asynchronous"]
[target.'cfg(all(unix, not(any(target_os = "emscripten", target_os = "unknown"))))'.dependencies]
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4.1"
futures-preview = "0.3.0-alpha.18"
romio = "0.3.0-alpha.9"

View File

@ -1,6 +1,6 @@
[package]
name = "libp2p-wasm-ext"
version = "0.5.0"
version = "0.6.0"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
edition = "2018"
description = "Allows passing in an external transport in a WASM environment"
@ -12,7 +12,7 @@ categories = ["network-programming", "asynchronous"]
[dependencies]
futures-preview = "0.3.0-alpha.18"
js-sys = "0.3.19"
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
parity-send-wrapper = "0.1.0"
wasm-bindgen = "0.2.42"
wasm-bindgen-futures = { version = "0.3.25", features = ["futures_0_3"] }

View File

@ -2,7 +2,7 @@
name = "libp2p-websocket"
edition = "2018"
description = "WebSocket transport for libp2p"
version = "0.12.0"
version = "0.13.0"
authors = ["Parity Technologies <admin@parity.io>"]
license = "MIT"
repository = "https://github.com/libp2p/rust-libp2p"
@ -14,12 +14,12 @@ bytes = "0.4.12"
either = "1.5.3"
futures-preview = "0.3.0-alpha.18"
#futures-rustls = "0.12.0-alpha" # TODO: https://github.com/quininer/tokio-rustls/issues/51
libp2p-core = { version = "0.12.0", path = "../../core" }
libp2p-core = { version = "0.13.0", path = "../../core" }
log = "0.4.8"
rw-stream-sink = { version = "0.1.1", path = "../../misc/rw-stream-sink" }
soketto = { git = "https://github.com/paritytech/soketto.git", branch = "develop", features = ["deflate"] }
url = "2.1.0"
webpki-roots = "0.17.0"
webpki-roots = "0.18.0"
[dev-dependencies]
libp2p-tcp = { version = "0.12.0", path = "../tcp" }
libp2p-tcp = { version = "0.13.0", path = "../tcp" }