anacrolix / torrent

Full-featured BitTorrent client package and utilities
Mozilla Public License 2.0
5.57k stars 625 forks source link

Webtorrent support #138

Closed faddat closed 4 years ago

faddat commented 7 years ago

Issuehunt badges

Does this client by any chance support webtorrent?

If no, anyone know of a go torrent solution that does?

thanks!


IssueHunt Summary #### [anacrolix anacrolix](https://issuehunt.io/u/anacrolix) has been rewarded. ### Backers (Total: $250.00) - [steelbrain steelbrain](https://issuehunt.io/u/steelbrain) ($50.00) - $200.00 have been anonymously funded. ### Submitted pull Requests - [#393 Webtorrent support](https://issuehunt.io/r/anacrolix/torrent/pull/393) --- ### Tips - Checkout the [Issuehunt explorer](https://issuehunt.io/r/anacrolix/torrent/) to discover more funded issues. - Need some help from other developers? [Add your repositories](https://issuehunt.io/r/new) on IssueHunt to raise funds. --- IssueHunt has been backed by the following sponsors. [Become a sponsor](https://issuehunt.io/membership/members)
anacrolix commented 4 years ago

@Sean-Der I've created issues the next 2 items we need. I think it may be possible to do them concurrently, so long as the addr string is agreed upon by the tracker and Dialer implementations. See those issues for more information. I've not had time myself to progress further yet due to work and other constraints.

anacrolix commented 4 years ago

I did some more investigating. This looks exceptionally difficult to integrate into the existing code. The tracker and connection management are tightly coupled. It's also probably not appropriate just to maintain state at the Torrent level for trackers, it might be necessary at the Client level in order to scale to many Torrents with the same tracker URLs specified. The potential for disconnection from the trackers is a real kicker, I think there will be need to be many events flowing around the system.

backkem commented 4 years ago

I think disconnecting form the tracker isn't the end of the world. Once established, the WebRTC connections don't need the tracker's Websocket connection to stay alive. However, losing the connection before signaling is complete does mean you won't be able to complete the setup of a WebRTC connection.

Managing the tracker Websocket connections globally is probably a good idea since they will have more overhead than regular UDP ones.

backkem commented 4 years ago

The WebRTC connection setup is likely even more tricky. Normally WebRTC will allocate random ports for both sides of the connection. In addition, there are two steps: signaling (tracker) and the actual connections (torrent). This would require a bunch of back-and-fort between the tracker and connection logic and it's quite inefficient for this use-case.

However, unlike in the browser we have more control over the network stack. You could potentially address these downsides as follows:

This would mean:

The pion/webrtc library should be flexible enough to make this happen.

anacrolix commented 4 years ago

Thanks for the assistance again @backkem. I have a in-progress branch at https://github.com/anacrolix/torrent/tree/webtorrent that's able to download. Within the torrent repo, you can test it with GOPPROF=http go run -race -v ./cmd/torrent -dht=false 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=wss://tracker.btorrent.xyz&tr=wss://tracker.fastcast.nz&tr=wss://tracker.openwebtorrent.com'. It's very rough for now, but I'll continue to mold it to the torrent architecture, and take suggestions and improvements from people more familiar with WebRTC and webtorrent.

anacrolix commented 4 years ago

That command is now $ GOPPROF=http go run -v ./cmd/torrent download -dht=false -tcpPeers=false -utpPeers=false 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=wss://tracker.btorrent.xyz&tr=wss://tracker.fastcast.nz&tr=wss://tracker.openwebtorrent.com'.

issuehunt-oss[bot] commented 4 years ago

@anacrolix has rewarded $225.00 to @anacrolix. See it on IssueHunt

anacrolix commented 4 years ago

I'm closing this as done. There are further improvements to be made, but now that Webtorrent is supported on master, those will come over time.

jpillora commented 4 years ago

Nice work Matt!

On Thu, 16 Apr 2020 at 9:35 am Matt Joiner notifications@github.com wrote:

Closed #138 https://github.com/anacrolix/torrent/issues/138.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/anacrolix/torrent/issues/138#event-3237633578, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAE2X4234VIIWQYJNC6W6MTRMZAE7ANCNFSM4CZIEDIQ .