Skip to content

Integrate WebTorrent support from libtorrent#1850

Draft
QuixThe2nd wants to merge 1 commit into
rakshasa:masterfrom
QuixThe2nd:codex/integrate-webtorrent-support
Draft

Integrate WebTorrent support from libtorrent#1850
QuixThe2nd wants to merge 1 commit into
rakshasa:masterfrom
QuixThe2nd:codex/integrate-webtorrent-support

Conversation

@QuixThe2nd

Copy link
Copy Markdown

Summary

This wires rtorrent up as the configuration, UI, RPC, and CI consumer of WebTorrent support implemented in rakshasa/libtorrent.

The WebRTC, WebSocket tracker, signaling, SDP/ICE, and DataChannel transport logic remains in libtorrent. rtorrent only detects support, exposes user-facing controls/status, and displays WebTorrent tracker/peer state.

Depends on rakshasa/libtorrent#796.

What Changed

  • Add build-time WebTorrent integration:

    • --enable-webtorrent / default enabled
    • --disable-webtorrent
    • configure-time probe for the required libtorrent WebTorrent API
    • HAVE_LIBUTORRENT_WEBTORRENT only when the probe succeeds
    • rtorrent does not link libdatachannel directly; it consumes libtorrent through pkg-config
  • Add RPC/config commands:

    • system.has_webtorrent
    • protocol.webtorrent
    • protocol.webtorrent.set
    • p.is_webtorrent
    • p.transport
    • t.type_str
  • Mark safe RPC commands:

    • system.has_webtorrent
    • protocol.webtorrent
    • p.is_webtorrent
    • p.transport
    • t.type_str
  • Add UI integration:

    • peer list TR column
      • WT for WebTorrent/WebRTC peers
      • -- for TCP peers
    • peer detail view shows Transport: WebRTC or TCP
    • tracker list shows WebSocket trackers as websocket
    • download info panel shows WebTorrent state:
      • enabled
      • disabled
      • not built
  • Add documentation examples:

    • #protocol.webtorrent.set = yes
    • #protocol.webtorrent.set = no
    • note that WebTorrent requires a WebTorrent-enabled rakshasa/libtorrent
    • note that ws:// and wss:// trackers are handled by libtorrent
  • Update CI workflows:

    • add matrix fields for default/WebTorrent libtorrent builds
    • add rtorrent WebTorrent build path
    • add disabled WebTorrent build coverage
  • Preserve completed-session seeding behavior:

    • restored complete torrents load resume progress and publish a full bitfield before WebTorrent peers connect

Runtime Behavior

When built with WebTorrent-capable libtorrent:

  • WebTorrent is enabled by default.
  • protocol.webtorrent.set = no disables WebTorrent runtime behavior globally.
  • protocol.webtorrent.set = yes re-enables it.
  • ws:// and wss:// trackers are accepted and handled by libtorrent.

When built without WebTorrent-capable libtorrent:

  • system.has_webtorrent returns 0
  • protocol.webtorrent returns 0
  • setting protocol.webtorrent.set = yes throws:
    • WebTorrent support is not available in this build.

Compatibility

Existing TCP peer behavior and existing tracker behavior remain unchanged for:

  • HTTP trackers
  • HTTPS trackers
  • UDP trackers
  • DHT trackers

Existing peer rate/choke/snub/ban/disconnect behavior is unchanged.

Testing

Tested locally on macOS against the matching libtorrent branch.

WebTorrent-enabled build:

  • ./configure --enable-webtorrent
  • make -j4
  • make check
    • 2/2 rtorrent tests passed

Disabled build against libtorrent built with --disable-webtorrent:

  • ./configure --disable-webtorrent
  • make -j4
  • make check
    • 2/2 rtorrent tests passed

End-to-end browser test:

  • rtorrent seeded a fresh torrent with a wss://tracker.btorrent.xyz:443 tracker
  • browser WebTorrent client loaded the .torrent
  • browser connected to rtorrent as a WebTorrent/WebRTC peer
  • browser received the piece and completed the file

Also verified:

  • git diff --check clean
  • rtorrent + ruTorrent run successfully against the WebTorrent-enabled build

@QuixThe2nd QuixThe2nd mentioned this pull request Jun 26, 2026
@kingomarwashere

Copy link
Copy Markdown

LFG!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants