7 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
1b793242e6
.cargo: Run clippy on ALL the source files (#2949) 2022-10-04 18:24:38 +11:00
Elena Frank
ef2afcd41e
protocols/autonat: optionally use only global IPs (#2618)
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.
2022-05-22 22:04:05 +02:00
Elena Frank
48598fc1da
protocols/autonat: Fix flaky test (#2660)
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.
2022-05-22 21:07:55 +02:00
Elena Frank
dceb72bfe2
protocols/autonat: Fix flaky test (#2480) 2022-02-15 14:12:41 +01:00
Elena Frank
13ded7f6a8
protocols/autonat/tests: Ignore irrelevant events (#2450)
Ignore `SwarmEvent::ExpiredListenAddr` in tests.
Print swarm event on panic.

Co-authored-by: Max Inden <mail@max-inden.de>
2022-01-29 12:33:15 +01:00
Elena Frank
c61ea6ad29
protocols/: Add basic AutoNAT implementation (#2262)
This commit adds a behaviour protocol that implements the AutoNAT specification.
It enables users to detect whether they are behind a NAT. The Autonat Protocol
implements a Codec for the Request-Response protocol, and wraps it in a new
Network Behaviour with some additional functionality.

Co-authored-by: David Craven <david@craven.ch>
Co-authored-by: Max Inden <mail@max-inden.de>
2022-01-14 10:27:28 +01:00