A command line torrent client written in rust, implementing the Torrent protocol v1.0 (BEP 3, detailed spec) over TCP, with the following extensions:
- BEP 5 - DHT Protocol;
- BEP 6 - Fast Extension;
- BEP 9 - Extension for Peers to Send Metadata Files (Magnet links);
- BEP 10 - Extension Protocol;
- BEP 11 - Peer Exchange (PEX);
- BEP 12 - Multitracker Metadata Extension;
- BEP 15 - UDP Tracker Protocol for BitTorrent;
- BEP 23 - 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 1Gb/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 definable via environment variables:
Usage: yatorrent [OPTIONS]
Options:
-t, --torrent-file <TORRENT_FILE>
Path to the .torrent file (optional, either this or a magnet link must be provided) [env: TORRENT_FILE=]
-m, --magnet-uri <MAGNET_URI>
Magnet Link URI (optional, either this or a torrent file must be provided) [env: MAGNET_URI=]
-b, --base-path <BASE_PATH>
Base path where files are downloaded (directory will be created if it does not exist) [env: BASE_PATH=] [default: _current working dir_]
-p, --port <PORT>
Listening port for Torrent protocol [env: PORT=] [default: 8000]
-d, --dht-port <DHT_PORT>
Listening port for DHT protocol [env: DHT_PORT=] [default: 8001]
-l, --log-level <LOG_LEVEL>
Log level [env: LOG_LEVEL=] [default: info] [possible values: trace, debug, info, warn, error]
-s, --show-peers-stats
Show detailed stats per peer [env: SHOW_PEERS_STATS=]
-c, --max-connected-peers <MAX_CONNECTED_PEERS>
Maximum number of connected peers allowed [env: MAX_CONNECTED_PEERS=] [default: 100]
-z, --max-download-bandwidth <MAX_DOWNLOAD_BANDWIDTH>
Max allowerd total download bandwidth, with associated unit, e.g 10MiB (MiB is different from MB, the value is always bytes regardless of the case of "b", optional, no limit if not provided) [env: MAX_DOWNLOAD_BANDWIDTH=]
-u, --max-upload-bandwidth <MAX_UPLOAD_BANDWIDTH>
Max allowerd total upload bandwidth, with associated unit, e.g 10MiB (MiB is different from MB, the value is always bytes regardless of the case of "b", optional, no limit if not provided) [env: MAX_UPLOAD_BANDWIDTH=]
-e, --exit-when-complete
Exit the client when the download is complete [env: EXIT_WHEN_COMPLETE=]
-h, --help
Print help
-V, --version
Print version
Things yet to be implemented / todos:
- check for stalled downloads / try new peers if no current one has a piece we want
- better algorithm to exclude bad peers for new connections
- remove not interested peers if we are also not interested if connection count is high
- text-based UI / ncourses
- BEP 29 - uTorrent transport protocol
- BEP 55 - Holepunch extension