diff --git a/README.md b/README.md index 7bfcf27..f7efedb 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,6 @@ In node.js, the `webtorrent` package only connects to normal TCP/UDP peers, not WebRTC peers. If you want to connect to all types of peers, including WebRTC peers, from node.js, you need to use this package (`webtorrent-hybrid`). -Previous versions (0.x) of this package used [wrtc](https://github.com/js-platform/node-webrtc), a WebRTC implementation via native extensions, the current one is based on [electron-webrtc](https://github.com/mappum/electron-webrtc) (which in turn uses [electron-prebuilt](https://github.com/electron-userland/electron-prebuilt)) for better compatibility. It creates a hidden Electron process (which is based on Chromium, so WebRTC support is great!) and communicates with that process to enable WebRTC in Node.js. This adds a lot of overhead, so we are looking forward to using a pure JavaScript implementation, like perhaps [Node-RTCPeerConnection](https://github.com/nickdesaulniers/node-rtc-peer-connection) when it's ready. - -To run this package on a headless server execute [the provided script](bin/prepareHeadless.sh) or follow [these instructions](https://github.com/mappum/electron-webrtc#running-on-a-headless-server). - ## Install To install WebTorrent: @@ -31,37 +27,6 @@ To install a `webtorrent-hybrid` command line program, run: npm install webtorrent-hybrid -g ``` -### OS X - -On OS X, this should Just Work™. - -### Linux - -The current version of `webtorrent-hybrid` requires a screen, since the headless Electron -instance expects one. If you're running in a screenless environment (like on a server), -you must use a virtual screen such as `xvfb`. You must install it before using -`webtorrent-hybrid`. - -#### For Debian / Ubuntu: - -```bash -sudo apt-get install xvfb -``` - -If you get an error about a missing .so file ("error while loading shared libraries"), use the search at the bottom of [packages.debian.org](https://packages.debian.org) to find out which packages in your release provide a given file. - -On server editions, the following additional packages should be installed since Electron depends on them: - -```bash -sudo apt-get install libgtk2.0-0 libxtst-dev libxss-dev libgconf2-dev libnss3 libasound2-dev -``` - -#### For CentOS / RHEL: - -```bash -sudo yum install xorg-x11-server-Xvfb -``` - ## Usage `webtorrent-hybrid` has the same command line interface (CLI) and module API as diff --git a/bin/prepareHeadless.sh b/bin/prepareHeadless.sh deleted file mode 100755 index 69d3b31..0000000 --- a/bin/prepareHeadless.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Detect running X server, load Xvfb on headless systems and starts a virtual buffer - -if [ -z $(pidof X) ]; then - - if [ ! $(which "Xvfb") ]; then - # TODO: - # - check alternative package support - if VERB="$( which apt-get )" 2> /dev/null; then - sudo apt-get install xvfb - elif VERB="$( which yum )" 2> /dev/null; then - sudo yum install xorg-x11-server-Xvfb - else - echo "Could not determine your package manager. Please, check the instructions to install Xvfb in your enviroment" - exit 2 - fi - fi - - #Check if Xvfb was installed - if [ $(which "Xvfb") ]; then - running=$(pidof Xvfb) - if [ -z "$running" ]; then - kill running - fi - - export DISPLAY="0:99" - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & - echo "Xvfb runing" - else - echo "Xvfb is not installed in your system" - fi -fi diff --git a/lib/global.js b/lib/global.js index 2ee535f..6673590 100644 --- a/lib/global.js +++ b/lib/global.js @@ -1,27 +1,8 @@ const createTorrent = require('create-torrent') -const ElectronWebRTC = require('electron-webrtc') +const wrtc = require('wrtc') global.WEBTORRENT_ANNOUNCE = createTorrent.announceList .map(arr => arr[0]) .filter(url => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0) -global.WRTC = () => { - const wrtc = ElectronWebRTC() - - const ensureCloseElectron = () => { - process.removeListener('SIGINT', ensureCloseElectron) - process.removeListener('SIGTERM', ensureCloseElectron) - wrtc.close() - } - - process.on('SIGINT', ensureCloseElectron) - process.on('SIGTERM', ensureCloseElectron) - - wrtc.on('error', (err, source) => { - if (err.message !== 'Daemon already closed') { - console.error(err, source) - } - }) - - return wrtc -} +global.WRTC = wrtc diff --git a/package.json b/package.json index 3ce1741..7514a97 100644 --- a/package.json +++ b/package.json @@ -12,10 +12,10 @@ "url": "https://github.com/webtorrent/webtorrent-hybrid/issues" }, "dependencies": { - "create-torrent": "^3.23.1", - "electron-webrtc": "^0.3.0", - "webtorrent": "0.x", - "webtorrent-cli": "^1.0.1" + "create-torrent": "^3.33.0", + "webtorrent": "^0.102.4", + "webtorrent-cli": "^1.12.3", + "wrtc": "^0.2.1" }, "devDependencies": { "standard": "*"