Giter VIP home page Giter VIP logo

instant.io's Introduction


WebTorrent
WebTorrent

The streaming torrent client. For node.js and the web.

discord ci npm version npm downloads Standard - JavaScript Style Guide

Sponsored by    Socket - JavaScript open source supply chain security    Wormhole

WebTorrent is a streaming torrent client for node.js and the browser. YEP, THAT'S RIGHT. THE BROWSER. It's written completely in JavaScript – the language of the web – so the same code works in both runtimes.

In node.js, this module is a simple torrent client, using TCP and UDP to talk to other torrent clients.

In the browser, WebTorrent uses WebRTC (data channels) for peer-to-peer transport. It can be used without browser plugins, extensions, or installations. It's Just JavaScript™. Note: WebTorrent does not support UDP/TCP peers in browser.

Simply include the webtorrent.min.js script on your page to start fetching files over WebRTC using the BitTorrent protocol, or import WebTorrent from 'webtorrent' with browserify or webpack. See demo apps and code examples below.

jsdelivr download count

To make BitTorrent work over WebRTC (which is the only P2P transport that works on the web) we made some protocol changes. Therefore, a browser-based WebTorrent client or "web peer" can only connect to other clients that support WebTorrent/WebRTC.

To seed files to web peers, use a client that supports WebTorrent, e.g. WebTorrent Desktop, a desktop client with a familiar UI that can connect to web peers, webtorrent-hybrid, a command line program, or Instant.io, a website. Established torrent clients like Vuze have already added WebTorrent support so they can connect to both normal and web peers. We hope other clients will follow.

Network

Features

  • Torrent client for node.js & the browser (same npm package!)
  • Insanely fast
  • Download multiple torrents simultaneously, efficiently
  • Pure Javascript (no native dependencies)
  • Exposes files as streams
    • Fetches pieces from the network on-demand so seeking is supported (even before torrent is finished)
    • Seamlessly switches between sequential and rarest-first piece selection strategy
  • Supports advanced torrent client features
  • Comprehensive test suite (runs completely offline, so it's reliable and fast)
  • Check all the supported BEPs here

Browser/WebRTC environment features

  • WebRTC data channels for lightweight peer-to-peer communication with no plugins
  • No silos. WebTorrent is a P2P network for the entire web. WebTorrent clients running on one domain can connect to clients on any other domain.
  • Stream video torrents into a <video> tag (webm, mkv, mp4, ogv, mov, etc (AV1, H264, HEVC*, VP8, VP9, AAC, FLAC, MP3, OPUS, Vorbis, etc))
  • Supports Chrome, Firefox, Opera and Safari.

Install

To install WebTorrent for use in node or the browser with import WebTorrent from 'webtorrent', run:

npm install webtorrent

To install a webtorrent command line program, run:

npm install webtorrent-cli -g

To install a WebTorrent desktop application for Mac, Windows, or Linux, see WebTorrent Desktop.

Ways to help

Who is using WebTorrent today?

Lots of folks!

WebTorrent API Documentation

Read the full API Documentation.

Usage

WebTorrent is the first BitTorrent client that works in the browser, using open web standards (no plugins, just HTML5 and WebRTC)! It's easy to get started!

In the browser

Downloading a file is simple:
import WebTorrent from 'webtorrent'

const client = new WebTorrent()
const magnetURI = '...'

client.add(magnetURI, torrent => {
  // Got torrent metadata!
  console.log('Client is downloading:', torrent.infoHash)

  for (const file of torrent.files) {
    document.body.append(file.name)
  }
})
Seeding a file is simple, too:
import dragDrop from 'drag-drop'
import WebTorrent from 'webtorrent'

const client = new WebTorrent()

// When user drops files on the browser, create a new torrent and start seeding it!
dragDrop('body', files => {
  client.seed(files, torrent => {
    console.log('Client is seeding:', torrent.infoHash)
  })
})

There are more examples in docs/get-started.md.

Browserify

WebTorrent works great with browserify, an npm package that lets you use node-style require() to organize your browser code and load modules installed by npm (as seen in the previous examples).

Webpack

WebTorrent also works with webpack, another module bundler. However, webpack requires extra configuration which you can find in the webpack bundle config used by webtorrent.

Or, you can just use the pre-built version via import WebTorrent from 'webtorrent/dist/webtorrent.min.js' and skip the webpack configuration.

Script tag

WebTorrent is also available as a standalone script (webtorrent.min.js) which exposes WebTorrent on the window object, so it can be used with just a script tag:

<script type='module'>
  import WebTorrent from 'webtorrent.min.js'
</script>

The WebTorrent script is also hosted on fast, reliable CDN infrastructure (Cloudflare and MaxCDN) for easy inclusion on your site:

<script type='module'>
  import WebTorrent from 'https://esm.sh/webtorrent'
</script>
Chrome App

If you want to use WebTorrent in a Chrome App, you can include the following script:

<script type='module'>
  import WebTorrent from 'webtorrent.chromeapp.js'
</script>

Be sure to enable the chrome.sockets.udp and chrome.sockets.tcp permissions!

In Node.js

WebTorrent also works in node.js, using the same npm package! It's mad science!

NOTE: To connect to "web peers" (browsers) in addition to normal BitTorrent peers, use webtorrent-hybrid which includes WebRTC support for node.

As a command line app

WebTorrent is also available as a command line app. Here's how to use it:

$ npm install webtorrent-cli -g
$ webtorrent --help

To download a torrent:

$ webtorrent magnet_uri

To stream a torrent to a device like AirPlay or Chromecast, just pass a flag:

$ webtorrent magnet_uri --airplay

There are many supported streaming options:

--airplay               Apple TV
--chromecast            Chromecast
--mplayer               MPlayer
--mpv                   MPV
--omx [jack]            omx [default: hdmi]
--vlc                   VLC
--xbmc                  XBMC
--stdout                standard out [implies --quiet]

In addition to magnet uris, WebTorrent supports many ways to specify a torrent.

Talks about WebTorrent

Modules

Most of the active development is happening inside of small npm packages which are used by WebTorrent.

The Node Way™

"When applications are done well, they are just the really application-specific, brackish residue that can't be so easily abstracted away. All the nice, reusable components sublimate away onto github and npm where everybody can collaborate to advance the commons." — substack from "how I write modules"

node.js is shiny

Modules

These are the main modules that make up WebTorrent:

module tests version description
webtorrent torrent client (this module)
bittorrent-dht distributed hash table client
bittorrent-peerid identify client name/version
bittorrent-protocol bittorrent protocol stream
bittorrent-tracker bittorrent tracker server/client
bittorrent-lsd bittorrent local service discovery
create-torrent create .torrent files
magnet-uri parse magnet uris
parse-torrent parse torrent identifiers
torrent-discovery find peers via dht, tracker, and lsd
ut_metadata metadata for magnet uris (protocol extension)
ut_pex peer discovery (protocol extension)

Enable debug logs

In node, enable debug logs by setting the DEBUG environment variable to the name of the module you want to debug (e.g. bittorrent-protocol, or * to print all logs).

DEBUG=* webtorrent

In the browser, enable debug logs by running this in the developer console:

localStorage.setItem('debug', '*')

Disable by running this:

localStorage.removeItem('debug')

License

MIT. Copyright (c) Feross Aboukhadijeh and WebTorrent, LLC.

instant.io's People

Contributors

bnb avatar danbovey avatar dependabot[bot] avatar diegorbaquero avatar feross avatar fumesover avatar gcq avatar greenkeeper[bot] avatar greenkeeperio-bot avatar hisener avatar iuriguilherme avatar jakefb avatar jhiesey avatar jimmywarting avatar josephfrazier avatar joshterrill avatar kitten-s avatar linusu avatar mafintosh avatar markreid avatar mathiasvr avatar nicola avatar nixxquality avatar r0mflip avatar renovate-bot avatar renovate[bot] avatar toxel avatar tsonge avatar willstott101 avatar zackees avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

instant.io's Issues

Have a list of demo files

I think it would be nice to have a list of demo files (like this) that people can download/watch to better understand what's instant.io is about.
It could be an html page or a simple markdown page (maybe in instant.io's wiki ? idk)

add normal file upload box

04:25 <substack> feross: drag/drop on instant.io doesn't work very well for me on linux
04:25 <substack> what about a download form?
04:26 <substack> it just opens the file in the browser instead of intercepting the dropped file

cc @substack

Wrong magnet uri

Is always generating magnet:?tr=wss%3A%2F%2Ftracker.webtorrent.io

Is upload rate correct?

When I transfer directly from one tab to another, the uploader's transfer rate appears significantly higher than the receiver's. What is going on?

saving the downloaded file

Is there an option to save the downloaded (video) file? I could not find one after downloading mp4 file; only playback option is provided.

Error in /instant.io-master/server/index.js

Hello,
just leaving a bugfix that there is an issue with code located here

app.use(express.static(path.join(__dirname, '../static')))

my editor does not seem to like express.static

(static comes up as red)

Let me know if anyone figured it out or if it is just my coder.

Cheers
K!

ICE failed under Firefox 33.0

Executed localStorage.debug = '*'
Random info hash with a lot of seeds: 1FA6D2D6A5FE21D00E0B822CCDA7699547163F65
Click download.

"webtorrent " "new webtorrent" " +0ms" bundle.js:7710
"bittorrent-client " "new client peerId 2d5757303030312d643461336135313438666163 nodeId 3b40854e569e83ab91b91cc657295eb06ae72249" " +2ms" bundle.js:7710
localStorage.debug = '*'
"*"
"webtorrent " "add [object Object]" " +2m" bundle.js:7710
"bittorrent-client " "add [object Object]" " +1ms" bundle.js:7710
"bittorrent-client:torrent " "new torrent" " +0ms" bundle.js:7710
"webtorrent-swarm " "new swarm i 1fa6d2d6a5fe21d00e0b822ccda7699547163f65 p 2d5757303030312d643461336135313438666163" " +2ms" bundle.js:7710
"torrent-discovery " "setTorrent 1FA6D2D6A5FE21D00E0B822CCDA7699547163F65" " +1ms" bundle.js:7710
"webtorrent-tracker " "new client 1fa6d2d6a5fe21d00e0b822ccda7699547163f65" " +0ms" bundle.js:7710
"webtorrent-tracker " "new tracker wss://tracker.webtorrent.io" " +1ms" bundle.js:7710
"webtorrent-tracker " "sent `start` wss://tracker.webtorrent.io {"event":"started"}" " +0ms" bundle.js:7710
GET https://tracker.webtorrent.io/ [HTTP/1.1 101 Switching Protocols 925ms]
"webtorrent-tracker " "generating 15 offers" " +1s" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-3e51f593800eae610c1b3554d6bd46daf1c0249d" " +1ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-f13fb56b594c810b47a76e166394cbddc0da2b34" " +137ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-3829444fac77f0b5cdf2090a48622e816aa6c72e" " +170ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-49ca926597b481836b4790ad11319de48d96f8d0" " +153ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-354a0eff1663ded83a35a9a9edae21848964cf02" " +54ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-c9f5d4343a328c981fa32f0110190f9ec1253ab9" " +80ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-bea48aeeeb9718c29b06269a462d3c7039476b10" " +89ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-137a863bf8edad4d11c79f08f9f495171d78677f" " +139ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-3713f12c797b4d2143521b9d1087fc57eb1c253f" " +74ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-b767fb81cb320f68ffa2a6a7e4a150807f4afc4e" " +61ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-446d7904c2f337c56f344da2e101354947271886" " +60ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-d91858637919d05d54093da6b0081b8aa8dc3dd4" " +107ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-85bf6f9931c8738940a56c0c00394dff755272b0" " +77ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-9deecc6252b239196f70dd0e11f6064eb1b2b438" " +87ms" bundle.js:7710
"simple-peer " "new peer initiator: true channelName: simple-peer-0e2494e0bd8a3b82c2ab127f629ffee68e78b418" " +194ms" bundle.js:7710
ICE failed, see about:webrtc for more details
"simple-peer " "iceConnectionStateChange new failed" " +100ms" bundle.js:7710
"simple-peer " "iceConnectionStateChange new failed" " +2ms" bundle.js:7710
"simple-peer " "iceConnectionStateChange new failed" " +0ms" bundle.js:7710
"simple-peer " "iceConnectionStateChange new failed" " +1ms" bundle.js:7710
"simple-peer " "iceConnectionStateChange new failed" " +0ms" bundle.js:7710
"simple-peer " "iceConnectionStateChange new failed" " +1ms" bundle.js:7710
"simple-peer " "iceConnectionStateChange new failed" " +0ms" bundle.js:7710
"simple-peer " "iceConnectionStateChange new failed" " +2ms" bundle.js:7710
"simple-peer " "iceConnectionStateChange new failed" " +0ms" bundle.js:7710
"simple-peer " "iceConnectionStateChange new failed" " +1ms" bundle.js:7710
"simple-peer " "iceConnectionStateChange new failed" " +0ms" bundle.js:7710
"simple-peer " "signalingStateChange have-local-offer" " +52ms" bundle.js:7710
"simple-peer " "signalingStateChange have-local-offer" " +0ms" bundle.js:7710
"simple-peer " "signalingStateChange have-local-offer" " +5ms" bundle.js:7710
"simple-peer " "signalingStateChange have-local-offer" " +0ms" bundle.js:7710
"simple-peer " "signalingStateChange have-local-offer" " +1ms" bundle.js:7710
"simple-peer " "signalingStateChange have-local-offer" " +0ms" bundle.js:7710

about:webrtc shows 15 of these:

Closed PeerConnection:1413129330578000 (id=5700 url=http://instant.io/) 18:04:08 GMT+0200

ICE statistics

Local SDP
v=0
o=Mozilla-SIPUA-33.0 16730 0 IN IP4 0.0.0.0
s=SIP Call
t=0 0
a=ice-ufrag:5abadc12
a=ice-pwd:c3794f4089d896401a248b1ae64599d3
a=fingerprint:sha-256 51:CD:4F:DB:59:8C:DD:74:A3:38:FF:B0:53:7B:0D:B0:13:D2:52:CF:15:B3:98:9D:8F:EC:48:E1:A6:BD:A9:D7
m=application 9 DTLS/SCTP 5000
c=IN IP4 0.0.0.0
a=sctpmap:5000 webrtc-datachannel 16
a=setup:actpass

Remote SDP


I don't know if it's a problem with FF, with my setup, or webtorrent.
If i can help in any way tell me.

Video autoplay

The video previews autoplay when you upload them, but if you upload more than one video at once, they all play at the same time.

Switch drag-drop to not use buffer

That way we don't need to load the whole file into memory up-front.

drag-drop/buffer -> drag-drop

It looks like just making this change triggers some bug in filestream where the 'end' event is not emitted. Investigate.

Downloading from .torrent files is broken

instant.io gives "Uncaught Error: Invalid torrent identifier" in the javascript console when trying to download from a torrent file rather than info hash or magnet link.

Steps to reproduce:

  1. Start seeding a file on instant.io
  2. Download the torrent for the file
  3. Open the torrent in a new tab at instant.io

I'm using Chrome Version 43.0.2357.81

Add a P2P chat component

Just though of this. Wouldn't it be cool if you could choose to participate in some sort of chat with all your WebTorrent peers using WebRTC? Since you're sharing content it seems that you're also sharing an interest. And that's always a good place to start a conversation!

I was thinking like an opt-in sidepanel with a chat "hosted" by the peers - like Friends!

Transfer stats: peer count is wrong

Peers seem not to be removed from torrent.swarm._peers correctly. Also, the peer count is sometimes 0 even though a transfer is happening.

Privacy & legality

Could we assume that this method of P2P transfer is somewhat safer than more mainstream ones?

Let me explain my scenario. My sister lives in Germany where illegally downloading licensed content is under strict surveillance. You can get fined without warning and fines are usually pretty salty. She works on a boat and gets bored after work hours without internet. Before she embarks I have files I want to send her to keep busy. Like a movie that I got legally by buying it directly from the artist's website, or an ebook from a kickstarter I supported. These are legal to share with my family, and I am not planning on distributing them. Though, from the point of view of an algorithm, it might look like I'm broadcasting licensed content.

Could sharing through instant.io be considered safe? Or will she get fined if I choose to send her files this way?

Add a progress/status indicator for download

When first going to a download link (instant.io/#infoHash) there are quite a few seconds where it looks like just an upload page before the download section gets populated with progress. Would be good to put at least a spinner there as soon as the page loads so the user knows a download is coming.

Questions about Torrent/Peer Discovery

I have a few questions on how peer discovery works in instant.io and webtorrent:

  • If DHT working in webtorrent, why did you use a tracker server instead? (index.js, line 43.)
  • If DHT is enabled on a torrent, can it be found by just its infoHash?
  • Is it ok to use wss://tracker.webtorrent.io for applications using webtorrent?
    • If not, do you have any tips on creating a tracker server?

Thanks in advance!

Seeding file from server

How could I seed files withoud internet inside NAT?

How could I seed files from the server after client have uploaded the file. Webtorrent-hybrid and webtorrent use the same websocket adress so i have an error

Seed multiple torrents at once

It would be cool if it was possible to choose what happens when more than one file is selected or dropped in. The user should be able to choose if a torrent is created from the array of files or if a torrent is created for each file so each file has its own individual hash. I'm willing to give this an attempt and make a PR.

Trigger.sh is asking for password

Hi Ferros,

I have removed the node modules of the clone so that i can install the "bin" files but for some reason it asks for a password. Is it required for me to implement these .sh files or should I continue with browserifying the indexes? Thanks for your help in advance.

instant.io broken in firefox nightly

I get following in the console:
TypeError: asm.js type error: expecting argument type declaration for 'e' of the form 'arg = arg|0' or 'arg = +arg' or 'arg = fround(arg)'

Then when it tries to hash a file:
AssertionError: false == true

I guess it might be related to this: subrosa-io/subrosa-client#39

Better torrent name when dropping a folder

When dropping multiple files, or a folder (which will soon be supported for Chrome!), we currently just pick the first file name as the name of the torrent. This is confusing. What should we name the torrent instead?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.