From 5d7fe98c6c1134bc057c27a57333dfd1a3964e6a Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Tue, 17 Jan 2017 23:00:21 -0800 Subject: [PATCH] Set user-agent header for http tracker requests Fixes: https://github.com/feross/webtorrent/issues/962 --- lib/torrent.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/torrent.js b/lib/torrent.js index 0b695561..dc186c2d 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -52,6 +52,7 @@ var FILESYSTEM_CONCURRENCY = 2 var RECONNECT_WAIT = [ 1000, 5000, 15000 ] var VERSION = require('../package.json').version +var USER_AGENT = 'WebTorrent/' + VERSION + ' (https://webtorrent.io)' var TMP try { @@ -332,7 +333,8 @@ Torrent.prototype._onListening = function () { peerId: self.client.peerId, dht: !self.private && self.client.dht, tracker: trackerOpts, - port: self.client.torrentPort + port: self.client.torrentPort, + userAgent: USER_AGENT }) self.discovery.on('error', onError) @@ -395,7 +397,7 @@ Torrent.prototype._getMetadataFromServer = function () { url: url, method: 'GET', headers: { - 'user-agent': 'WebTorrent/' + VERSION + ' (https://webtorrent.io)' + 'user-agent': USER_AGENT } } var req