`libp2p-core` provides the `StreamMuxer` abstraction so it can provide
functionality that abstracts over this trait.
We never use the `flush_all` function as part of our abstractions.
No one else is going to use it so we can remove it from the abstraction.
Optionally only perform dial-backs on peers that are observed at a global ip-address.
This is relevant when multiple peers are in the same local network, in which case a peer could incorrectly assume themself to be public because a peer in the same local network was able to dial them. Thus servers should reject dial-back requests from clients with a non-global IP address, and at the same time clients should only pick connected peers as servers if they are global.
Behind a config flag (enabled by default) to also allow use-cases where AutoNAT is needed within a private network.
Handle in test that a `OutboundProbeEvent::Response` can be reported
before the associated inbound connection event.
In rare cases (that only really happen in a test setup where both peers
run on the same device) the server may observe a connection and report
the response back to the client, before the connection event was
reported at the client.
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>
The `HandlerWrapper` polls three components:
1. `ConnectionHandler`
2. Outbound negotiating streams
3. Inbound negotiating streams
The `ConnectionHandler` itself might itself poll already negotiated streams.
By polling the three components above in the listed order one:
- Prioritizes local work and work coming from negotiated streams over
negotiating streams.
- Prioritizes outbound negotiating streams over inbound negotiating
streams, i.e. outbound requests over inbound requests.
Replace `atomic::Atomic<u64>` by `std::sync::atomic:AtomicU64`.
The original motivation of using `atomic::Atomic<u64>` instead of
`std`'s version in #1670 was the following:
> I used the atomic crate and an Atomic<u64> because the AtomicU64 type
> isn't available on all architectures. The atomic crate automatically
> falls back to using a Mutex on platforms that don't support AtomicU64.
This argumentation is moot because the crate directly depends on
`libp2p-core` which also uses `AtomicU64`.
Have the main event loop (`Swarm::poll_next_event`) prioritize:
1. Work on `NetworkBehaviour` over work on `Pool`, thus prioritizing
local work over work coming from a remote.
2. Work on `Pool` over work on `ListenersStream`, thus prioritizing work
on existing connections over upgrading new incoming connections.
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Simplifies `PoolEvent`, no longer carrying a reference to an
`EstablishedConnection` or the `Pool`, but instead the `PeerId`,
`ConnectionId` and `ConnectedPoint` directly.
Co-authored-by: Elena Frank <elena.frank@protonmail.com>
Moves the score buckets to the metrics configuration, setting the same defaults
as what we had but also allowing the user to pass a reference to the score
thresholds to create them from that. Having them in the config also allows users
to set them directly.
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`.
* 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>
* *: Import `libp2p` with `default-features = false`
While not a win in most cases, it reduces compile time for tests of
individual crates.
* Cargo.toml: Set features for examples