原文:hacks.mozilla.org/2018/08/dwe…
作者:Feross Aboukhadijeh发表时间:August 15, 2018
译者:西楼听雨 发表时间:2018/8/20
原文是 Mozilla 开发者网站发布的关于 Dweb 的概念、应用及使用案例介绍的系列文章中的第三篇。(转载请注明出处)

本系列各篇章的翻译链接如下:

  1. [译] Dweb: 什么是 Dweb?(中英)
  2. [译] Dweb: 基于 Secure Scuttlebutt 的社交消息流 (中英)
  3. [译] Dweb: 用 WebTorrent 搭建一个可复原的 Web (中英)
  4. [译] Dweb: 基于 Beaker 的去中心化 Web (中英)
  5. [译] Dweb: 基于 IPFS 的去中心化 Web 文件系统 (中英)
  6. 待发布······


译注:以下斜体文本是原文中的编者按

In this series we are covering projects that explore what is possible when the web becomes decentralized or distributed. These projects aren’t affiliated with Mozilla, and some of them rewrite the rules of how we think about a web browser. What they have in common: These projects are open source, and open for participation, and share Mozilla’s mission to keep the web open and accessible for all.
在这个系列中,我们会讲到一些正在尝试探索在 Web 变为去中心化或分布式的时候存在哪些可能性的项目,这些项目不附属于 Mozilla,其中一些项目还重新定义了我们对 web 浏览器的认识。他们都有共同点:这些项目都是开源的,开放参与的,并且和 Mozilla ”keep the web open and accessible for all (让 Web 对所有人保持开放和可访问)“ 的宗旨一致。
The web is healthy when the financial cost of self-expression isn’t a barrier. In this installment of the Dweb series we’ll learn about WebTorrent – an implementation of the BitTorrent protocol that runs in web browsers. This approach to serving files means that websites can scale with as many users as are simultaneously viewing the website – removing the cost of running centralized servers at data centers. The post is written by Feross Aboukhadijeh, the creator of WebTorrent, co-founder of PeerCDN and a prolific NPM module author… 225 modules at last count! –Dietrich Ayala
当自我表达所需的经济代价不再是一种障碍时,Web 就是健康的。在这个系列的本次讲解中,我们将了解到的是 WebTorrent ——一种运行在浏览器中的 BitTorrent 协议的实现。这种供应文件的方式可以让网站在同时查看网站的用户量无论有多大的情况下都保持着伸缩性——(这可以)节省运行在数据中心的中心式服务器的运营代价。

什么是 WebTorrent ?

WebTorrent is the first torrent client that works in the browser. It’s written completely in JavaScript – the language of the web – and uses WebRTC for true peer-to-peer transport. No browser plugin, extension, or installation is required.

WebTorrent 是第一款运行在浏览器中的 torrent 客户端。它完全是用 JavaScript ——也就是 Web 所使用的语言——编写的,使用的是 WebRTC 来进行真实的点对点传输。没借助浏览器插件、扩展,也无需额外安装其他东西。

Using open web standards, WebTorrent connects website users together to form a distributed, decentralized browser-to-browser network for efficient file transfer. The more people use a WebTorrent-powered website, the faster and more resilient it becomes.

借助各种开放的 Web 标准,WebTorrent 得以将网站的用户连接到一起,组成一张具备高效文件传输能力的“浏览器对浏览器”的分布式、去中心化的网络。一个基于 WebTorrent 的网站,其使用的人越多,它的速度就越快,可复原性也越强。

架构

The WebTorrent protocol works just like BitTorrent protocol, except it uses WebRTC instead of TCP or uTP as the transport protocol.

WebTorrent 协议的工作机制和 BitTorrent 协议一样,除了它使用的是 WebRTC 而不是 TCP 或者 uTP 作为传输协议外。

In order to support WebRTC’s connection model, we made a few changes to the tracker protocol. Therefore, a browser-based WebTorrent client or “web peer” can only connect to other clients that support WebTorrent/WebRTC.

为了能支持 WebRTC 的连接模型,我们对(torrent 的) tracker 协议做了一些修改。这样,一个基于浏览器的 WebTorrent 客户端——或者说是 “web peer”—— 就可以与其他支持 WebTorrent 及 WebRTC 的客户端建立连接。

Once peers are connected, the wire protocol used to communicate is exactly the same as in normal BitTorrent. This should make it easy for existing popular torrent clients like Transmission, and uTorrent to add support for WebTorrent. Vuze already has support for WebTorrent!

一旦点与点之间建立了连接,(基于该连接之上的)用于通讯的协议就和常规的 BitTorrent 的没有区别了。这可以让已有的各主流的 torrent 客户端——如 Transmission、uTorrent——在增加对 WebTorrent 的支持时变得容易。——Vuze 已经实现了对 WebTorrent 的支持!

开始

It only takes a few lines of code to download a torrent in the browser!

在浏览器中下载一个 torrent 文件只需要几行代码就可以做到!

To start using WebTorrent, simply include the webtorrent.min.js script on your page. You can download the script from the WebTorrent website or link to the CDN copy.

要使用 WebTorrent,只需在你的页面中将 weborrent.min.js 脚本文件引用进来即可。你可以从 WebTorrent 的网站上下载(这个文件)或者将链接指向到一个 CDN 副本。

<script src="webtorrent.min.js"></script>复制代码

This provides a WebTorrent function on the window object. There is also an npm package available.

这样之后,它会在 Window 对象上提供一个 WebTorrent 函数(供使用)。此外还有 npm 包 可用。

var client = new WebTorrent()
​
// Sintel, a free, Creative Commons movie
// 《辛特尔》,一部免费,采用“知识共享”(许可协议)的电影
var torrentId = 'magnet:...' // Real torrent ids are much longer. // 真实的 torrent id 远比这个长
​
var torrent = client.add(torrentId)
​
torrent.on('ready', () => {
// Torrents can contain many files. Let's use the .mp4 file
// 一个种子文件可以包含许多个文件。这里我们只使用 .mp4 文件
var file = torrent.files.find(file => file.name.endsWith('.mp4'))// Display the file by adding it to the DOM.// Supports video, audio, image files, and more!// 把他添加到 DOM 中进行展示。// 支持视频、音频、图像文件等等!file.appendTo('body')
})复制代码

That’s it! Now you’ll see the torrent streaming into a <video width="300" height="150"> tag in the webpage!

就这样!现在你就可以在网页中看到这个 torrent 被灌输到了 <video width="300" height="150"> 标签中。

更多信息

You can learn more at webtorrent.io, or by asking a question in #webtorrent on Freenode IRC or on Gitter. We’re looking for more people who can answer questions and help people with issues on the GitHub issue tracker. If you’re a friendly, helpful person and want an excuse to dig deeper into the torrent protocol or WebRTC, then this is your chance!

你可以在 webtorrent.io 了解更多的信息,你也可以在 Freenode IRC 及 Gitter 上的 #webtorrent (频道/主题下)发出提问。我们正期待有更多的人在 GitHub 的问题跟踪列表上提交和解答问题。如果你是一位友好、乐于助人的人,并且在找机会深入挖掘 torrent 协议和/或 WebRTC,那么现在就是机会!

关于 Feross Aboukhadijeh

Feross writes popular open source software including WebTorrent, StandardJS, and hundreds of Node.js packages (collectively 200+ million downloads per month). He recently released a fun site called BitMidi that curates MIDI files for your listening pleasure! His open source work is supported by generous donors on Patreon.

Feross 编写了许多流行的开源软件的,包括 WebTorrent、StandardJS,以及几百份的 Node.js 包(每月总计 2 亿多次的下载量)。最近,他发布了一个名为 BitMidi 的有趣的网站,这个网站组织了许多的 MIDI 文件,可以为你带来听觉享受!他的开源事业都是由 Patreon 上慷慨的捐助者们所支持的。

  • 他的主页:feross.org

  • 他的Twitter: @feross

[译] Dweb: 用 WebTorrent 搭建一个可复原的 Web (中英)相关推荐

  1. 搭建一个简单vue项目web项目全过程(完整步骤)

    一.安装node环境 1.下载地址为:Node.js 2.检查是否安装成功:如果输出版本号,说明我们安装node环境成功 2.检查是否安装成功:如果输出版本号,说明我们安装node环境成功 3.为了提 ...

  2. 一个感人的爱情故事(中英对照)

    a girl and a boy were on a motorcycle, speeding through the night.  一天夜里,男孩骑摩托车带着女孩超速行驶 they loved e ...

  3. 搭建一个自定义的工作流管理平台(一)

    最近一直在做工作流的相关开发工作,自己也搭建了一个工作流的管理平台来方便开发调试.这里记录一下相关的工作. 工作流的引擎我采用的是业界流行的Camunda,这个引擎基于BPMN/DMN的标准来实现工作 ...

  4. 中英互译软件工程设计

    中英互译软件工程设计 引言部分 1.1 目的 该文档的目的是描述中英互译软件工程系统的概要设计,主要内容包括系统功能简介.系统结构设计.系统接口设计.模块设计和界面设计等. 本文档预期的读者包括设计人 ...

  5. 中英互译软件工程初步设计

    中英互译软件工程初步设计 引言部分 1.1 目的 该文档的目的是描述中英互译软件工程系统的概要设计,主要内容包括系统功能简介.系统结构设计.系统接口设计.模块设计和界面设计等. 本文档预期的读者包括设 ...

  6. 我们开源了一个轻量的 Web IDE UI 框架 - Molecule

    Molecule , 一个轻量的 Web IDE UI 框架 https://github.com/DTStack/molecule​github.com/DTStack/molecule 简介 Mo ...

  7. 手把手教你用JSP+Servlet+Tomcat实现一个最简单的Web应用

    JSP+Servlet+Tomcat实现一个简单的Web应用 需要使用到的技术 ①JSP ② Servlet ③Tomcat Web开发中的常见概念 Demo *本文针对编程务实实验内容,简单演示一下 ...

  8. 有没有python与机械结合的工作-Python3从零开始搭建一个语音对话机器人的实现...

    01-初心缘由 最近在研究语音识别方向,看了很多的语音识别的资料和文章,了解了一下语音识别的前世今生,其中包含了很多算法的演变,目前来说最流行的语音识别算法主要是依赖于深度学习的神经网络算法,其中RN ...

  9. python微信公众号翻译功能_使用python在SAE上搭建一个微信应用,使用有道翻译的api进行在线翻译...

    1. 准备,先在使用python一步一步搭建微信公众平台(一)中基本实现自动回复的功能后,接着在有道词典上申请一个key,http://fanyi.youdao.com/openapi?path=da ...

最新文章

  1. win7下设置cmd操作mysql的环境变量
  2. oracle 查看日志组切换状态_Oracle 11g ADG 快照备库切换步骤
  3. uva 11995 I Can Guess the Data Structure!
  4. SVM与感知机的异同点
  5. 2017.8.10 奖励关 思考记录
  6. javascript学习笔记 - 引用类型 Function
  7. 10. Javascript DOM节点
  8. eclipse安装lombok插件
  9. Android系统签名生成
  10. 移动边缘计算网络架构
  11. 数据可视化案例(七)——智慧园区
  12. 电脑可以上网但打不开微信公众号
  13. hdu 5294 Tricks Device(最短路)
  14. 什么是 SEO ??? 对SEO的详细介绍
  15. 一文读懂元数据的概念、分类及作用
  16. 成吉思汗陵举行戊戌年成吉思汗嗣火祭祀
  17. 那些诡异的黑客事件 一
  18. Swift3豆瓣电台
  19. VGG——CNN经典网络模型(pytorch实现)
  20. 2022年13个UX/UI/UE最佳创意灵感网站

热门文章

  1. Android上好看的倒数日APP,Hurry:颜值超高的倒数日 App,让 Android 手机桌面好看 2 倍 #Android...
  2. voice conversion
  3. 计算用户输入的日期离1900年1月1日相距多少天
  4. 热烈欢迎领导莅临指导主题PPT模板
  5. 雷军回应 “小米手机都是中低端”
  6. poi word文档在书签处插入图片
  7. VIEW PUSHED PREDICATE(谓词推入)引发的惨剧
  8. 王者荣耀小游戏1.0震撼上线!C++版
  9. java怎么打印星期,在任何日期打印出星期几
  10. 增量型旋转编码器和绝对值旋转编码器