Previously, the `DummyConnectionHandler` offered a "keep alive" functionality, i.e. it allowed users to set the value of what is returned from `ConnectionHandler::keep_alive`. This handler is primarily used in tests or `NetworkBehaviour`s that don't open any connections (like mDNS). In all of these cases, it is statically known whether we want to keep connections alive. As such, this functionality is better represented by a static `KeepAliveConnectionHandler` that always returns `KeepAlive::Yes` and a `DummyConnectionHandler` that always returns `KeepAlive::No`. To follow the naming conventions described in https://github.com/libp2p/rust-libp2p/issues/2217, we introduce a top-level `keep_alive` and `dummy` behaviour in `libp2p-swarm` that contains both the `NetworkBehaviour` and `ConnectionHandler` implementation for either case.
Examples
A set of examples showcasing how to use rust-libp2p.
Getting started
-
Small
ping
clone, sending a ping to a peer, expecting a pong as a response. See tutorial for a step-by-step guide building the example.
Individual libp2p features
-
A basic chat application demonstrating libp2p and the mDNS and floodsub protocols.
-
Same as the chat example but using the Gossipsub protocol.
-
Same as the chat example but using tokio for all asynchronous tasks and I/O.
-
-
A basic key value store demonstrating libp2p and the mDNS and Kademlia protocol.
-
Demonstrates how to use identify protocol to query peer information.
-
Demonstrates how to perform Kademlia queries on the IPFS network.
-
Implementation using the gossipsub, ping and identify protocols to implement the ipfs private swarms feature.
-
Discover peers on the same network via the MDNS protocol.
-
Tutorial on how to overcome firewalls and NATs with libp2p’s hole punching mechanism.
Integration into a larger application
-
Basic file sharing application with peers either providing or locating and getting files by name.
While obviously showcasing how to build a basic file sharing application with the Kademlia and Request-Response protocol, the actual goal of this example is to show how to integrate rust-libp2p into a larger application.