Use tracker.rtcConfig

This commit is contained in:
Diego Rodríguez 2017-02-03 15:30:02 -05:00
parent 49d9549d80
commit 131bbf9e9a
No known key found for this signature in database
GPG key ID: 699A21547E317F10

29
app.js
View file

@ -1,11 +1,8 @@
/* global WebTorrent, angular, moment, prompt */
const VERSION = '0.17.3'
const VERSION = '0.17.4'
const tracker = ['wss://tracker.btorrent.xyz', 'wss://tracker.openwebtorrent.com', 'wss://tracker.fastcast.nz']
const opts = {
announce: tracker
}
const trackers = ['wss://trackers.btorrent.xyz', 'wss://trackers.openwebtorrent.com', 'wss://trackers.fastcast.nz']
const rtcConfig = {
'iceServers': [
@ -16,6 +13,15 @@ const rtcConfig = {
]
}
const torrentOpts = {
announce: trackers
}
const trackerOpts = {
announce: trackers,
rtcConfig: rtcConfig
}
const debug = window.localStorage.getItem('debug') != null
const dbg = function (string, item, color) {
@ -34,8 +40,7 @@ const er = function (err, item) { dbg(err, item, '#FF0000') }
dbg(`Starting... v${VERSION}`)
const client = new WebTorrent({
rtcConfig: rtcConfig,
tracker: opts
tracker: trackerOpts
})
const app = angular.module('BTorrent',
@ -90,18 +95,18 @@ app.controller('BTorrentCtrl', ['$scope', '$rootScope', '$http', '$log', '$locat
} else {
dbg(`Seeding ${files.length} files`)
name = prompt('Please name your torrent', 'My Awesome Torrent') || 'My Awesome Torrent'
opts.name = name
torrentOpts.name = name
}
$rootScope.client.processing = true
$rootScope.client.seed(files, opts, $rootScope.onSeed)
delete opts.name
$rootScope.client.seed(files, torrentOpts, $rootScope.onSeed)
delete torrentOpts.name
}
}
$rootScope.openTorrentFile = function (file) {
if (file != null) {
dbg(`Adding torrent file ${file.name}`)
$rootScope.client.processing = true
$rootScope.client.add(file, opts, $rootScope.onTorrent)
$rootScope.client.add(file, torrentOpts, $rootScope.onTorrent)
}
}
$rootScope.client.on('error', function (err, torrent) {
@ -113,7 +118,7 @@ app.controller('BTorrentCtrl', ['$scope', '$rootScope', '$http', '$log', '$locat
if ((magnet != null) && magnet.length > 0) {
dbg(`Adding magnet/hash ${magnet}`)
$rootScope.client.processing = true
$rootScope.client.add(magnet, opts, onTorrent || $rootScope.onTorrent)
$rootScope.client.add(magnet, torrentOpts, onTorrent || $rootScope.onTorrent)
}
}
$rootScope.destroyedTorrent = function (err) {