308 Commits

Author SHA1 Message Date
Hannes
ece25973d5
transport/pnet: Update salsa20 to 0.10 (#2989) 2022-10-08 17:13:00 +11:00
Hannes
4a4019da50
transport/dns: Update async-std-resolver and trust-dns-resolver (#2988)
* build(deps): Update async-std-resolver requirement from 0.21 to 0.22

Updates the requirements on [async-std-resolver](https://github.com/bluejekyll/trust-dns) to permit the latest version.
- [Release notes](https://github.com/bluejekyll/trust-dns/releases)
- [Changelog](https://github.com/bluejekyll/trust-dns/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bluejekyll/trust-dns/compare/v0.21.0...v0.22.0)

---
updated-dependencies:
- dependency-name: async-std-resolver
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bumped versions of async-std-resolver and trust-dns-resolver

* Updated changelog

* Update transports/pnet/CHANGELOG.md

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-10-05 20:49:00 +01:00
Elena Frank
4577c5a81d
transports/tcp: Only translate tcp addresses (#2970)
Return `None` in in `<GenTcpTransport as Transport>::address_translation` if the
address is not a tcp address. Relevant if in case of something like
`OrTransport<TcpTransport, QuicTransport>`, where tcp would currently perform
the address translation for quic addresses.
2022-10-04 18:42:05 +01:00
Thomas Eizinger
1b793242e6
.cargo: Run clippy on ALL the source files (#2949) 2022-10-04 18:24:38 +11:00
Thomas Eizinger
f6bb846c36
*: Remove default features from all crates (#2918)
Remove default features. You need to enable required features
explicitly now. As a quick workaround, you may want to use the
new `full` feature which activates all features.
2022-09-29 16:32:22 +01:00
Max Inden
749ff00a79
transports/noise: Have NoiseAuthenticated::xx use X25519Spec (#2954)
We support two versions of the Noise XX handshake with X25519, but only one of
them is compliant with the specification and thus compliant with other
implementations. We should always default to the spec compliant handshake.

Fixes bug introduced in https://github.com/libp2p/rust-libp2p/pull/2887/
2022-09-29 13:16:22 +01:00
Roman
e530118fb0
build(deps): Bump rand to 0.8 and quickcheck to 1 (#2857)
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-09-22 18:48:32 +10:00
Thomas Eizinger
ed1b89902a
protocols/noise: Add NoiseConfig::with_prologue (#2903) 2022-09-21 13:46:35 +02:00
Thomas Eizinger
45faefa36c
*: Unfiy how we depend on crates across the workspace (#2886) 2022-09-19 17:32:02 +10:00
Thomas Eizinger
2c739e9bdb
protocols/noise: Introduce NoiseAuthenticated::xx constructor with X25519 DH key exchange (#2887)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-09-16 11:41:35 +10:00
Elena Frank
457fb51ee0
transports/tcp: Simplify IfWatcher integration (#2813)
With if-watch `2.0.0` `IfWatcher::new` is not async anymore, hence the
`IfWatch` wrapping logic is obsolete.

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2022-09-10 12:40:09 +02:00
Max Inden
83c67954e9
*: Prepare v0.48.0 (#2869) 2022-09-07 09:44:51 +02:00
Alexander Shishenko
8644c65a22
core/: Introduce rsa feature flag to avoid ring dependency (#2860)
- Introduce `rsa` feature flag to `libp2p-core`.
- Expose `rsa` feature in `libp2p`.
- Add `rsa` feature to `libp2p` `default`.
2022-09-07 08:16:22 +02:00
Divma
36a2773861
*: Update changelogs for prost dep update (#2851) 2022-08-30 10:03:54 +02:00
pinkforest(she/her)
e01f77bc49
transports/noise: Migrate away from deprecated sodiumoxide for tests (#2817) 2022-08-30 09:20:41 +02:00
Max Inden
4253080a43
*: Prepare v0.47.0 (#2830) 2022-08-22 05:14:04 +02:00
dependabot[bot]
6a9fa3d930
build(deps): Update prost requirement from 0.10 to 0.11 (#2788)
* build(deps): Update prost-build requirement from 0.10 to 0.11

Updates the requirements on [prost-build](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: prost-build
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): Update prost requirement from 0.10 to 0.11

Updates the requirements on [prost](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: prost
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-16 08:49:09 +02:00
Elena Frank
06aaea67f3
*: Fix clippy::derive-partial-eq-without-eq (#2818) 2022-08-14 04:03:04 +02:00
Elena Frank
74f01e47c9
transports/tcp: fix clippy::from-over-into (#2774) 2022-07-25 17:33:31 +02:00
tgmichel
c8066df232
*: Update to if-watch 1.1.1 (#2754) 2022-07-19 09:14:00 +02:00
Max Inden
66c2319230
transports/tcp: Bump to v0.35.0 (#2760)
Follow up on https://github.com/libp2p/rust-libp2p/pull/2724/. Given that
libp2p-core is bumped to v0.35.0, libp2p-tcp needs to be bumped as well.
2022-07-19 08:57:50 +02:00
Thomas Eizinger
1a553db596
core/muxing: Flatten StreamMuxer interface to poll_{inbound,outbound,address_change,close} (#2724)
Instead of having a mix of `poll_event`, `poll_outbound` and `poll_close`, we
flatten the entire interface of `StreamMuxer` into 4 individual functions:

- `poll_inbound`
- `poll_outbound`
- `poll_address_change`
- `poll_close`

This design is closer to the design of other async traits like `AsyncRead` and
`AsyncWrite`. It also allows us to delete the `StreamMuxerEvent`.
2022-07-18 05:20:11 +02:00
Max Inden
7df6bae520
*: Prepare v0.46.0 (#2730) 2022-07-05 13:09:58 +02:00
Elena Frank
62622a1bad
core/src/transport: Poll Transport directly, remove Transport::Listener (#2652)
Remove the concept of individual `Transport::Listener` streams from `Transport`.
Instead the `Transport` is polled directly via `Transport::poll`. The
`Transport` is now responsible for driving its listeners.
2022-07-04 04:16:57 +02:00
Max Inden
71909522cf
transports/tcp/: Call take_error on tokio TcpStream (#2725)
See e04e95a for the rational.

With tokio `v1.19.0` released, `TcStream` exposes `take_error`.

This commit applies the same fix from e04e95a to the tokio TCP provider.
2022-06-27 09:36:33 +02:00
Thomas Eizinger
eb490c08e9
core/muxing: Force StreamMuxer::Substream to implement Async{Read,Write} (#2707)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-06-23 21:52:11 +10:00
Max Inden
118046c9e0
transports/uds: Bump version due to libp2p-core upgrade (#2720)
`libp2p` 0.45.1 depends (amongst others) on `libp2p-uds` v0.32.0 and on
`libp2p-core` v0.33.0 `libp2p-uds` v0.32.0, however, depends on `libp2p-core`
v0.32.0.

This commit changes the version mismatch for the upcoming `libp2p release.
2022-06-23 08:48:05 +02:00
Thomas Eizinger
0bce7f7fff
*: Remove warnings when compiling without default features (#2692)
* Remove unused import in rendezvous tests

* Expand uds-transport conditionals to include features

In case neither the tokio nor the async-std feature is defined,
this file needs to be empty to avoid unused code warnings.

Co-authored-by: Max Inden <mail@max-inden.de>
2022-06-08 13:05:11 +02:00
Max Inden
6e1e314872
*: Prepare v0.45.0 (#2662) 2022-05-31 13:12:53 +02:00
Max Inden
6078fc619f
transports/{tcp,dns,websocket}: Remove Clone imp for *Config (#2682)
This commit removes the `Clone` implementation on `GenTcpConfig` and consequently the `Clone`
implementations on `GenDnsConfig` and `WsConfig`.

When port-reuse is enabled, `GenTcpConfig` tracks the addresses it is listening in a `HashSet`. This
`HashSet` is shared with the `TcpListenStream`s via an `Arc<Mutex<_>>`. Given that `Clone` is
`derive`d on `GenTcpConfig`, cloning a `GenTcpConfig`, results in both instances sharing the same
set of listen addresses. This is not intuitive.

This behavior is for example error prone in the scenario where one wants to speak both plain DNS/TCP and
Websockets. Say a user creates the transport in the following way:

``` Rust
let transport = {
    let tcp = tcp::TcpConfig::new().nodelay(true).port_reuse(true);
    let dns_tcp = dns::DnsConfig::system(tcp).await?;
    let ws_dns_tcp = websocket::WsConfig::new(dns_tcp.clone());
    dns_tcp.or_transport(ws_dns_tcp)
};
```

Both `dns_tcp` and `ws_dns_tcp` share the set of listen addresses, given the `dns_tcp.clone()` to
create the `ws_dns_tcp`. Thus, with port-reuse, a Websocket dial might reuse a DNS/TCP listening
port instead of a Websocket listening port.

With this commit a user is forced to do the below, preventing the above error:

``` Rust
let transport = {
    let dns_tcp = dns::DnsConfig::system(tcp::TcpConfig::new().nodelay(true).port_reuse(true)).await?;
    let ws_dns_tcp = websocket::WsConfig::new(
        dns::DnsConfig::system(tcp::TcpConfig::new().nodelay(true).port_reuse(true)).await?,
    );
    dns_tcp.or_transport(ws_dns_tcp)
};
```

Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
2022-05-31 12:29:43 +02:00
pj50
280475645c
transports/tcp: Fix port reuse using Arc<RwLock> for listen_addrs (#2670)
Fix bug introduced in 2ad905f35a.

Make sure set of listen addresses is shared between GenTcpConfig and TcpListenStream.
2022-05-30 16:53:52 +02:00
Friedel Ziegelmayer
d4c1292d42
transports/dns: Remove Clone trait bound (#2658) 2022-05-19 21:00:46 +10:00
Max Inden
d21cd5fed7
misc/: Move rw-stream-sink into rust-libp2p monorepo (#2641)
* misc/rw-stream-sink: Initial commit

See
62a923cc27

* misc/rw-stream-sink: Update to Rust edition 2021

* misc/rw-stream-sink: Add changelog
2022-05-16 19:17:49 +02:00
Hubert
22fbce34d5
*: Fix clippy warnings (#2615) 2022-04-19 12:13:45 +02:00
Max Inden
2ad905f35a
{core,swarm}/: Don't require Transport: Clone and take &mut (#2529)
Previously `libp2p-swarm` required a `Transport` to be `Clone`. Methods
on `Transport`, e.g. `Transport::dial` would take ownership, requiring
e.g. a `Clone::clone` before calling `Transport::dial`.

The requirement of `Transport` to be `Clone` is no longer needed in
`libp2p-swarm`. E.g.  concurrent dialing can be done without a clone per
dial.

This commit removes the requirement of `Clone` for `Transport` in
`libp2p-swarm`. As a follow-up methods on `Transport` no longer take
ownership, but instead a mutable reference (`&mut self`).

On the one hand this simplifies `libp2p-swarm`, on the other it
simplifies implementations of `Transport`.
2022-04-06 20:23:16 +02:00
dependabot[bot]
7a1147877a
build(deps): Update prost-build requirement from 0.9 to 0.10 (#2596)
* build(deps): Update prost-build requirement from 0.9 to 0.10

Updates the requirements on [prost-build](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/commits)

---
updated-dependencies:
- dependency-name: prost-build
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* .github/workflow: Don't run integration test in container

* .github/workflow: Don't run doc step in container

* .github/workflows: Remove component docs

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-04-06 15:54:42 +02:00
dependabot[bot]
680604f3d3
build(deps): Update prost requirement from 0.9 to 0.10 (#2597)
Updates the requirements on [prost](https://github.com/tokio-rs/prost) to permit the latest version.
- [Release notes](https://github.com/tokio-rs/prost/releases)
- [Commits](https://github.com/tokio-rs/prost/commits)

---
updated-dependencies:
- dependency-name: prost
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-04-05 21:35:54 +02:00
Max Inden
f26adbcd84
*: Prepare libp2p v0.44.0 (#2604) 2022-04-04 18:27:41 +02:00
dependabot[bot]
59bba65ac0
build(deps): Update async-std-resolver requirement from 0.20 to 0.21 (#2543)
* build(deps): Update async-std-resolver requirement from 0.20 to 0.21

Updates the requirements on [async-std-resolver](https://github.com/bluejekyll/trust-dns) to permit the latest version.
- [Release notes](https://github.com/bluejekyll/trust-dns/releases)
- [Changelog](https://github.com/bluejekyll/trust-dns/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bluejekyll/trust-dns/compare/v0.20.0...v0.21.1)

---
updated-dependencies:
- dependency-name: async-std-resolver
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* build(deps): Update trust-dns-resolver requirement from 0.20 to 0.21

Updates the requirements on [trust-dns-resolver](https://github.com/bluejekyll/trust-dns) to permit the latest version.
- [Release notes](https://github.com/bluejekyll/trust-dns/releases)
- [Changelog](https://github.com/bluejekyll/trust-dns/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bluejekyll/trust-dns/compare/v0.20.0...v0.21.1)

---
updated-dependencies:
- dependency-name: trust-dns-resolver
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* transports/dns: Bump patch version

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-03-02 14:10:53 +01:00
Max Inden
99855b1d10
*: Apply clippy suggestions (#2540) 2022-02-28 10:05:17 +01:00
Max Inden
b1859464c9
*: Prepare v0.43.0 (#2531) 2022-02-22 14:05:19 +01:00
Max Inden
7fc342e6c0
{core,swarm}: Remove Network abstraction (#2492)
This commit removes the `Network` abstraction, thus managing `Listeners`
and the connection `Pool` in `Swarm` directly. This is done under the
assumption that noone uses the `Network` abstraction directly, but
instead everyone always uses it through `Swarm`. Both `Listeners` and
`Pool` are moved from `libp2p-core` into `libp2p-swarm`. Given that they
are no longer exposed via `Network`, they can be treated as an
implementation detail of `libp2p-swarm` and `Swarm`.

This change does not include any behavioural changes.

This change has the followin benefits:

- Removal of `NetworkEvent`, which was mostly an isomorphism of
  `SwarmEvent`.
- Removal of the never-directly-used `Network` abstraction.
- Removal of now obsolete verbose `Peer` (`core/src/network/peer.rs`)
  construct.
- Removal of `libp2p-core` `DialOpts`, which is a direct mapping of
  `libp2p-swarm` `DialOpts`.
- Allowing breaking changes to the connection handling and `Swarm` API
  interface without a breaking change in `libp2p-core` and thus a
  without a breaking change in `/transport` protocols.

This change enables the following potential future changes:

- Removal of `NodeHandler` and `ConnectionHandler`. Thus allowing to
  rename `ProtocolsHandler` into `ConnectionHandler`.
- Moving `NetworkBehaviour` and `ProtocolsHandler` into `libp2p-core`,
  having `libp2p-xxx` protocol crates only depend on `libp2p-core` and
  thus allowing general breaking changes to `Swarm` without breaking all
  `libp2p-xxx` crates.
2022-02-13 21:57:38 +01:00
dependabot[bot]
8d13666167
build(deps): Update snow requirement from 0.8.0 to 0.9.0 (#2472)
* build(deps): Update snow requirement from 0.8.0 to 0.9.0

Updates the requirements on [snow](https://github.com/mcginty/snow) to permit the latest version.
- [Release notes](https://github.com/mcginty/snow/releases)
- [Commits](https://github.com/mcginty/snow/compare/v0.8.0...v0.9.0)

---
updated-dependencies:
- dependency-name: snow
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-04 17:05:10 +01:00
Volker Mische
a2c93fc766
*: Update multihash and multiaddr (#2469)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-02-03 17:38:41 +01:00
Max Inden
ea180aa3a8
*: Prepare v0.42.1 (#2467) 2022-02-02 15:59:32 +01:00
Max Inden
e04e95adcd
transports/tcp/: Call take_error on TCP socket (#2458)
Within `Provider::new_stream` we wait for the socket to become writable
(`stream.writable`), before returning it as a stream. In other words, we
are waiting for the socket to connect before returning it as a new TCP
connection.  Waiting to connect before returning it as a new TCP
connection allows us to catch TCP connection establishment errors early.

While `stream.writable` drives the process of connecting, it does not
surface potential connection errors themselves. These need to be
explicitly collected via `TcpSocket::take_error`. If not explicitly
collected, they will surface on future operations on the socket.

For now this commit explicitly calls `TcpSocket::take_error` when using
`async-io` only. `tokio` introduced the method (`take_error`) in
https://github.com/tokio-rs/tokio/pull/4364 though later reverted it in
https://github.com/tokio-rs/tokio/pull/4392. Once re-reverted, the same
patch can be applied when using `libp2p-tcp` with tokio.

---

One example on how this bug surfaces today:

A `/dnsaddr/xxx` `Multiaddr` can potentially resolve to multiple IP
addresses, e.g. to the IPv4 and the IPv6 addresses of a node.
`libp2p-dns` tries dialing each of them in sequence using `libp2p-tcp`,
returning the first that `libp2p-tcp` reports as successful.

Say that the local node tries the IPv6 address first. In the scenario
where the local node's networking stack does not support IPv6, e.g. has
no IPv6 route, the connection attempt to the resolved IPv6 address of
the remote node fails. Given that `libp2p-tcp` does not call
`TcpSocket::take_error`, it would falsly report the TCP connection
attempt as successful. `libp2p-dns` would receive the "successful" TCP
connection for the IPv6 address from `libp2p-tcp` and would not attempt
to dial the IPv4 address, even though it supports IPv4, and instead
bubble up the "successful" IPv6 TCP connection. Only later, when writing
or reading from the "successful" IPv6 TCP connection, would the IPv6
error surface.

Co-authored-by: Oliver Wangler <oliver@wngr.de>
2022-02-01 19:59:34 +01:00
Max Inden
e6ccfbc4e7
*: Prepare v0.42.0 (#2440) 2022-01-27 11:29:09 +01:00
hanabi1224
fad99808ac
*: Update tokio, lru and prost (#2443) 2022-01-20 09:43:32 +01:00
Max Inden
96dbfcd1ad
core/src/transport: Add Transport::dial_as_listener (#2363)
Allows `NetworkBehaviour` implementations to dial a peer, but instruct
the dialed connection to be upgraded as if it were the listening
endpoint.

This is needed when establishing direct connections through NATs and/or
Firewalls (hole punching). When hole punching via TCP (QUIC is different
but similar) both ends dial the other at the same time resulting in a
simultaneously opened TCP connection. To disambiguate who is the dialer
and who the listener there are two options:

1. Use the Simultaneous Open Extension of Multistream Select. See
   [sim-open] specification and [sim-open-rust] Rust implementation.

2. Disambiguate the role (dialer or listener) based on the role within
   the DCUtR [dcutr] protocol. More specifically the node initiating the
   DCUtR process will act as a listener and the other as a dialer.

This commit enables (2), i.e. enables the DCUtR protocol to specify the
role used once the connection is established.

While on the positive side (2) requires one round trip less than (1), on
the negative side (2) only works for coordinated simultaneous dials.
I.e. when a simultaneous dial happens by chance, and not coordinated via
DCUtR, the connection attempt fails when only (2) is in place.

[sim-open]: https://github.com/libp2p/specs/blob/master/connections/simopen.md
[sim-open-rust]: https://github.com/libp2p/rust-libp2p/pull/2066
[dcutr]: https://github.com/libp2p/specs/blob/master/relay/DCUtR.md
2022-01-17 16:35:14 +01:00
dependabot[bot]
446fcaad3d
build(deps): Update if-watch requirement from 0.3.0 to 1.0.0 (#2431)
Updates the requirements on [if-watch](https://github.com/dvc94ch/if-watch) to permit the latest version.
- [Release notes](https://github.com/dvc94ch/if-watch/releases)
- [Commits](https://github.com/dvc94ch/if-watch/commits)

---
updated-dependencies:
- dependency-name: if-watch
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-13 17:30:31 +01:00