BitTorrent client written in Rust. It implements the core functionality of downloading files from torrent files by connecting to peers and managing the download process.
- Parses
.torrentfiles to extract metadata - Communicates with HTTP trackers to discover peers
- Implements the BitTorrent protocol handshake
- Downloads torrent pieces from multiple peers concurrently
- Verifies piece integrity using SHA-1 hashes
- Supports concurrent downloads from multiple peers
- Only supports
.torrentfiles (no magnet links) - Only supports HTTP trackers
- Does not support multi-file torrents
- Only downloads (does not upload/share pieces)
# Clone the repository
git clone https://github.com/Abimael10/bit-client-rs.git
cd bit-client-rs
# Build in release mode
cargo build --release
# The binary will be available at target/release/bit-client-rs# Download a torrent file
./target/release/bit-client-rs <torrent-file> <output-file>
# Example:
./target/release/bit-client-rs debian-13.3.0-amd64-netinst.iso.torrent debian.isoThe project is organized into several modules:
- main: Entry point that accepts torrent file and output path as arguments
- torrentfile: Handles parsing of .torrent files and manages the download process
- p2p: Core peer-to-peer download logic with worker pool implementation
- client: Manages individual peer connections and message handling
- handshake: Implements the BitTorrent handshake protocol
- message: Handles encoding/decoding of BitTorrent protocol messages
- peers: Manages peer information and parsing
- bitfield: Implements bitfield operations for tracking downloaded pieces
sha-1: For SHA-1 hashinghex: For hex encoding/decodingrand: For random peer ID generationserdeandserde_bencode: For bencoding/decodingreqwest: For HTTP tracker communicationtokio: For async runtimethiserror: For error handlingbyteorder: For handling network byte order
Run the tests with:
cargo test ··· Built with love by Juan Abimael Santos Castillo ···