From 67518997f452617d2ba10676d14c3606ec9b7bf2 Mon Sep 17 00:00:00 2001 From: Yoann Ciabaud Date: Wed, 3 Feb 2016 09:38:31 +0100 Subject: [PATCH 1/2] Adds a getAnnounceOpts callback to forward to the tracker --- lib/torrent.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/torrent.js b/lib/torrent.js index 2cd9fd63..88ac86e1 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -90,6 +90,7 @@ function Torrent (torrentId, opts) { this.pieces = [] this._selections = [] this._critical = [] + this._getExtraAnnounceOpts = opts.getExtraAnnounceOpts // for cleanup this._servers = [] @@ -280,7 +281,15 @@ Torrent.prototype._onSwarmListening = function () { peerId: self.client.peerId, port: self.client.torrentPort, rtcConfig: self.client._rtcConfig, - wrtc: self.client._wrtc + wrtc: self.client._wrtc, + getAnnounceOpts: function () { + return { + uploaded: self.uploaded, + downloaded: self.downloaded, + left: self.length - self.downloaded, + extraAnnounceOpts: self._getExtraAnnounceOpts && self._getExtraAnnounceOpts() + } + } }) self.discovery.on('error', self._onError.bind(self)) self.discovery.on('peer', self.addPeer.bind(self)) From 372a5018da288f6cf4f5568a3da9f3739402bce2 Mon Sep 17 00:00:00 2001 From: Yoann Ciabaud Date: Wed, 3 Feb 2016 09:38:31 +0100 Subject: [PATCH 2/2] Adds a getAnnounceOpts callback to forward to the tracker --- lib/torrent.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/torrent.js b/lib/torrent.js index 2cd9fd63..88ac86e1 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -90,6 +90,7 @@ function Torrent (torrentId, opts) { this.pieces = [] this._selections = [] this._critical = [] + this._getExtraAnnounceOpts = opts.getExtraAnnounceOpts // for cleanup this._servers = [] @@ -280,7 +281,15 @@ Torrent.prototype._onSwarmListening = function () { peerId: self.client.peerId, port: self.client.torrentPort, rtcConfig: self.client._rtcConfig, - wrtc: self.client._wrtc + wrtc: self.client._wrtc, + getAnnounceOpts: function () { + return { + uploaded: self.uploaded, + downloaded: self.downloaded, + left: self.length - self.downloaded, + extraAnnounceOpts: self._getExtraAnnounceOpts && self._getExtraAnnounceOpts() + } + } }) self.discovery.on('error', self._onError.bind(self)) self.discovery.on('peer', self.addPeer.bind(self))