Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ default = [
"websocket",
"yamux",
]
dcutr = ["libp2p-dcutr"]
deflate = ["libp2p-deflate"]
dns-async-std = ["libp2p-dns", "libp2p-dns/async-std"]
dns-tokio = ["libp2p-dns", "libp2p-dns/tokio"]
Expand All @@ -48,7 +49,7 @@ noise = ["libp2p-noise"]
ping = ["libp2p-ping", "libp2p-metrics/ping"]
plaintext = ["libp2p-plaintext"]
pnet = ["libp2p-pnet"]
relay = ["libp2p-relay"]
relay = ["libp2p-relay", "libp2p-metrics/relay"]
request-response = ["libp2p-request-response"]
rendezvous = ["libp2p-rendezvous"]
tcp-async-io = ["libp2p-tcp", "libp2p-tcp/async-io"]
Expand All @@ -72,6 +73,7 @@ futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` featu
getrandom = "0.2.3" # Explicit dependency to be used in `wasm-bindgen` feature
instant = "0.1.11" # Explicit dependency to be used in `wasm-bindgen` feature
lazy_static = "1.2"
libp2p-dcutr = { version = "0.1.0", path = "protocols/dcutr", optional = true }
libp2p-core = { version = "0.31.0", path = "core", default-features = false }
libp2p-floodsub = { version = "0.33.0", path = "protocols/floodsub", optional = true }
libp2p-gossipsub = { version = "0.35.0", path = "./protocols/gossipsub", optional = true }
Expand Down Expand Up @@ -119,6 +121,7 @@ members = [
"misc/peer-id-generator",
"muxers/mplex",
"muxers/yamux",
"protocols/dcutr",
"protocols/floodsub",
"protocols/gossipsub",
"protocols/rendezvous",
Expand Down
36 changes: 36 additions & 0 deletions core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,43 @@
Introduce `upgrade::read_length_prefixed` and `upgrade::write_length_prefixed`.
See [PR 2111](https://github.com/libp2p/rust-libp2p/pull/2111).

- Add support for multistream-select [simultaneous open extension] to assign _initiator_ and
_responder_ role during authentication protocol negotiation on simultaneously opened connection.

This is one important component of the greater effort to support hole punching in rust-libp2p.

- `Transport::upgrade` no longer takes a multistream-select `Version`. Instead the
multistream-select `Version`s `V1`, `V1Lazy` and `V1SimultaneousOpen` can be selected when
setting the authentication upgrade via `Builder::authenticate_with_version` and the
multistream-select `Version`s `V1` and `V1Lazy` can be selected when setting the multiplexing
upgrade via `Builder::multiplex_with_version`.

Users merely wanting to maintain the status quo should use the following call chain depending
on which `Version` they previously used:

- `Version::V1`

```rust
my_transport.upgrade()
.authenticate(my_authentication)
.multiplex(my_multiplexer)
```
- `Version::V1Lazy`

```rust
my_transport.upgrade()
.authenticate_with_version(my_authentication, Version::V1Lazy)
.multiplex_with_version(my_multiplexer, Version::V1Lazy)
```

- `Builder::multiplex_ext` is removed in favor of the new simultaneous open workflow. Please reach
out in case you depend on `Builder::multiplex_ext`.

See [PR 2066].

[PR 2090]: https://github.com/libp2p/rust-libp2p/pull/2090
[simultaneous open extension]: https://github.com/libp2p/specs/blob/master/connections/simopen.md
[PR 2066]: https://github.com/libp2p/rust-libp2p/pull/2066

# 0.28.3 [2021-04-26]

Expand Down
34 changes: 22 additions & 12 deletions core/src/connection/listeners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,6 @@ where

#[cfg(test)]
mod tests {
use futures::{future::BoxFuture, stream::BoxStream};

use super::*;
use crate::transport;

Expand Down Expand Up @@ -463,12 +461,18 @@ mod tests {
impl transport::Transport for DummyTrans {
type Output = ();
type Error = std::io::Error;
type Listener = BoxStream<
'static,
Result<ListenerEvent<Self::ListenerUpgrade, std::io::Error>, std::io::Error>,
type Listener = Pin<
Box<
dyn Stream<
Item = Result<
ListenerEvent<Self::ListenerUpgrade, std::io::Error>,
std::io::Error,
>,
>,
>,
>;
type ListenerUpgrade = BoxFuture<'static, Result<Self::Output, Self::Error>>;
type Dial = BoxFuture<'static, Result<Self::Output, Self::Error>>;
type ListenerUpgrade = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>>>>;
type Dial = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>>>>;

fn listen_on(
self,
Expand Down Expand Up @@ -519,12 +523,18 @@ mod tests {
impl transport::Transport for DummyTrans {
type Output = ();
type Error = std::io::Error;
type Listener = BoxStream<
'static,
Result<ListenerEvent<Self::ListenerUpgrade, std::io::Error>, std::io::Error>,
type Listener = Pin<
Box<
dyn Stream<
Item = Result<
ListenerEvent<Self::ListenerUpgrade, std::io::Error>,
std::io::Error,
>,
>,
>,
>;
type ListenerUpgrade = BoxFuture<'static, Result<Self::Output, Self::Error>>;
type Dial = BoxFuture<'static, Result<Self::Output, Self::Error>>;
type ListenerUpgrade = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>>>>;
type Dial = Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>>>>;

fn listen_on(
self,
Expand Down
5 changes: 2 additions & 3 deletions core/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pub use self::boxed::Boxed;
pub use self::choice::OrTransport;
pub use self::memory::MemoryTransport;
pub use self::optional::OptionalTransport;
pub use self::upgrade::Upgrade;

/// A transport provides connection-oriented communication between two peers
/// through ordered streams of data (i.e. connections).
Expand Down Expand Up @@ -198,12 +197,12 @@ pub trait Transport {

/// Begins a series of protocol upgrades via an
/// [`upgrade::Builder`](upgrade::Builder).
fn upgrade(self, version: upgrade::Version) -> upgrade::Builder<Self>
fn upgrade(self) -> upgrade::Builder<Self>
where
Self: Sized,
Self::Error: 'static,
{
upgrade::Builder::new(self, version)
upgrade::Builder::new(self)
}
}

Expand Down
Loading