23 Commits

Author SHA1 Message Date
Max Inden
2910c985e8
fix(examples): call Swarm::add_external_address in dcutr and relay
> Observed addresses (aka. external address candidates) of the local node, reported by a remote node
> via `libp2p-identify`, are no longer automatically considered confirmed external addresses, in
> other words they are no longer trusted by default. Instead users need to confirm the reported
> observed address either manually, or by using `libp2p-autonat`. In trusted environments users can
> simply extract observed addresses from a `libp2p-identify::Event::Received { info:
> libp2p_identify::Info { observed_addr }}` and confirm them via `Swarm::add_external_address`.

Follow-up to https://github.com/libp2p/rust-libp2p/pull/3954.

Pull-Request: #4052.
2023-06-09 03:26:24 +00:00
Thomas Eizinger
ed14630672
feat: leverage type-safe /p2p in multiaddr
This updates `multiaddr` to version `0.19`.

Depends-On: #3656.
Depends-On: https://github.com/multiformats/rust-multiaddr/pull/83.
Resolves: #4039.

Pull-Request: #4037.
2023-06-08 01:38:18 +00:00
dependabot[bot]
c723df461f
deps: bump clap from 4.3.0 to 4.3.1
Pull-Request: #4027.
2023-06-05 10:59:28 +00:00
Thomas Coratger
75edcfcdb0
docs(examples): add a README to each example
Resolves #3853.

Pull-Request: #3974.
2023-06-01 07:40:22 +00:00
Max Inden
fc386a51a7
fix: remove obsolete event_process = false
The `libp2p-swarm-derive` `event_process` option was removed in https://github.com/libp2p/rust-libp2p/pull/2840.

Pull-Request: #3984.
2023-05-25 05:44:54 +00:00
dependabot[bot]
d090b58881
deps: bump clap from 4.2.7 to 4.3.0
Pull-Request: #3970.
2023-05-22 18:48:38 +00:00
Max Inden
cc5b346a7c
feat(swarm): expose ConnectionId and add conn duration metric
- Exposes the `ConnectionId` in the various `SwarmEvent` variants.
- Tracks connection duration in `libp2p-metrics::swarm`.

Pull-Request: #3927.
2023-05-17 05:19:53 +00:00
Thomas Coratger
6e36e8aa35
feat(swarm): rename associated types for message passing
Previously, the associated types on `NetworkBehaviour` and `ConnectionHandler` carried generic names like `InEvent` and `OutEvent`. These names are _correct_ in that `OutEvent`s are passed out and `InEvent`s are passed in but they don't help users understand how these types are used.

In theory, a `ConnectionHandler` could be used separately from `NetworkBehaviour`s but that is highly unlikely. Thus, we rename these associated types to indicate, where the message is going to be sent to:

- `NetworkBehaviour::OutEvent` is renamed to `ToSwarm`: It describes the message(s) a `NetworkBehaviour` can emit to the `Swarm`. The user is going to receive those in `SwarmEvent::Behaviour`.
- `ConnectionHandler::InEvent` is renamed to `FromBehaviour`: It describes the message(s) a `ConnectionHandler` can receive from its behaviour via `ConnectionHandler::on_swarm_event`. The `NetworkBehaviour` can send it via the `ToSwarm::NotifyHandler` command.
- `ConnectionHandler::OutEvent` is renamed to `ToBehaviour`: It describes the message(s) a `ConnectionHandler` can send back to the behaviour via the now also renamed `ConnectionHandlerEvent::NotifyBehaviour` (previously `ConnectionHandlerEvent::Custom`)

Resolves: #2854.

Pull-Request: #3848.
2023-05-14 10:58:08 +00:00
dependabot[bot]
8acbabdaf6
deps: bump clap from 4.2.6 to 4.2.7
Pull-Request: #3870.
2023-05-02 19:57:44 +00:00
dependabot[bot]
6a22bd3df0
deps: bump clap from 4.2.5 to 4.2.6
Pull-Request: #3869.
2023-05-02 19:38:16 +00:00
Thomas Eizinger
b1cdf8d4bb
feat(yamux): rename symbols to follow module-based naming convention
Implements our naming convention for the `libp2p-yamux` crate.

Related: #2217.

Pull-Request: #3852.
2023-05-01 02:25:52 +00:00
dependabot[bot]
cfdf5c3345
deps: bump clap from 4.2.4 to 4.2.5
Pull-Request: #3849.
2023-04-28 14:21:17 +00:00
Thomas Eizinger
2f5270ba76
feat(noise): deprecate all handshake patterns apart from XX
In the libp2p specs, the only handshake pattern that is specified is the XX handshake. Support for other handshake patterns can be added through external modules. While we are at it, we rename the remaining types to following the laid out naming convention.

The tests for handshakes other than XX are removed. The handshakes still work as we don't touch them in this patch.

Related #2217.

Pull-Request: #3768.
2023-04-28 13:50:31 +00:00
dependabot[bot]
a836bb471f
deps: bump clap from 4.2.1 to 4.2.4
Pull-Request: #3808.
2023-04-28 11:19:43 +00:00
Thomas Eizinger
28da3d4180
fix(ci): ensure all examples compile with the specified feature-set
Due to cargo's feature unification, a full build of our workspace doesn't actually check whether the examples compile as standalone projects.

We add a new CI check that iterates through all crates in the `examples/` directory and runs a plain `cargo check` on them. Any failure is bubbled up via `set -e`, thus failing CI in case one of the `cargo check` commands fails.

To fix the current failures, we construct a simple TCP transport everywhere where we were previously using `development_transport`. That is because `development_transport` requires `mplex` which is now deprecated.

Related #3657.
Related #3809.

Pull-Request: #3811.
2023-04-21 09:58:08 +00:00
Thomas Coratger
44d4b1133d
feat(libp2p): deprecate mplex
`mplex` module (no flow control and no streams limit) is deprecated to encourage `yamux` usage.

Resolves #3677.

Pull-Request: #3689.
2023-04-04 09:49:59 +00:00
dependabot[bot]
389e519e7f
deps: bump clap from 4.1.11 to 4.2.1
Pull-Request: #3731.
2023-04-03 19:02:18 +00:00
dependabot[bot]
0ff0ef7a35
deps: bump futures from 0.3.27 to 0.3.28
Pull-Request: #3725.
2023-04-03 14:43:42 +00:00
dependabot[bot]
15ef8c0325
deps: bump clap from 4.1.8 to 4.1.11
Pull-Request: #3638.
2023-03-20 14:06:08 +00:00
dependabot[bot]
9d0ec7e074
deps: bump futures from 0.3.26 to 0.3.27
Pull-Request: #3597.
2023-03-13 11:35:04 +00:00
Thomas Eizinger
2a14df25eb
feat: introduce libp2p-identity crate
This patch combines the `libp2p_core::identity` and `libp2p_core::peer_id` modules into a new crate: `libp2p-identity`.

Resolves https://github.com/libp2p/rust-libp2p/issues/3349.

Pull-Request: #3350.
2023-03-12 15:46:58 +01:00
Thomas Eizinger
d53cfed236
chore: move libp2p crate to a dedicated directory
Currently, our top-level `Cargo.toml` manifest represents a crate AND a workspace. This causes surprising behaviour (e.g. #2949) where we need to explicitly pass `--workpace` to every command to run it on the entire workspace and not just the meta crate.

My moving the meta crate into its own directory, the root manifest file is a virtual manifest only and thus, every `cargo` command will automatically default to running on the entire workspace.

On top of this, I personally find it easier to understand if workspace and crate manifests are not mixed.

Pull-Request: #3536.
2023-03-08 13:20:39 +00:00
Oleg Kubrakov
b63e05dad6
refactor: move examples to common location
Refactor examples into separate binary crates.

Fixes https://github.com/libp2p/rust-libp2p/issues/3111.

Pull-Request: #3509.
2023-03-08 08:17:33 +00:00