cliTorrent is a minimal async BitTorrent client built from scratch - handling peer connections, trackers (HTTP/UDP), and piece verification - all inside a terminal.
Live demo of the client downloading a Torrent file
- ✅ Full
.torrentfile parser (bencode format) - ✅ Multi-tracker support (HTTP/HTTPS and UDP)
- ✅ Concurrent downloads from multiple peers using
asyncio - ✅ Single-file and multi-file torrent support
- ✅ SHA-1 piece verification
- ✅ Intelligent stall recovery and peer rotation
- ✅ A simple terminal based UI
- ❌ DHT support
- ❌ Rarest piece first implementation
- ❌ Uploading/seeding to other peers
- ❌ Downlolad multiple torrents at once
┌─────────────────────────────────────────────────────────────────┐
│ BitTorrent Client Flow │
└─────────────────────────────────────────────────────────────────┘
┌──────────────┐
│ User Input │
│(Torrent File)│
└──────┬───────┘
│
▼
┌─────────────────────┐
│ Parse Torrent File │
│ (bencode, torrent) │
└────────────┬────────┘
│
┌────────────┴────────────┐
│ │
▼ ▼
┌───────────────┐ ┌──────────────────┐
│ Extract Meta │ │ Calculate Info │
│ (filename, │ │ Hash (SHA-1) │
│ size, etc) │ └──────────────────┘
└───────────────┘
│
▼
┌──────────────────────┐
│ Contact Tracker │
│ (tracker.py) │
│ Get Peer List │
└─────────┬────────────┘
│
▼
┌──────────────────────┐
│ Establish P2P Conn │
│ (peers.py) │
│ Download Pieces │
└─────────┬────────────┘
│
┌───────────┼───────────┐
▼ ▼ ▼
┌────────┐ ┌────────┐ ┌──────────┐
│Piece 1 │ │Piece 2 │ │Piece N │
└─────┬──┘ └────┬───┘ └─────┬────┘
│ │ │
└────────┬┴──────────┬─┘
▼ ▼
┌──────────────────────┐
│ Verify Hash & Save │
│ (downloader.py) │
└─────────┬────────────┘
│
▼
┌──────────────────────┐
│ Update UI Status │
│ (ui.py) │
│ Progress, Speed, etc │
└──────────────────────┘
- Clone the repo
git clone https://github.com/siddiqui-ayan/cliTorrent
cd cliTorrent
- Install the required modules
pip install -r requirements.txt
- Run the bittorent client
python main.py ./examples/onepiece.torrent
I wouldn't have been able to get this far without the help of the following resources: Markus Eliasson's bittorent blog, manware's youtube video and the Unofficial bittorent spec, so thank you :)

