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
Option to disable BEP19 web seeds #911
Changes from all commits
File filter...
Jump to…
| @@ -51,11 +51,12 @@ If `opts` is specified, then the default options (shown below) will be overridde | ||
|
|
||
| ```js | ||
| { | ||
| dht: Boolean|Object, // Enable DHT (default=true), or options object for DHT | ||
| maxConns: Number, // Max number of connections per torrent (default=55) | ||
| nodeId: String|Buffer, // DHT protocol node ID (default=randomly generated) | ||
| peerId: String|Buffer, // Wire protocol peer ID (default=randomly generated) | ||
| tracker: Boolean|Object // Enable trackers (default=true), or options object for Tracker | ||
| tracker: Boolean|Object, // Enable trackers (default=true), or options object for Tracker | ||
| dht: Boolean|Object, // Enable DHT (default=true), or options object for DHT | ||
| webSeeds: Boolean // Enable BEP19 web seeds (default=true) | ||
feross
Member
|
||
| } | ||
| ``` | ||
|
|
||
| @@ -1,7 +1,7 @@ | ||
| { | ||
| "name": "webtorrent", | ||
| "description": "Streaming torrent client", | ||
| "version": "0.96.5", | ||
| "version": "0.97.0", | ||
feross
Member
|
||
| "author": { | ||
| "name": "WebTorrent, LLC", | ||
| "email": "feross@webtorrent.io", | ||
| @@ -9,8 +9,12 @@ var serveStatic = require('serve-static') | ||
| var test = require('tape') | ||
| var WebTorrent = require('../../') | ||
|
|
||
| // it should be fast to download a small torrent over local HTTP | ||
| var WEB_SEED_TIMEOUT_MS = 500 | ||
|
|
||
| test('Download using webseed (via .torrent file)', function (t) { | ||
| t.plan(6) | ||
| t.timeoutAfter(WEB_SEED_TIMEOUT_MS) | ||
feross
Member
|
||
|
|
||
| var parsedTorrent = extend(fixtures.leaves.parsedTorrent) | ||
|
|
||
| @@ -72,3 +76,46 @@ test('Download using webseed (via .torrent file)', function (t) { | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| test('Disable webseeds', function (t) { | ||
| var parsedTorrent = extend(fixtures.leaves.parsedTorrent) | ||
|
|
||
| var httpServer = http.createServer(function (req, res) { | ||
| t.fail('webseed http server should not get any requests') | ||
| }) | ||
| var client | ||
|
|
||
| httpServer.on('error', function (err) { t.fail(err) }) | ||
|
|
||
| series([ | ||
| function (cb) { | ||
| httpServer.listen(cb) | ||
| }, | ||
|
|
||
| function (cb) { | ||
| parsedTorrent.urlList = [ | ||
| 'http://localhost:' + httpServer.address().port + '/' + fixtures.leaves.parsedTorrent.name | ||
| ] | ||
|
|
||
| client = new WebTorrent({ dht: false, tracker: false, webSeeds: false }) | ||
|
|
||
| client.on('error', function (err) { t.fail(err) }) | ||
| client.on('warning', function (err) { t.fail(err) }) | ||
|
|
||
| client.add(parsedTorrent, {store: MemoryChunkStore}) | ||
|
|
||
| // The test above ensures that we can download the whole torrent over webseeds within a | ||
| // short time. Here, we wait the same amount of time and make sure no HTTP requests happen. | ||
feross
Member
|
||
| setTimeout(cb, WEB_SEED_TIMEOUT_MS) | ||
| } | ||
| ], function (err) { | ||
| t.error(err) | ||
| client.destroy(function (err) { | ||
| t.error(err, 'client destroyed') | ||
| }) | ||
| httpServer.close(function () { | ||
| t.pass('http server closed') | ||
| t.end() | ||
| }) | ||
| }) | ||
| }) | ||
Looks like v0.96.0 is missing. I'll add it.