Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add default webrtc trackers when there is webrtc support #673

Closed
Closed
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -30,6 +30,8 @@ var Swarm = require('bittorrent-swarm')
var uniq = require('uniq')
var ut_metadata = require('ut_metadata')
var ut_pex = require('ut_pex') // browser exclude
var Peer = require('simple-peer')
var createTorrent = require('create-torrent')

var File = require('./file')
var RarityMap = require('./rarity-map')
@@ -50,6 +52,16 @@ var TMP = typeof pathExists.sync === 'function'
? path.join(pathExists.sync('/tmp') ? '/tmp' : os.tmpDir(), 'webtorrent')
: '/tmp/webtorrent'

if (Peer.WEBRTC_SUPPORT && !global.WEBTORRENT_ANNOUNCE) {
global.WEBTORRENT_ANNOUNCE = createTorrent.announceList
.map(function (arr) {
return arr[0]
})
.filter(function (url) {
return url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0
})
}

inherits(Torrent, EventEmitter)

/**
@@ -16,7 +16,7 @@ test('client.add: magnet uri, utf-8 string', function (t) {

torrent.on('infoHash', function () {
t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
t.equal(torrent.magnetURI.split('&tr')[0], fixtures.leaves.magnetURI)

client.remove(fixtures.leaves.magnetURI, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
@@ -38,7 +38,7 @@ test('client.add: torrent file, buffer', function (t) {

torrent.on('infoHash', function () {
t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
t.equal(torrent.magnetURI.split('&tr')[0], fixtures.leaves.magnetURI)

client.remove(fixtures.leaves.torrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
@@ -104,7 +104,7 @@ test('client.add: parsed torrent, from `parse-torrent`', function (t) {

torrent.on('infoHash', function () {
t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
t.equal(torrent.magnetURI.split('&tr')[0], fixtures.leaves.magnetURI)

client.remove(fixtures.leaves.parsedTorrent, function (err) { t.error(err, 'torrent destroyed') })
t.equal(client.torrents.length, 0)
@@ -17,7 +17,7 @@ test('client.seed: torrent file (Buffer)', function (t) {
}, function (torrent) {
t.equal(client.torrents.length, 1)
t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
t.equal(torrent.magnetURI.split('&tr')[0], fixtures.leaves.magnetURI)

client.remove(torrent, function (err) { t.error(err, 'torrent removed') })
t.equal(client.torrents.length, 0)
@@ -40,7 +40,7 @@ test('client.seed: torrent file (Buffer), set name on buffer', function (t) {
client.seed(buf, function (torrent) {
t.equal(client.torrents.length, 1)
t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
t.equal(torrent.magnetURI.split('&tr')[0], fixtures.leaves.magnetURI)

client.remove(torrent, function (err) { t.error(err, 'torrent removed') })
t.equal(client.torrents.length, 0)
@@ -64,7 +64,7 @@ test('client.seed: torrent file (Blob)', function (t) {
}, function (torrent) {
t.equal(client.torrents.length, 1)
t.equal(torrent.infoHash, fixtures.leaves.parsedTorrent.infoHash)
t.equal(torrent.magnetURI, fixtures.leaves.magnetURI)
t.equal(torrent.magnetURI.split('&tr')[0], fixtures.leaves.magnetURI)

client.remove(torrent, function (err) { t.error(err, 'torrent removed') })
t.equal(client.torrents.length, 0)
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.