Skip to content

Commit d344537

Browse files
committed
expose client.infoHash and client.infoHashBuffer
1 parent 633f6f5 commit d344537

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

client.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ function Client (peerId, port, torrent, opts) {
4040
self._peerIdHex = self._peerId.toString('hex')
4141
self._peerIdBinary = self._peerId.toString('binary')
4242

43-
self._infoHash = typeof torrent.infoHash === 'string'
43+
self.infoHash = typeof torrent.infoHash === 'string'
4444
? torrent.infoHash
4545
: torrent.infoHash.toString('hex')
46-
self._infoHashBuffer = new Buffer(self._infoHash, 'hex')
47-
self._infoHashBinary = self._infoHashBuffer.toString('binary')
46+
self.infoHashBuffer = new Buffer(self.infoHash, 'hex')
47+
self._infoHashBinary = self.infoHashBuffer.toString('binary')
4848

4949
self.torrentLength = torrent.length
5050
self.destroyed = false
@@ -54,7 +54,7 @@ function Client (peerId, port, torrent, opts) {
5454
self._rtcConfig = opts.rtcConfig
5555
self._wrtc = opts.wrtc
5656

57-
debug('new client %s', self._infoHash)
57+
debug('new client %s', self.infoHash)
5858

5959
var webrtcSupport = !!self._wrtc || typeof window !== 'undefined'
6060

lib/client/udp-tracker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ UDPTracker.prototype._request = function (opts) {
146146
}
147147
var infoHashes = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0)
148148
? opts.infoHash.map(function (infoHash) { return infoHash.toString('hex') })
149-
: [ (opts.infoHash && opts.infoHash.toString('hex')) || self.client._infoHash ]
149+
: [ (opts.infoHash && opts.infoHash.toString('hex')) || self.client.infoHash ]
150150

151151
for (var i = 0, len = (msg.length - 8) / 12; i < len; i += 1) {
152152
self.client.emit('scrape', {
@@ -193,7 +193,7 @@ UDPTracker.prototype._request = function (opts) {
193193
connectionId,
194194
common.toUInt32(common.ACTIONS.ANNOUNCE),
195195
transactionId,
196-
self.client._infoHashBuffer,
196+
self.client.infoHashBuffer,
197197
self.client._peerId,
198198
toUInt64(opts.downloaded),
199199
opts.left != null ? toUInt64(opts.left) : new Buffer('FFFFFFFFFFFFFFFF', 'hex'),
@@ -211,7 +211,7 @@ UDPTracker.prototype._request = function (opts) {
211211

212212
var infoHash = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0)
213213
? Buffer.concat(opts.infoHash)
214-
: (opts.infoHash || self.client._infoHashBuffer)
214+
: (opts.infoHash || self.client.infoHashBuffer)
215215

216216
send(Buffer.concat([
217217
connectionId,

lib/client/websocket-tracker.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ WebSocketTracker.prototype._onSocketData = function (data) {
137137
if (data.info_hash !== self.client._infoHashBinary) {
138138
debug(
139139
'ignoring websocket data from %s for %s (looking for %s: reused socket)',
140-
self.announceUrl, common.binaryToHex(data.info_hash), self.client._infoHash
140+
self.announceUrl, common.binaryToHex(data.info_hash), self.client.infoHash
141141
)
142142
return
143143
}
@@ -149,7 +149,7 @@ WebSocketTracker.prototype._onSocketData = function (data) {
149149

150150
debug(
151151
'received %s from %s for %s',
152-
JSON.stringify(data), self.announceUrl, self.client._infoHash
152+
JSON.stringify(data), self.announceUrl, self.client.infoHash
153153
)
154154

155155
var failure = data['failure reason']

0 commit comments

Comments
 (0)