diff --git a/index.js b/index.js index 708571d7..6537c610 100644 --- a/index.js +++ b/index.js @@ -78,6 +78,12 @@ function WebTorrent (opts) { } self.nodeIdBuffer = Buffer.from(self.nodeId, 'hex') + if (typeof opts.userAgent === 'string') { + self.userAgent = opts.userAgent + } else { + self.userAgent = 'WebTorrent/' + VERSION + ' (https://webtorrent.io)' + } + self.destroyed = false self.listening = false self.torrentPort = opts.torrentPort || 0 diff --git a/lib/torrent.js b/lib/torrent.js index 579f3daa..95b26ad5 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -330,6 +330,7 @@ Torrent.prototype._onListening = function () { infoHash: self.infoHash, announce: self.announce, peerId: self.client.peerId, + userAgent: self.client.userAgent, dht: !self.private && self.client.dht, tracker: trackerOpts, port: self.client.torrentPort