47

没有太多要补充的了。是否可以仅使用 HTML 和 JavaScript 构建一个 torrent 客户端。您不能使用 Java、ActiveX、NaCl 之类的东西……如果是,请给出高级描述。

我对前端开发了解不多,但我认为 websockets 将能够进行网络连接(是否可以将一个客户端连接到另一个客户端而无需所有数据都通过服务器?)。我知道您不能使用 JavaScript 编写文件,所以我认为正在下载的文件要么必须完全保存在内存中,要么客户端必须使用 HTML5 中的新 API 之一来存储内容。

4

7 回答 7

33

不,这不对。

这是因为 WebSocket 规范不属于 HTML5 和 JavaScript ;-) 话虽这么说,但问题是“在 [progressive/upcoming] 浏览器中使用本机支持的功能”然后......

...仍然没有:-)

这是因为 WebSocket 需要一个特殊的握手来设置限制。这不是免费的开放 TCP 盛会。该方法将需要

  1. 要修改客户端以接受 WebSocket 请求(以及处理任何跨站点访问问题)

  2. 或者,更现实地说,是一个可以反弹的服务器

于 2011-01-23T20:24:33.747 回答
17

这可以使用Chrome 应用程序 APIchrome.socketchrome.fileSystem

Google Chrome 至少有一个纯 JavaScript 实现:JSTorrent

于 2013-03-02T11:48:29.137 回答
17

There's a recent implementation based on WebRTC that works in node and the browser: https://github.com/feross/webtorrent

于 2014-10-28T16:30:50.097 回答
10

There's no good reason why this can't be done today. BitTorrent/uTorrent both have code to support websocket connections with binary frames. However, they are currently compiled without support (due to political/product reasons I think). I used to work at BitTorrent and another engineer (Arty) wrote the support. For a while it was really cool being able to download torrents onto iPads from mobile Safari. (saving directly to Google Drive funnily enough)

HTTP trackers could be configured to send Access-Control-Allow-Origin headers.

Also the tracker announce protocol could use a bit in the "key" field to indicate that the client accepts websocket connections. Then a special argument like "typewant" could indicate that the announce response should only return clients who have sent that bit.

The tracker protocol could also be extended similarly to support negotiation of WebRTC P2P DataChannel connections, so that connections could be made directly browser<->browser.

For now, we have the chrome.socket platform API, and jstorrent, a chrome packaged app (designed for ChromeOS mainly)

于 2013-08-21T03:48:48.247 回答
9

您不能使用 WebSocket,因为它们是严格的客户端-服务器。但即将推出的 WebRTC 标准,虽然主要针对音频/视频会议,但提供了通用客户端-客户端数据传输的规定。如果此规定成为最终版本,那么您将有一种可行的方法来实现浏览器之间的通用对等数据传输。

于 2011-12-09T09:01:28.183 回答
4

一些:

https://github.com/superafroman/node-torrent

https://github.com/deoxxa/bittorrent.js

于 2012-09-20T03:03:09.897 回答
4

I'm late to the party, but since this question is still among the top on Google's results, I'll answer anyway.

You may write BitTorrent-related web apps or browser extensions with Btapp.js, which uses a Javascript interface provided by BitTorrent Torque. When you call the connect method, the user will be prompted to install BitTorrent Torque, that's all. Some cool stuff going on if you check out existing projects using it—streaming media, drag-and-drop sharing, etc.

As for solutions without any dependency, the ones mentioned by Nick Russler still seem to be the only feasible options.

于 2013-07-21T09:30:36.783 回答