HTorrent is a work-in-progress BitTorrent client written in Haskell. This was built as a learning exercise. It is not intended for use in production.
NOTE: HTorrent uses pwrite & pread under the hood to allow for parallel reads of tracker content. For this reason, only POSIX system are supported (sorry windows).
- Run
wget https://github.com/nicksanford/htorrent/raw/master/release_builds/osx/htorrent && chmod +x ./htorrent
- Run
htorrent --help
for usage instructions
- Run
wget https://github.com/nicksanford/htorrent/raw/master/release_builds/linux/htorrent && chmod +x ./htorrent
- Run
htorrent --help
for usage instructions
- Install / make sure you have git and Stack and that binaries installed via
stack install
are reachable in your path. - Run
git clone https://github.com/nicksanford/htorrent && cd htorrent
- Run
make test
, all tests should pass. If they do not, please open an issue. - Run
make install
- Run
htorrent --help
for usage instructions
I built this as an exercise to learn Haskell (which had only minimal exposure to prior to this project) and use it to build a non trivial project from scratch. I also wanted to learn about parsing, bit manipulation, socket programming, property based testing, how to build efficient concurrent / parallel programs in Haskell, and how to profile & optimize Haskell programs.
- Able to resume partial download with no duplicate work
- Accepting incoming connections from peers
- Computes & sends initial bitfield message to peers
- Hash checking to verify that each piece received is valid
- Is able to seed & leach from itself
- Never downloads the same piece twice.
- Only requests a piece from a peer if it already knows the peer has the piece.
- Parallel leaching & seeding
- Property & unit tests for parsing logic
- Reading single torrent
- Tracks if peer is choking and does not request pieces if peer is choking
- Tracks which pieces each peer has by parsing have & bitfield messages.
- Support for large single files
- Signal handling for Ctrl-C & clean shutdown
- Refactor Parser module to use attoparsec as profiling discovered explicit fold / unfold parser to be the current bottleneck
- Publishing have messages to all peers as pieces complete
- Provide visualization (presentation mode)
- Fix issue where if the tracker server doesn't exist, it does not just blow up. Report back
HTTP Call 'http call' to tracker server 'tracker server url'
- Add CI/CD
- Asking for rarest blocks first.
- Close connections with peers when you have everything and they have everything
- Convert cabal file into an hpack file
- DHT support
- Endgame - asking for the same pieces from multiple peers when number of outstanding pieces is lower than number of peers which can serve them.
- Game theory algorithm for deciding when to choke peers (currently peers are always unchoked)
- Only sending interested messages when the peer actually has pieces HTorrent needs (currently HTorrent is always interested in all peers)
- Property / integration tests for bittorrent FSM itself
- Property tests for RPC parser
- Provide ability to get debug logging
- Provide option to exit on completion
- Requesting tracker for more peers when HTorrent runs low on peers
- Resolve all compiler warnings
- Support for WebSeeds http://techie-buzz.com/how-to/what-are-web-seeds-bittorrent.html
- Support for multiple torrents
- Support for multiple trackers
- Support for specifying the download directory (currently it just downloads the file in the current directory)
- Torrents which contain more than one file
- Track download statistics to report back to tracker
- Tracking & reporting total download & upload rate
- UDP Tracker Protocol
- PRs welcome! If you would like to add/suggest a feature, please feel free to submit a PR/issue.