Skip to content

Commit 177171b

Browse files
committed
expose client.peerId and client.peerIdBuffer
1 parent 7980e26 commit 177171b

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

client.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ function Client (peerId, port, torrent, opts) {
3434
if (!opts) opts = {}
3535

3636
// required
37-
self._peerId = Buffer.isBuffer(peerId)
37+
self.peerId = typeof peerId === 'string'
3838
? peerId
39-
: new Buffer(peerId, 'hex')
40-
self._peerIdHex = self._peerId.toString('hex')
41-
self._peerIdBinary = self._peerId.toString('binary')
39+
: peerId.toString('hex')
40+
self.peerIdBuffer = new Buffer(self.peerId, 'hex')
41+
self._peerIdBinary = self.peerIdBuffer.toString('binary')
4242

4343
self.infoHash = typeof torrent.infoHash === 'string'
4444
? torrent.infoHash

lib/client/udp-tracker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ UDPTracker.prototype._request = function (opts) {
194194
common.toUInt32(common.ACTIONS.ANNOUNCE),
195195
transactionId,
196196
self.client.infoHashBuffer,
197-
self.client._peerId,
197+
self.client.peerIdBuffer,
198198
toUInt64(opts.downloaded),
199199
opts.left != null ? toUInt64(opts.left) : new Buffer('FFFFFFFFFFFFFFFF', 'hex'),
200200
toUInt64(opts.uploaded),

0 commit comments

Comments
 (0)