diff --git a/lib/torrent.js b/lib/torrent.js index 8f667ffe..6c744274 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -72,6 +72,7 @@ class Torrent extends EventEmitter { this.skipVerify = !!opts.skipVerify this._store = opts.store || FSChunkStore this._getAnnounceOpts = opts.getAnnounceOpts + this._getWebseedOpts = opts.getWebseedOpts this.strategy = opts.strategy || 'sequential' diff --git a/lib/webconn.js b/lib/webconn.js index 9c2b461d..33ed0c9a 100644 --- a/lib/webconn.js +++ b/lib/webconn.js @@ -110,7 +110,7 @@ class WebConn extends Wire { 'Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d', url, pieceIndex, offset, length, start, end ) - const opts = { + let opts = { url, method: 'GET', headers: { @@ -118,6 +118,9 @@ class WebConn extends Wire { range: `bytes=${start}-${end}` } } + if (this._torrent._getWebseedOpts) { + opts = this._torrent._getWebseedOpts(opts) + } function onResponse (res, data) { if (res.statusCode < 200 || res.statusCode >= 300) { hasError = true