A modular BitTorrent client implementation in Go, following the BEP 3 specification.

- Magnet Link Support: Full implementation of BEP 9 (Metadata Exchange) and BEP 5 (DHT) for magnet downloads.
- Modern Web UI: A futuristic, interactive dashboard built with React, Vite, and Three.js.
- Real-Time Stats: Live monitoring of download/upload speeds, active peers, and progress.
- File Upload: Support for uploading
.torrentfiles directly via the UI. - Bencode Parsing: Robust encoder/decoder for bencoded data.
- Torrent Parsing: Support for single and multi-file torrents.
- Tracker Communication: HTTP and UDP tracker support.
- Peer Wire Protocol: Full implementation (Handshake, Bitfield, Choke/Unchoke, Interested, Request, Piece).
- Go 1.25 or later
- Node.js & npm (for Web UI)
-
Clone the repository:
git clone https://github.com/valhalla/go-torrent.git cd go-torrent -
Build the backend:
go mod tidy go build -o torrent-client ./cmd/client
-
Setup the Frontend:
cd web npm install npm run build cd ..
Start the server:
./torrent-client serve --port 8080Then open http://localhost:5173 (if running dev server) or serve the static files (if configured).
Note: The current dev setup requires running npm run dev in the web/ directory parallel to the backend.
Run the client by providing the path to a .torrent file:
./torrent-client <path_to_torrent_file> <output_directory>Or for magnet links:
./torrent-client magnet "<magnet_link>" <output_directory>This project has evolved into a fully functional BitTorrent client with:
- Standard HTTP & UDP Trackers
- DHT (Distributed Hash Table) for peer discovery
- Magnet Link Support (Metadata Exchange)
- Modern Web Dashboard
- File Uploads