Use tracker.rtcConfig
This commit is contained in:
parent
49d9549d80
commit
131bbf9e9a
1 changed files with 17 additions and 12 deletions
29
app.js
29
app.js
|
@ -1,11 +1,8 @@
|
||||||
/* global WebTorrent, angular, moment, prompt */
|
/* 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 trackers = ['wss://trackers.btorrent.xyz', 'wss://trackers.openwebtorrent.com', 'wss://trackers.fastcast.nz']
|
||||||
const opts = {
|
|
||||||
announce: tracker
|
|
||||||
}
|
|
||||||
|
|
||||||
const rtcConfig = {
|
const rtcConfig = {
|
||||||
'iceServers': [
|
'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 debug = window.localStorage.getItem('debug') != null
|
||||||
|
|
||||||
const dbg = function (string, item, color) {
|
const dbg = function (string, item, color) {
|
||||||
|
@ -34,8 +40,7 @@ const er = function (err, item) { dbg(err, item, '#FF0000') }
|
||||||
dbg(`Starting... v${VERSION}`)
|
dbg(`Starting... v${VERSION}`)
|
||||||
|
|
||||||
const client = new WebTorrent({
|
const client = new WebTorrent({
|
||||||
rtcConfig: rtcConfig,
|
tracker: trackerOpts
|
||||||
tracker: opts
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const app = angular.module('BTorrent',
|
const app = angular.module('BTorrent',
|
||||||
|
@ -90,18 +95,18 @@ app.controller('BTorrentCtrl', ['$scope', '$rootScope', '$http', '$log', '$locat
|
||||||
} else {
|
} else {
|
||||||
dbg(`Seeding ${files.length} files`)
|
dbg(`Seeding ${files.length} files`)
|
||||||
name = prompt('Please name your torrent', 'My Awesome Torrent') || 'My Awesome Torrent'
|
name = prompt('Please name your torrent', 'My Awesome Torrent') || 'My Awesome Torrent'
|
||||||
opts.name = name
|
torrentOpts.name = name
|
||||||
}
|
}
|
||||||
$rootScope.client.processing = true
|
$rootScope.client.processing = true
|
||||||
$rootScope.client.seed(files, opts, $rootScope.onSeed)
|
$rootScope.client.seed(files, torrentOpts, $rootScope.onSeed)
|
||||||
delete opts.name
|
delete torrentOpts.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$rootScope.openTorrentFile = function (file) {
|
$rootScope.openTorrentFile = function (file) {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
dbg(`Adding torrent file ${file.name}`)
|
dbg(`Adding torrent file ${file.name}`)
|
||||||
$rootScope.client.processing = true
|
$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) {
|
$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) {
|
if ((magnet != null) && magnet.length > 0) {
|
||||||
dbg(`Adding magnet/hash ${magnet}`)
|
dbg(`Adding magnet/hash ${magnet}`)
|
||||||
$rootScope.client.processing = true
|
$rootScope.client.processing = true
|
||||||
$rootScope.client.add(magnet, opts, onTorrent || $rootScope.onTorrent)
|
$rootScope.client.add(magnet, torrentOpts, onTorrent || $rootScope.onTorrent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$rootScope.destroyedTorrent = function (err) {
|
$rootScope.destroyedTorrent = function (err) {
|
||||||
|
|
Loading…
Reference in a new issue