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
path: root/lib
diff options
context:
space:
mode:
authorGilles De Mey <gilles.de.mey@gmail.com>2015-08-16 21:48:11 +0300
committerGilles De Mey <gilles.de.mey@gmail.com>2015-08-31 00:30:52 +0300
commit0babdde10161cccf7227b7e8229cdb3f24cd1b3b (patch)
tree288beb81f9b9793eb2feaed822fd7d53bc455e5a /lib
parentfed21e9205bb53f8568e3a07cded887698f166fc (diff)
Disable DHT and PEX when the torrent is flagged as private
Add test for private torrent - should disable DHT Fail public torrent test when using a private torrent standard Disable DHT for the torrent's swarm and discovery.
Diffstat (limited to 'lib')
-rw-r--r--lib/torrent.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/torrent.js b/lib/torrent.js
index 9d4ecdf..0275d70 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -196,7 +196,9 @@ Torrent.prototype._onParsedTorrent = function (parsedTorrent) {
// create swarm
self.swarm = new Swarm(self.infoHash, self.client.peerId, {
- handshake: { dht: !!self.client.dht }
+ handshake: {
+ dht: self.private ? false : !!self.client.dht
+ }
})
self.swarm.on('error', self._onError.bind(self))
self.swarm.on('wire', self._onWire.bind(self))
@@ -263,7 +265,9 @@ Torrent.prototype._onSwarmListening = function () {
// begin discovering peers via the DHT and tracker servers
self.discovery = new Discovery({
announce: self.announce,
- dht: self.client.dht,
+ dht: self.private
+ ? false
+ : self.client.dht,
tracker: self.client.tracker,
peerId: self.client.peerId,
port: self.client.torrentPort,
@@ -587,8 +591,8 @@ Torrent.prototype._onWire = function (wire, addr) {
wire.ut_metadata.fetch()
}
- // use ut_pex extension
- if (typeof ut_pex === 'function') {
+ // use ut_pex extension if the torrent is not flagged as private
+ if (typeof ut_pex === 'function' && !self.private) {
wire.use(ut_pex())
// wire.ut_pex.start() // TODO two-way communication