Add WebTorrent tracker and WebRTC peer support#796
Conversation
|
There's too much if/defs all over, just use a class with empty functions when not defined so the code looks clean. And not seeing the reason why you're adding things to PeerConnectionBase, it should not be integrated with the code there. |
|
Thanks for the fast feedback @rakshasa I'll move the WebRTC/DataChannel path behind a generic peer transport adapter, so PeerConnectionBase only talks to a transport interface and no longer owns WebTorrent-specific state or init. I’ll also replace the scattered USE_WEBTORRENT guards with disabled-build stub/no-op classes, keeping ifdefs only at the dependency/factory boundary where libdatachannel headers and implementation details are involved. |
|
I pushed a refactor that moves WebRTC/DataChannel I/O behind a generic peer transport adapter. PeerConnectionBase now only talks to the transport interface and no longer owns WebTorrent-specific state or initialization. I also moved the disabled-build path to stubs/no-op classes where possible, leaving USE_WEBTORRENT guards around the libdatachannel-facing implementation boundary. Verified:
|
|
To put you in the right direction; your code should not touch anything in It should be a Easiest first step is to do it (a bit sub-optimally) by getting thread-net to grab your blocks of the torrent, and using the same mechanism that PeerConnectionLeech uses. (but not the same code/base-classes) |
429bc6d to
32a1203
Compare
|
Thanks, I pushed a rework in the direction you suggested. The WebRTC/DataChannel path is no longer promoted into That manager receives streams from WebSocket tracker signaling and uses download-layer state ( |
Summary
This adds optional WebTorrent support to rakshasa/libtorrent.
The implementation adds WebSocket tracker support, WebRTC DataChannel peer transport, and runtime capability/control APIs so clients such as rtorrent can detect and toggle WebTorrent support.
This is inspired by the WebTorrent support in arvidn/libtorrent, but implemented against rakshasa/libtorrent's tracker, peer, and protocol architecture rather than imported as a direct patch.
What Changed
Add autotools support for WebTorrent:
--enable-webtorrent--disable-webtorrentUSE_WEBTORRENTLIBTORRENT_HAS_WEBTORRENT=1in pkg-config cflags for consumersAdd runtime WebTorrent capability/control APIs:
torrent::runtime::webtorrent_supported()torrent::runtime::webtorrent_enabled()torrent::runtime::set_webtorrent_enabled(bool)Add WebSocket tracker support:
TRACKER_WEBSOCKETTrackerWebsocketws://andwss://tracker URL dispatchAdd WebRTC DataChannel peer support:
webtorrent::RtcSignalingwebtorrent::DataChannelStreamwebtorrent::PeerConnectorAdd peer metadata for consumers:
Add tests for WebSocket tracker parsing/building/signaling behavior.
Dependencies
When WebTorrent is enabled, this expects system-installed dependencies:
libdatachannelnlohmann_jsonNo vendored submodules are added.
Note for review:
libdatachannelis documented upstream as MPL-2.0 licensed. Since rtorrent/libtorrent are GPLv2+, this should get an explicit compatibility review by maintainers/package maintainers.Compatibility
Existing tracker behavior is unchanged for:
http://https://udp://dht://--disable-webtorrentbuilds do not require libdatachannel and continue to build/test without WebTorrent dependencies.Testing
Tested locally on macOS:
./configure --enable-webtorrentmake -j4make check./configure --disable-webtorrentmake -j4make checkEnd-to-end smoke tested with rtorrent built against this branch:
wss://tracker