From c5429d697aaf4b26fa9f7b0d37eb33843882558c Mon Sep 17 00:00:00 2001 From: nkittsteiner Date: Thu, 5 May 2016 23:59:30 -0300 Subject: [PATCH 1/2] WIP running tests for changes in opts --- index.js | 8 +++++--- lib/torrent.js | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 29478884..3e9dc783 100644 --- a/index.js +++ b/index.js @@ -68,12 +68,14 @@ function WebTorrent (opts) { self.listening = false self.torrentPort = opts.torrentPort || 0 self.dhtPort = opts.dhtPort || 0 - self.tracker = opts.tracker !== undefined ? opts.tracker : true + self.tracker = opts.tracker !== undefined ? opts.tracker : {} self.torrents = [] self.maxConns = Number(opts.maxConns) || 55 - self._rtcConfig = opts.rtcConfig - self._wrtc = opts.wrtc || global.WRTC // to support `webtorrent-hybrid` package + if (typeof self.tracker === 'object') { + self.tracker.rtcConfig = opts.rtcConfig + self.tracker.wrtc = opts.wrtc || global.WRTC // to support `webtorrent-hybrid` package + } if (typeof TCPPool === 'function') { self._tcpPool = new TCPPool(self) diff --git a/lib/torrent.js b/lib/torrent.js index 810e10d6..b335cb9f 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -292,8 +292,8 @@ Torrent.prototype._onListening = function () { var self = this if (self.discovery || self.destroyed) return var trackerOpts = { - rtcConfig: self.client._rtcConfig, - wrtc: self.client._wrtc, + rtcConfig: self.client.tracker.rtcConfig, + wrtc: self.client.tracker.wrtc, getAnnounceOpts: function () { var opts = { uploaded: self.uploaded, From 5375ea4810159423090ec853375d8f80b085b3ee Mon Sep 17 00:00:00 2001 From: nkittsteiner Date: Fri, 6 May 2016 21:52:08 -0300 Subject: [PATCH 2/2] Changing documentation, deleting wrtc and rtcConfig opts --- docs/api.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/api.md b/docs/api.md index a4ebe55e..f8f08067 100644 --- a/docs/api.md +++ b/docs/api.md @@ -51,16 +51,18 @@ If `opts` is specified, then the default options (shown below) will be overridde ```js { - dht: Boolean|Object, // Enable DHT (default=true), or options object for DHT - maxConns: Number, // Max number of connections per torrent (default=55) - nodeId: String|Buffer, // DHT protocol node ID (default=randomly generated) - peerId: String|Buffer, // Wire protocol peer ID (default=randomly generated) - rtcConfig: Object, // RTCPeerConnection configuration object (default=STUN only) - tracker: Boolean, // Whether or not to enable trackers (default=true) - wrtc: Object // Custom webrtc implementation (in node, specify the [wrtc](https://www.npmjs.com/package/wrtc) or [electron-webrtc](https://github.com/mappum/electron-webrtc) package) + dht: Boolean|Object, // Enable DHT (default=true), or options object for DHT + maxConns: Number, // Max number of connections per torrent (default=55) + nodeId: String|Buffer, // DHT protocol node ID (default=randomly generated) + peerId: String|Buffer, // Wire protocol peer ID (default=randomly generated) + tracker: Boolean|Object, // Enable trackers (default=true), or options object for tracker (wrtc and rtcConfig) } ``` ++ See the documentation for webrtc implementation (in node, specify the [wrtc](https://www.npmjs.com/package/wrtc) ++ or [electron-webrtc](https://github.com/mappum/electron-webrtc) package) for information on what options are available ++ via the `opts` object. + ## `client.add(torrentId, [opts], [function ontorrent (torrent) {}])` Start downloading a new torrent.