Skip to content

Abimael10/bit-client-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BitTorrent Client in Rust

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.

Features

  • Parses .torrent files 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

Limitations

  • Only supports .torrent files (no magnet links)
  • Only supports HTTP trackers
  • Does not support multi-file torrents
  • Only downloads (does not upload/share pieces)

Building

# 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

Usage

# 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.iso

Architecture

The 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

Dependencies

  • sha-1: For SHA-1 hashing
  • hex: For hex encoding/decoding
  • rand: For random peer ID generation
  • serde and serde_bencode: For bencoding/decoding
  • reqwest: For HTTP tracker communication
  • tokio: For async runtime
  • thiserror: For error handling
  • byteorder: For handling network byte order

Testing

Run the tests with:

cargo test

··· Built with love by Juan Abimael Santos Castillo ···

About

BitTorrent client written in Rust.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages