Docs.rs
  • mainline-4.2.0
    • mainline 4.2.0
    • Docs.rs crate page
    • MIT
    • Links
    • Homepage
    • Repository
    • crates.io
    • Source
    • Owners
    • Nuhvi
    • Dependencies
      • bytes ^1.9.0 normal
      • crc ^3.2.1 normal
      • document-features ^0.2.10 normal
      • ed25519-dalek ^2.1.1 normal
      • flume ^0.11.1 normal
      • lru ^0.12.5 normal
      • rand ^0.8.5 normal
      • serde ^1.0.215 normal
      • serde_bencode ^0.2.4 normal
      • serde_bytes ^0.11.15 normal
      • sha1_smol ^1.0.1 normal
      • thiserror ^2.0.3 normal
      • tracing ^0.1 normal
      • clap ^4.5.21 dev
      • ctrlc ^3.4.5 dev
      • dashmap ^6.1 dev
      • futures ^0.3.31 dev
      • histo ^1.0.0 dev
      • rayon ^1.10 dev
      • tracing-subscriber ^0.3 dev
    • Versions
    • 33.33% of the crate is documented
  • Go to latest version
  • Platform
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate mainline

mainline4.2.0

  • All Items

Sections

  • Mainline
    • Getting started
    • Features
    • Acknowledgment
    • Feature flags

Crate Items

  • Re-exports
  • Modules
  • Structs

Crates

  • mainline

Crate mainline

Source
Expand description

§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, 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.

API Docs

§Getting 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:

  • BEP0005 DHT Protocol
  • BEP0042 DHT Security extension
  • BEP0043 Read-only DHT Nodes
  • BEP0044 Storing arbitrary data in the DHT

This implementation also includes measures against Vertical Sybil Attacks.

§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::server().build();` for more control.

Supported BEPs:

  • BEP0005 DHT Protocol
  • BEP0042 DHT Security extension
  • BEP0043 Read-only DHT Nodes
  • BEP0044 Storing arbitrary data in the DHT
§Rate limiting

The default server implementation has no rate-limiting, you can run your own custom server 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 as a reference, and Rustydht-lib that saved me a lot of time, especially at the serialization and deserialization of Bencode messages.

§Feature flags

  • async — Enable Dht::as_async() to use async_dht::AsyncDht

Re-exports§

  • pub use rpc::ClosestNodes;

Modules§

  • async_dht
    AsyncDht node.
  • errors
    Exported errors
  • rpc
    K-RPC implementatioStoreQueryMetdatan
  • server
    Modules needed only for nodes running in server mode (not read-only).

Structs§

  • Bytes
    A cheaply cloneable and sliceable chunk of contiguous memory.
  • Dht
    Mainline Dht node.
  • Id
    Kademlia node Id or a lookup target
  • MutableItem
    Bep_0044’s Mutable item.
  • Node
    Node entry in Kademlia routing table
  • Settings
    Dht settings
  • SigningKey
    ed25519 signing key which can be used to produce signatures.
  • Testnet
    Create a testnet of Dht nodes to run tests against instead of the real mainline network.

Results

Settings
Help
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.