diff options
author | John Hiesey <john@hiesey.com> | 2021-04-09 07:08:51 +0300 |
---|---|---|
committer | John Hiesey <john@hiesey.com> | 2021-04-09 07:08:51 +0300 |
commit | dddd652ac29eb6547761bb84a8d6c624bc1152bd (patch) | |
tree | 60547fca1e413b4a91b4eefe07e8bb958fb8cc48 /lib/torrent.js | |
parent | 9f415f812e99de2f6b9d74e0c0841c9a10d8904a (diff) |
Add lt_donthave
Diffstat (limited to 'lib/torrent.js')
-rw-r--r-- | lib/torrent.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index ca58842..c87c079 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -11,6 +11,7 @@ const fs = require('fs') const FSChunkStore = require('fs-chunk-store') // browser: `memory-chunk-store` const get = require('simple-get') const ImmediateChunkStore = require('immediate-chunk-store') +const ltDontHave = require('lt_donthave') const MultiStream = require('multistream') const net = require('net') // browser exclude const os = require('os') // browser exclude @@ -1012,7 +1013,9 @@ class Torrent extends EventEmitter { }) // Timeout for piece requests to this peer - wire.setTimeout(PIECE_TIMEOUT, true) + if (wire.type !== 'webSeed') { // webseeds always send 'unhave' on http timeout + wire.setTimeout(PIECE_TIMEOUT, true) + } // Send KEEP-ALIVE (every 60s) so peers will not disconnect the wire wire.setKeepAlive(true) @@ -1059,6 +1062,8 @@ class Torrent extends EventEmitter { }) } + wire.use(ltDontHave()) + // Hook to allow user-defined `bittorrent-protocol` extensions // More info: https://github.com/webtorrent/bittorrent-protocol#extension-api this.emit('wire', wire, addr) @@ -1109,6 +1114,12 @@ class Torrent extends EventEmitter { this._updateWireInterest(wire) }) + wire.lt_donthave.on('donthave', () => { + updateSeedStatus() + this._update() + this._updateWireInterest(wire) + }) + wire.once('interested', () => { wire.unchoke() }) |