5 unstable releases

0.3.0 Apr 23, 2021
0.2.2 Mar 2, 2021
0.2.1 Jan 26, 2021
0.2.0 Jan 14, 2021
0.1.0 Oct 26, 2020

#84 in #libp2p

Download history 8/week @ 2023-07-26 6/week @ 2023-08-02 8/week @ 2023-08-09 32/week @ 2023-08-16 124/week @ 2023-08-23 4/week @ 2023-08-30 23/week @ 2023-09-06 7/week @ 2023-09-13 6/week @ 2023-09-20 15/week @ 2023-09-27 8/week @ 2023-10-04 9/week @ 2023-10-11 8/week @ 2023-10-18 13/week @ 2023-10-25 14/week @ 2023-11-01 16/week @ 2023-11-08

53 downloads per month
Used in 2 crates

MIT license


Alternative repository for work on libp2p

Continuous integration

This repository is an alternative implementation in Rust of the libp2p spec. Not like rust-libp2p, libp2p-rs is written with async/await syntax, and driven by async runtime. Even though, many codes are borrowed from rust-libp2p and some from go-libp2p. We are trying to keep compatible with the two implementations, but it is unfortunately not guaranteed.


How to use the library?

As mentioned above, the API is completely different from rust-libp2p. There is no such thing as 'NetworkBehaviour' in libp2p-rs at all. Instead, you should build the Swarm with the transports you like to use, then you have to create a Swarm::Control from it. The Swarm::Control is exposing all Swarm APIs which can be used to manipulate the Swarm - open/read/write/close streams and even more. This is quite similar as the BasicHost in go-libp2p. As for Kad-DHT, similarly you should get the Kad::Control for the same reason. Furthermore, you can combine the Swarm with Kad, after that you have the RoutedHost, which has a routing functionality over the BasicHost.

It is strongly recommended to check the docs and sample code in details:

Code examples:

  • Details about how to write your code can be found in examples
    • swarm_simple demonstrates how to build transport and create sub-stream for communication
    • kad_simple demonstrates how to run a Kad-DHT server. In this example, the interactive shell is integrated for debugging/observing Kad-DHT internal data structures
    • ...


NOTE: The master branch is now an active development branch (starting with v0.1.0), which means breaking changes could be made at any time.



This crate provides the type DnsConfig that allows one to resolve the /dns4/ and /dns6/ components of multiaddresses.


In order to use this crate, create a DnsConfig with one of its constructors and pass it an implementation of the Transport trait.

Whenever we want to dial an address through the DnsConfig and that address contains a /dns/, /dns4/, or /dns6/ component, a DNS resolve will be performed and the component will be replaced with /ip4/ and/or /ip6/ components.


~487K SLoC