A command line torrent client written in rust, implementing the Torrent protocol v1.0 (detailed spec) over TCP, with the following extensions:
- Multitracker Metadata Extension;
- UDP Tracker Protocol for BitTorrent;
- DHT Protocol;
- Extension Protocol;
- Peer Exchange (PEX);
- Tracker Returns Compact Peer Lists.
This is a didactic project I created purely to learn rust, it is far from feature complete or production ready, albeit working: it has been tested to saturate a 200Mb/s internet connection with low cpu usage.
Compile with:
$ cargo build --release
and run with:
$ yatorrent -t <path to torrent file>
All command line arguments (show them with the --help
), also definible via environment variables:
Usage: yatorrent [OPTIONS] --torrent-file <TORRENT_FILE>
Options:
-t, --torrent-file <TORRENT_FILE> Path to the .torrent file [env: TORRENT_FILE=]
-b, --base-path <BASE_PATH> Optional base path where files are downloaded (directory will be created if it does not exist) [env: BASE_PATH=] [default: <current directory>]
-p, --port <PORT> Optional listening port [env: PORT=] [default: 8000]
-d, --dht-port <DHT_PORT> Optional listening port for DHT protocol [env: DHT_PORT=] [default: 8001]
-l, --log-level <LOG_LEVEL> Optional log level [env: LOG_LEVEL=] [default: info] [possible values: trace, debug, info, warn, error]
-h, --help Print help
-V, --version Print version
Things yet to be implemented / todos:
- optionally limit upload/download speed
- do not over-request blocks
- better choking algorithm
- better block requests pipelining algorithm: use also peer bandwith stats, tune request queue size
- check for stalled downloads / try new peers if no current one has a piece we want
- better endgame: ask the last remaining blocks to multiple peers to finish faster
- better algorithm to exlude bad peers for new connections
- remove not interested peers if we are also not interested
- avoid re-requesting blocks after receiving choke message for awhile - requested blocks could still come
- text-based UI / ncourses
- Extension for Peers to Send Metadata Files (Magnet links)