Skip to content

Latest commit

 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

refinedtorrent

A BitTorrent client written from scratch, implementing the peer wire protocol and HTTP tracker communication directly from the BitTorrent spec — no external torrent/bencode libraries doing the heavy lifting.

Built as a learning project to understand how BitTorrent actually works under the hood

What it does

  • Parses .torrent files
  • Announces to HTTP(S) trackers and parses the compact peer list response
  • Performs the BitTorrent handshake and peer wire protocol messaging
  • Downloads from multiple peers concurrently, with:
    • Per-piece SHA1 hash verification against the .torrent file's piece hashes
    • Automatic requeueing of a piece if a peer disconnects or sends bad data mid-download, so no peer failure stalls the download
  • Live terminal progress bar

What it does not do (I might implement these later)

This was a learning project, not a full BitTorrent client:

  • No DHT or Peer Exchange — peer discovery relies entirely on the torrent's HTTP tracker
  • No magnet link support — only .torrent files
  • No UDP tracker support — HTTP(S) trackers only
  • Single-file torrents only — multi-file torrent support is not implemented
  • Download only — no seeding/uploading

Because of this, the client works best against torrents with a healthy HTTP tracker (e.g. official Linux distro ISOs), and won't find peers for trackerless/DHT-only torrents.

Showcase

Video of downloading a sample.txt file and debian ISO and matching the ISO's SHA256 with the published checksum

torrentclientshowcase.mp4

Notes

  • Debugging networking conditions that don't show up in a toy example: rate limiting/throttling, and connectivity issues caused by CGNAT (My ISP 😡)
  • Verifying correctness — the final downloaded file's SHA256 matched the official published checksum exactly

How to run

git clone https://github.com/RefinedDev/refinedtorrent.git
cd refinedtorrent
cargo run --release -- <path/to/torrent_file>

For more information, try --help.

License

Dual-licensed under MIT or Apache-2.0

About

BitTorrent CLI

Topics

Resources

Stars

17 stars

Watchers

1 watching

Forks

Contributors

Languages