15 Commits

Author SHA1 Message Date
Hannes
d5ea93dd71
feat(swarm): Make executor for connection tasks explicit (#3097)
Previously, the executor for connection tasks silently defaulted to a `futures::executor::ThreadPool`. This causes issues such as https://github.com/libp2p/rust-libp2p/issues/2230.

With this patch, we force the user to choose, which executor they want to run the connection tasks on which results in overall simpler API with less footguns.

Closes #3068.
2022-11-15 14:26:03 +00:00
Thomas Eizinger
afb777e937
swarm-derive: Add prelude configuration option to NetworkBehaviour macro (#3055)
Currently, our `NetworkBehaviour` derive macro depends on the `libp2p` crate to be in scope. This prevents standalone usage which forces us to depend on `libp2p` in all our tests where we want to derive a `NetworkBehaviour`.

This PR introduces a `prelude` option that - by default - points to `libp2p::swarm::derive_prelude`, a new module added to `libp2p_swarm`. With this config option, users of `libp2p_swarm` can now refer to the macro without depending on `libp2p`, breaking the circular dependency in our workspace. For consistency with the ecosystem, the macro is now also re-exported by `libp2p_swarm` instead of `libp2p` at the same position as the trait that it implements.

Lastly, we introduce an off-by-default `macros` feature flag that shrinks the dependency tree for users that don't need the derive macro.
2022-11-12 23:59:14 +00:00
Thomas Eizinger
4d1b165982
transports/tcp: Unify symbol naming (#2961)
Co-authored-by: Elena Frank <elena.frank@protonmail.com>
2022-10-24 15:41:08 +11:00
Qinxuan Chen
d9a2e6c1bd
build(deps): Update clap to v4 (#3015) 2022-10-14 15:51:23 +11:00
Thomas Eizinger
1b793242e6
.cargo: Run clippy on ALL the source files (#2949) 2022-10-04 18:24:38 +11:00
João Oliveira
a7a96e5502
protocols/identify: Revise symbol naming (#2927) 2022-10-04 11:17:31 +11:00
Thomas Eizinger
1da75b2b25
protocols/ping: Properly deprecate types with Ping prefix (#2937)
Co-authored-by: Elena Frank <elena.frank@protonmail.com>
Co-authored-by:  João Oliveira <hello@jxs.pt>
2022-10-01 00:19:34 +10:00
Ryan Plauche
cce296e55e
protocols/{autonat,dcutr}: Fixing filename collision in examples (#2959)
Co-authored-by: Ryan Plauche <ryan@littlebearlabs.io>
2022-09-30 13:58:35 +10: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
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
1d6b08b0b6
protocols/dcutr/examples: Wait to tell relay its public addr (#2659)
As a listening client, when requesting a reservation with a relay, the relay
responds with its public addresses. The listening client can then use the public
addresses of the relay to advertise itself as reachable under a relayed
address (`/<public-relay-addr>/p2p-circuit/p2p/<listening-client-peer-id>`).

The above operates under the assumption that the relay knows its public address.
A relay learns its public address from remote peers, via the identify protocol.
In the case where the relay just started up, the listening client might be the
very first node to connect to it.

Such scenario allows for a race condition. The listening client requests a
reservation from the relay, while the relay requests its public address from the
listening client. The former needs to contain the response from the latter.

This commit serializes the two requests, making sure, in the case of a freshly
started relay, that the listening client tells the relay its public address
before requesting a reservation from the relay.

Co-authored-by: Elena Frank <elena.frank@protonmail.com>
2022-05-20 21:59:32 +02:00
Max Inden
0e9ab1c960
protocols/dcutr/example: Wait for relay to accept reservation request (#2642)
When in listening mode, wait for the relay to accept our reservation
request. Only then can a client in dialing mode establish a relayed
connection to us via the relay.

See also
https://github.com/libp2p/rust-libp2p/issues/2621#issuecomment-1123549348
2022-05-19 20:08:32 +02:00
TotalKrill
90140a6eaf
*: Change structopt to native clap derive implementations (#2600)
Co-authored-by: Max Inden <mail@max-inden.de>
2022-04-05 21:56:44 +02:00
Max Inden
0bb8ee98d5
protocols/: Implement Direct Connection Upgrade through Relay (DCUtR) (#2438)
Enables two peers to coordinate a hole punch (direct connection upgrade)
via a relayed connection.

See https://github.com/libp2p/specs/blob/master/relay/DCUtR.md for
specification.
2022-02-08 15:56:35 +01:00