FX-Torrent is the most complete BitTorrent implementation fully written in Rust, which supports both Linux, MacOS, and Windows.
It supports most of the Bittorrent protocol specifications, such as multi-file torrents, validating existing files, resuming torrent files,
and is based on the libtorrent library for functionality and naming convention.
To use the fx-torrent library, add the following cargo dependency:
Cargo.toml
[dependencies]
fx-torrent = "0.3.0"Next, create a new FXTorrentSession which manages one or more torrents.
A Torrent can be created from a magnet link, torrent file, or passing the raw TorrentMetadata.
create a new session with torrent
use fx_torrent::torrents::{FxTorrentSession, TorrentFlags};
// The fx-torrent crate makes use of async tokio runtimes
// this requires that new sessions and torrents need to be created within an async context
#[tokio::main]
async fn main() -> Result<(), io::Error> {
let session = FxTorrentSession::builder()
.base_path("/torrent/location/directory")
.client_name("MyClient")
.build()
.unwrap();
// Create a torrent from a magnet link
let magnet_torrent = session.session.add_torrent_from_uri("magnet:?XXX", TorrentFlags::default()).await;
// Create a torrent from a torrent file
let file_torrent = session.session.add_torrent_from_uri("/tmp/example.torrent", TorrentFlags::default()).await;
Ok(())
}For more examples, see the examples.
The CLI example can be used to download torrents from a magnet link or torrent file. It uses Ratatui as the terminal UI library.
- BEP3 - The BitTorrent Protocol Specification
- BEP4 - Assigned Numbers
- BEP5 - DHT Protocol
- BEP6 - Fast Extension
- BEP9 - Extension for Peers to Send Metadata Files
- BEP10 - Extension Protocol
- BEP11 - Peer Exchange (PEX)
- BEP12 - Multitracker Metadata Extension
- BEP15 - UDP Tracker Protocol for BitTorrent
- BEP19 - WebSeed - HTTP/FTP Seeding (GetRight style)
- BEP20 - Peer ID Conventions
- BEP21 - Extension for partial seeds
- BEP29 - uTorrent transport protocol
- BEP32 - BitTorrent DHT Extensions for IPv6
- BEP33 - DHT scrape
- BEP40 - Canonical Peer Priority
- BEP42 - DHT Security extension
- BEP44 - Storing arbitrary data in the DHT
- BEP47 - Padding files and extended file attributes
- BEP48 - Tracker Protocol Extension: Scrape
- BEP51 - DHT Infohash Indexing
- BEP52 - The BitTorrent Protocol Specification v2 (WIP)
- BEP53 - Magnets
- BEP54 - The lt_donthave extension
- BEP55 - Holepunch extension (WIP)
This project is licensed under the Apache-2.0 license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.