rqbit

repository·main·Indexed 23 days ago

https://github.com/ikatson/rqbit

A high-performance BitTorrent client written in Rust featuring a robust HTTP API, Web UI, and desktop application. It includes librqbit, a fully featured torrent downloading library, and a specialized bencode crate for serialization and deserialization of Bencode-encoded data. The project also provides rqbit-log-to-postgres for efficiently loading JSON logs into a PostgreSQL database.

Tokens
40.8K
Snippets
87
Records
261
Agent score
83%

What's inside rqbit

  1. Configure the Parent Height Chain for Virtuoso

    main

    react-virtuoso requires a parent container with an explicit height to function correctly. If the parent height is not defined, the list may not render.

    To ensure the virtualization container fills the available space, follow this CSS/Tailwind chain:

    1. Root elements (html, body): Set height: 100%.
    2. App container: Use h-screen flex flex-col.
    3. Content area: Use flex-1 min-h-0 (or grow min-h-0).
    4. Virtuoso container: Use flex-1 min-h-0.

    Critical Note: The min-h-0 class is essential for flex children. Without it, flex items have an implicit min-height: auto, which prevents them from shrinking below the size of their content, breaking the virtualization layout.

    /* Required CSS chain example */
    html, body: height: 100%
      └─ App container: h-screen flex flex-col
           └─ Content area: flex-1 min-h-0
                └─ Virtuoso container: flex-1 min-h-0
  2. Stream torrent files via HTTP

    main

    rqbit supports streaming torrent files (e.g., for video playback in VLC) with seeking support via HTTP Range headers. The server prioritizes pieces needed for the current stream position.

    Streaming URL format: http://IP:3030/torrents/<torrent_id>/stream/<file_id>

  3. Understand the Live Torrent State Architecture

    main

    The live torrent state is managed through a coordinated system of data structures that track piece and chunk progress. The architecture ensures that every piece exists in exactly one of four disjoint states:

    • COMPLETED: have[piece] = true (verified)
    • IN_FLIGHT: inflight.contains(piece) (being downloaded)
    • QUEUED: queue_pieces[piece] = true (needed, waiting)
    • NOT_NEEDED: None of the above (deprioritized)

    State coordination is handled by PieceTracker, which wraps ChunkTracker and manages inflight pieces to maintain these invariants during downloads, peer deaths, and checksum failures.

  4. Access the Web UI and Desktop App

    main

    Web UI

    Once the server is running, access the Web UI at: http://localhost:3030/web/

    Desktop App

    The desktop app is a thin wrapper around the Web UI.

    • macOS/Windows: Download from Releases.
    • Linux: Build manually using cargo tauri build.
    cargo tauri build
  5. Enable mDNS advertising

    main

    To make the Web UI accessible via http://rqbit.local:3030/web/ on your local network, enable mDNS. This requires listening on a non-loopback address (like 0.0.0.0):

    rqbit --enable-mdns --http-api-listen-addr 0.0.0.0:3030 server start ...
  6. Install rqbit

    main

    You can install rqbit using several methods depending on your environment:

    • Homebrew (macOS/Linux): brew install rqbit
    • Cargo (Rust toolchain): cargo install rqbit
    • Docker: Use the official image ikatson/rqbit from Docker Hub.
    • Pre-built binaries: Available in the Releases section.
    brew install rqbit
    # or
    cargo install rqbit
  7. Quick start: Start the rqbit server

    main

    To start the rqbit server and specify a download directory (e.g., ~/Downloads), use the server start command:

    rqbit server start ~/Downloads

    To watch a specific folder for new .torrent files, use the --watch-folder option:

    rqbit server start --watch-folder [path] /download/path
  8. Enable UPnP Media Server

    main

    To advertise managed torrents to your LAN (e.g., for smart TVs) without transcoding, start the server with the --enable-upnp-server flag:

    rqbit --enable-upnp-server server start ...
  9. Implement Virtualized Table View

    main

    For table layouts, each row should be wrapped in its own <table> element to maintain column alignment with the fixed header. This avoids complex layout issues within the virtualized container.

    Each TorrentTableRow should use table-fixed and explicit cell widths to ensure columns line up across different rows.

    // TorrentTable.tsx
    const itemContent = useCallback(
      (index: number) => {
        const torrent = filteredTorrents![index];
        return (
          <TorrentTableRow
            torrent={torrent}
            isSelected={selectedTorrentIds.has(torrent.id)}
            onRowClick={handleRowClick}
            onCheckboxChange={toggleSelection}
          />
        );
      },
      [filteredTorrents, selectedTorrentIds, handleRowClick, toggleSelection]
    );
    
    return (
      <div className="flex flex-col h-full">
        {/* Fixed header */}
        <table className="w-full table-fixed">
          <thead>...</thead>
        </table>
        {/* Virtualized body */}
        <div className="flex-1 min-h-0">
          <Virtuoso
            totalCount={filteredTorrents?.length ?? 0}
            itemContent={itemContent}
          />
        </div>
      </div>
    );
    // TorrentTableRow.tsx
    return (
      <table className="w-full table-fixed">
        <tbody >
          <tr className="h-[40px]">
            <td className="w-8 align-middle">...</td>
            <td className="w-12 align-middle">...</td>
            {/* ... more cells with explicit widths */}
          </tr>
        </tbody>
      </table>
    );
  10. Configure Socks proxy support

    main

    Use the --socks-url flag to route traffic through a SOCKS proxy:

    rqbit --socks-url socks5://[username:password]@host:port ...