#bittorrent #dht #kademlia #networking #torrent

mainline

Simple, robust, BitTorrent's Mainline DHT implementation

18 releases (9 stable)

4.0.0 Sep 27, 2023
1.5.0 Apr 12, 2024
1.4.0 Mar 2, 2024
1.0.0 Nov 28, 2023
0.6.1 Nov 27, 2023

#284 in Network programming

Download history 4/week @ 2024-01-14 12/week @ 2024-01-21 4/week @ 2024-01-28 13/week @ 2024-02-04 6/week @ 2024-02-11 453/week @ 2024-02-18 208/week @ 2024-02-25 62/week @ 2024-03-03 34/week @ 2024-03-10 29/week @ 2024-03-17 75/week @ 2024-03-24 46/week @ 2024-03-31 146/week @ 2024-04-07 112/week @ 2024-04-14

384 downloads per month
Used in 2 crates

MIT license

175KB
4K SLoC

Mainline

Simple, robust, BitTorrent's Mainline DHT implementation.

This library is focused on being the best and simplest Rust client for Mainline, especially focused on reliable and fast time-to-first-response.

It should work as a routing / storing node as well, but if you want to run a reliable node to support the network, you might be better off running libtorrent for now.

API Docs

Get started

Check the Examples.

Features

Client

Running as a client, means you can store and query for values on the DHT, but not accept any incoming requests.

use mainline::Dht;

let dht = Dht::client(); // or Dht::default();

Supported BEPs:

Server

Running as a server is the same as a client, but you also respond to incoming requests and serve as a routing and storing node, supporting the general routing of the DHT, and contributing to the storage capacity of the DHT.

use mainline::Dht;

let dht = Dht::server(); // or Dht::builder::as_server().build();

Supported BEPs:

Acknowledgment

This implementation was possible thanks to Webtorrent's Bittorrent-dht as a reference, and Rustydht-lib that saved me a lot of time, especially at the serialization and deserialization of Bencode messages.

Dependencies

~3.5–5MB
~104K SLoC