Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-07-03 07:48:38 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-07-03 07:48:38 +0300
commitb3e1d2dd0e80378a6d0587272d7088436ed65126 (patch)
tree0a8a8df501590dfece072299fec53662d2d7b534
parent8bd60a2c197d27a77aa47f2df39a7444463aea6f (diff)
cleanup web seed support after PR
-rw-r--r--lib/torrent.js9
-rw-r--r--test/download-webseed-torrent.js27
2 files changed, 16 insertions, 20 deletions
diff --git a/lib/torrent.js b/lib/torrent.js
index 44994ab..f507fd6 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -241,7 +241,7 @@ Torrent.prototype._onSwarmListening = function () {
if (self.parsedTorrent.info) self._onMetadata(self.parsedTorrent)
if (self.parsedTorrent.urlList) {
- self.parsedTorrent.urlList.forEach(self.addWebPeer.bind(self))
+ self.parsedTorrent.urlList.forEach(self.addWebSeed.bind(self))
}
self.emit('listening', self.client.torrentPort)
@@ -399,12 +399,11 @@ Torrent.prototype.addPeer = function (peer) {
/**
* Add a web peer to the swarm
- * @param {string} web peer url
+ * @param {string} url web seed url
*/
-Torrent.prototype.addWebPeer = function (webPeer) {
+Torrent.prototype.addWebSeed = function (url) {
var self = this
- self.emit('webPeer', webPeer)
- self.swarm.addWebPeer(webPeer, self.parsedTorrent)
+ self.swarm.addWebSeed(url, self.parsedTorrent)
}
/**
diff --git a/test/download-webseed-torrent.js b/test/download-webseed-torrent.js
index 5c048f8..b6f7b2c 100644
--- a/test/download-webseed-torrent.js
+++ b/test/download-webseed-torrent.js
@@ -21,7 +21,7 @@ leavesParsed.announce = []
test('Download using webseed (via .torrent file)', function (t) {
t.plan(5)
- var serve = serveStatic(path.join(__dirname, './content'))
+ var serve = serveStatic(path.join(__dirname, 'content'))
var httpServer = http.createServer(function (req, res) {
var done = finalhandler(req, res)
serve(req, res, done)
@@ -38,18 +38,15 @@ test('Download using webseed (via .torrent file)', function (t) {
cb(null, port)
})
},
- client1: ['httpPort', function (cb, r) {
-
+ client: ['httpPort', function (cb, r) {
leavesParsed.urlList.push('http://localhost:' + r.httpPort + '/' + leavesFilename)
- var client1 = new WebTorrent({
- tracker: false,
- dht: { bootstrap: false }
- })
+ var client = new WebTorrent({ tracker: false, dht: false })
- client1.on('error', function (err) { t.fail(err) })
+ client.on('error', function (err) { t.fail(err) })
+ client.on('warning', function (err) { t.fail(err) })
- client1.on('torrent', function (torrent) {
+ client.on('torrent', function (torrent) {
torrent.files.forEach(function (file) {
file.getBuffer(function (err, buf) {
if (err) throw err
@@ -58,18 +55,18 @@ test('Download using webseed (via .torrent file)', function (t) {
})
torrent.once('done', function () {
- t.pass('client1 downloaded torrent from webseed')
- cb(null, client1)
+ t.pass('client downloaded torrent from webseed')
+ cb(null, client)
})
})
- client1.add(leavesParsed)
-
+ client.add(leavesParsed)
}]
}, function (err, r) {
+
t.error(err)
- r.client1.destroy(function () {
- t.pass('client1 destroyed')
+ r.client.destroy(function () {
+ t.pass('client destroyed')
})
httpServer.close(function () {
t.pass('http server closed')