How piyushxcoder/dhaar-torrent works
Dhaar Torrent is a Rust BitTorrent client library and CLI. Its main workflow parses torrent metadata, discovers peers through HTTP trackers, coordinates inbound and outbound peer connections, requests and verifies pieces, persists resumable data, and extracts the completed torrent into its real file layout. The Download API wires these actors together and publishes live progress and transfer statistics. The graph preserves documented capabilities even where implementation excerpts were unavailable; unsampled subsystem links are omitted when their wiring cannot be established.
Main entry points: lib.rs Download API · peer_manager/mod.rs Peer manager · peer_connection/mod.rs Peer connection · piece_manager/mod.rs Piece manager
Components 20
Entry and orchestration
- CLI entry
src/main.rs - Configuration
src/config/mod.rs - Download API
src/lib.rs - Status feed
src/status.rs
Torrent metadata
- Torrent parser
src/torrent_parser/parser.rs - Torrent metadata
src/torrent_parser/metadata.rs - Bencode codec
crates/bencode-dhaar/src/lib.rs
Peer discovery
- Peer explorer
src/peer_explorer/mod.rs - Tracker manager
src/peer_explorer/tracker/tracker_manager.rs - Tracker clients
src/peer_explorer/tracker/tracker_client.rs
Peer transfer
- Peer manager
src/peer_manager/mod.rs - Peer selection
src/peer_manager/peer_selection_strategy.rs - Peer connection
src/peer_connection/mod.rs - Wire codec
src/wire_protocol/codec/mod.rs
Pieces and storage
- Piece manager
src/piece_manager/mod.rs - Resumable disk store
src/store/mod.rs
Other components
- CLI or library user
- HTTP trackers
- Remote peers
- Download filesystem
Connections 26
- CLI or library user → CLI entry: runs
- CLI or library user → Download API: creates download
- CLI entry → Configuration: loads settings
- CLI entry → Download API: starts download
- Download API → Torrent parser: parses torrent
- Torrent parser → Bencode codec: decodes
- Torrent parser → Torrent metadata: builds metadata
- Download API → Tracker manager: configures tracker source
- Download API → Peer explorer: starts actor
- Tracker manager → Tracker clients: announces
- Tracker clients → HTTP trackers: requests peers
- Tracker manager → Peer explorer: sends discovered peers
- Peer explorer → Peer manager: dispatches peers
- Download API → Peer manager: starts actor
- Peer manager → Peer selection: selects peers
- Peer manager → Peer connection: opens connections
- Peer manager → Remote peers: accepts and dials
- Peer connection → Wire codec: encodes and decodes
- Peer connection → Remote peers: exchanges blocks
- Download API → Piece manager: starts actor
- Peer connection → Piece manager: submits blocks
- Piece manager → Resumable disk store: reads and writes
- Resumable disk store → Download filesystem: persists and extracts
- Piece manager → Status feed: publishes progress
- Download API → Status feed: samples statistics
- CLI or library user → Status feed: subscribes