Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pubky/mainline
Simple, robust, BitTorrent's Mainline DHT implementation
https://github.com/pubky/mainline
Last synced: about 8 hours ago
JSON representation
Simple, robust, BitTorrent's Mainline DHT implementation
- Host: GitHub
- URL: https://github.com/pubky/mainline
- Owner: pubky
- License: mit
- Created: 2023-10-19T13:11:11.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-06-24T10:29:53.000Z (5 months ago)
- Last Synced: 2024-07-15T14:50:48.329Z (4 months ago)
- Language: Rust
- Size: 331 KB
- Stars: 26
- Watchers: 3
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mainline
Simple, robust, BitTorrent's [Mainline](https://en.wikipedia.org/wiki/Mainline_DHT) 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, and has been running in production for many months without an issue. However if you are running your separate (read: small) DHT, or otherwise facing unusual DoS attack, you should consider implementing [rate limiting](#rate-limiting).
**[API Docs](https://docs.rs/mainline/latest/mainline/)**
## Getting started
Check the [Examples](https://github.com/Nuhvi/mainline/tree/main/examples).
## Features
### Client
Running as a client, means you can store and query for values on the DHT, but not accept any incoming requests.
```rust
use mainline::Dht;let dht = Dht::client(); // or `Dht::default();`
```Supported BEPs:
- [x] [BEP0005 DHT Protocol](https://www.bittorrent.org/beps/bep_0005.html)
- [x] [BEP0042 DHT Security extension](https://www.bittorrent.org/beps/bep_0042.html)
- [x] [BEP0043 Read-only DHT Nodes](https://www.bittorrent.org/beps/bep_0043.html)
- [x] [BEP0044 Storing arbitrary data in the DHT](https://www.bittorrent.org/beps/bep_0044.html)This implementation also includes [measures against Vertical Sybil Attacks](./docs/sybil-resistance.md).
### 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.
```rust
use mainline::Dht;let dht = Dht::server(); // or `Dht::builder::server().build();` for more control.
```Supported BEPs:
- [x] [BEP0005 DHT Protocol](https://www.bittorrent.org/beps/bep_0005.html)
- [ ] [BEP0042 DHT Security extension](https://www.bittorrent.org/beps/bep_0042.html)
- [x] [BEP0043 Read-only DHT Nodes](https://www.bittorrent.org/beps/bep_0043.html)
- [x] [BEP0044 Storing arbitrary data in the DHT](https://www.bittorrent.org/beps/bep_0044.html)#### Rate limiting
The default server implementation has no rate-limiting, you can run your own [custom server](./examples/custom_server.rs) and apply your custom rate-limiting. However, that limit/block will only apply _after_ parsing incoming messages, and it won't affect handling incoming responses.
## Acknowledgment
This implementation was possible thanks to [Webtorrent's Bittorrent-dht](https://github.com/webtorrent/bittorrent-dht) as a reference, and [Rustydht-lib](https://github.com/raptorswing/rustydht-lib) that saved me a lot of time, especially at the serialization and deserialization of Bencode messages.