diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-05-08 20:21:42 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-05-08 20:21:42 +0300 |
commit | 47d181f809bf19b669c62457f7e8b45d72246b21 (patch) | |
tree | 59c41144fb16a3b8560d5b88ff78ed32ee006509 /lib/torrent.js | |
parent | 587f3adaf83c761c8cea30d62d3e68bc359ab31d (diff) |
Move tracker options into `opts.tracker`
Closes #649
Based on a PR by @nkittsteiner. #791
Diffstat (limited to 'lib/torrent.js')
-rw-r--r-- | lib/torrent.js | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index 810e10d..e29c38f 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -202,10 +202,10 @@ Object.defineProperty(Torrent.prototype, '_numConns', { } }) -// TODO: remove in v2 +// TODO: remove in v1 Object.defineProperty(Torrent.prototype, 'swarm', { get: function () { - console.log('WebTorrent: `torrent.swarm` is deprecated. Use `torrent` directly instead.') + console.warn('WebTorrent: `torrent.swarm` is deprecated. Use `torrent` directly instead.') return this } }) @@ -291,18 +291,26 @@ Torrent.prototype._processParsedTorrent = function (parsedTorrent) { Torrent.prototype._onListening = function () { var self = this if (self.discovery || self.destroyed) return - var trackerOpts = { - rtcConfig: self.client._rtcConfig, - wrtc: self.client._wrtc, - getAnnounceOpts: function () { - var opts = { - uploaded: self.uploaded, - downloaded: self.downloaded, - left: Math.max(self.length - self.downloaded, 0) + + var trackerOpts = self.client.tracker + if (trackerOpts) { + trackerOpts = extend(self.client.tracker, { + getAnnounceOpts: function () { + var opts = { + uploaded: self.uploaded, + downloaded: self.downloaded, + left: Math.max(self.length - self.downloaded, 0) + } + if (self.client.tracker.getAnnounceOpts) { + extendMutable(opts, self.client.tracker.getAnnounceOpts()) + } + if (self._getAnnounceOpts) { + // TODO: consider deprecating this, as it's redundant with the former case + extendMutable(opts, self._getAnnounceOpts()) + } + return opts } - if (self._getAnnounceOpts) opts = extend(opts, self._getAnnounceOpts()) - return opts - } + }) } // begin discovering peers via DHT and trackers @@ -311,7 +319,7 @@ Torrent.prototype._onListening = function () { announce: self.announce, peerId: self.client.peerId, dht: !self.private && self.client.dht, - tracker: self.client.tracker && trackerOpts, + tracker: trackerOpts, port: self.client.torrentPort }) |