Skip to content

nayiswftw/Rusbit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Rusbit πŸ¦€

A blazingly fast BitTorrent client written in Rust

Rust Cargo License: MIT Version

Download torrents and magnet links from the command line with ease

πŸš€ Quick Start β€’ πŸ“– Documentation β€’ 🀝 Contributing

✨ Features

πŸ” Decode & Parse

Parse and decode bencoded values and torrent metadata

  • βœ… Decode bencoded values
  • βœ… Torrent info extraction

🌐 Network Operations

Peer discovery and protocol handshakes

  • βœ… Peer discovery
  • βœ… BitTorrent handshakes

πŸ“₯ Downloading

Flexible download options for pieces and complete files

  • βœ… Individual piece downloads
  • βœ… Full torrent downloads
  • βœ… Concurrent peer downloads

🧲 Magnet Links

Complete magnet link support

  • βœ… Magnet link parsing
  • βœ… Magnet-based downloads
  • βœ… Magnet handshakes

⚑ Performance

High-performance asynchronous operations

  • βœ… Async downloads with Tokio
  • βœ… Multi-peer concurrent transfers
  • βœ… Efficient piece management

πŸ“‹ Table of Contents

πŸš€ Installation

Prerequisites

  • Rust (latest stable version recommended)

Build from Source

# Clone the repository
git clone https://github.com/nayiswftw/Rusbit.git
cd rusbit-cli

# Build in release mode for optimal performance
cargo build --release

The binary will be available at target/release/rusbit-cli.

Verify Installation

./target/release/rusbit-cli --version

⚑ Quick Start

Download a torrent file:

rusbit-cli download -o myfile.txt sample.torrent

Download via magnet link:

rusbit-cli magnet-download -o myfile.txt "magnet:?xt=urn:btih:c5fb9894bdaba464811b088d806bdd611ba490af&dn=magnet3.gif&tr=http%3A%2F%2Fbittorrent-test-tracker.codecrafters.io%2Fannounce"

Get torrent information:

rusbit-cli info sample.torrent

πŸ“– Usage

Global Options

  • -v, --verbose: Enable verbose logging
  • -p, --progress: Show progress bar during downloads
  • -h, --help: Display help information
  • -V, --version: Display version information

Commands

Decode Bencoded Value

rusbit-cli decode "<bencoded-string>"

Get Torrent Information

rusbit-cli info <torrent-file>

List Peers

rusbit-cli peers <torrent-file>

Perform Handshake

rusbit-cli handshake <torrent-file> <peer-address>

Download Single Piece

rusbit-cli download-piece -o <output-file> <torrent-file> <piece-index>

Download Complete File

rusbit-cli download -o <output-file> <torrent-file>

Magnet Link Commands

πŸ”— Magnet Link Operations

Parse Magnet Link

rusbit-cli magnet-parse "<magnet-link>"

Magnet Handshake

rusbit-cli magnet-handshake "<magnet-link>"

Get Magnet Info

rusbit-cli magnet-info "<magnet-link>"

Download Piece via Magnet

rusbit-cli magnet-download-piece -o <output-file> "<magnet-link>" <piece-index>

Download Complete File via Magnet

rusbit-cli magnet-download -o <output-file> "<magnet-link>"

πŸ’‘ Examples

Basic Torrent Download

rusbit-cli download -o ubuntu.iso ubuntu.torrent

Magnet Link Download with Verbose Output

rusbit-cli --verbose magnet-download -o movie.mp4 "magnet:?xt=urn:btih:...&dn=Movie&tr=..."

Inspect Torrent Metadata

rusbit-cli info sample.torrent

Output:

Tracker URL: http://bittorrent-test-tracker.codecrafters.io/announce
File Name: sample.txt
File Length: 92063 bytes
Piece Length: 32768 bytes
Info Hash: 2d88a4bf3...
Piece Hashes:
  Piece 0: 1c8f1...
  Piece 1: 8e4f5...
  Piece 2: 3b2a7...
Total Pieces: 3

Download with Progress Bar

rusbit-cli --progress download -o ubuntu.iso ubuntu.torrent

Magnet Link Download with Progress Bar

rusbit-cli --progress magnet-download -o movie.mp4 "magnet:?xt=urn:btih:...&dn=Movie&tr=..."

βš™οΈ Configuration

On first run, Rusbit creates a rusbit.toml configuration file with default settings. You can modify this file to customize:

  • Peer ID prefix: Customize your client identification
  • Listen port: Port for incoming peer connections
  • Maximum connections: Limit concurrent peer connections
  • Piece timeout: Timeout for piece downloads (seconds)
  • Request timeout: Timeout for peer requests (seconds)
  • Maximum retries: Number of retry attempts for failed operations
  • Download directory: Default output directory

Example rusbit.toml:

πŸ“„ Example Configuration
peer_id_prefix = "-RB0001-"
listen_port = 6881
max_connections = 50
piece_timeout = 30
request_timeout = 10
max_retries = 3
download_directory = "."

πŸ”§ Troubleshooting

Common Issues

❌ Connection timeouts - Check your internet connection - Try different torrent files or magnet links - Adjust timeout settings in `rusbit.toml`
🐌 Low download speeds - Ensure multiple peers are available - Check firewall settings - Try running with verbose logging: `rusbit-cli --verbose ...` - Use the progress bar to monitor download status: `rusbit-cli --progress ...`
πŸ”¨ Build failures - Ensure you have the latest Rust stable version - Update dependencies: `cargo update` - Clean and rebuild: `cargo clean && cargo build`

Getting Help

  • Open an issue on GitHub
  • Check existing issues for similar problems
  • Provide verbose logs when reporting bugs

🀝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes and add tests
  4. Run tests: cargo test
  5. Commit your changes: git commit -m 'Add amazing feature'
  6. Push to the branch: git push origin feature/amazing-feature
  7. Open a Pull Request

Development Setup

# Clone and build
git clone https://github.com/nayiswftw/Rusbit.git
cd rusbit-cli
cargo build

# Run tests
cargo test

# Run with sample data
cargo run -- info sample.torrent

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❀️ in Rust

⭐ Star us on GitHub β€’ πŸ› Report Issues

About

A command-line BitTorrent client written in Rust.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors