expose client.peerId and client.peerIdBuffer

This commit is contained in:
Feross Aboukhadijeh 2015-12-02 22:33:15 -08:00
parent 7980e264da
commit 177171b82c
2 changed files with 5 additions and 5 deletions

View File

@ -34,11 +34,11 @@ function Client (peerId, port, torrent, opts) {
if (!opts) opts = {}
// required
self._peerId = Buffer.isBuffer(peerId)
self.peerId = typeof peerId === 'string'
? peerId
: new Buffer(peerId, 'hex')
self._peerIdHex = self._peerId.toString('hex')
self._peerIdBinary = self._peerId.toString('binary')
: peerId.toString('hex')
self.peerIdBuffer = new Buffer(self.peerId, 'hex')
self._peerIdBinary = self.peerIdBuffer.toString('binary')
self.infoHash = typeof torrent.infoHash === 'string'
? torrent.infoHash

View File

@ -194,7 +194,7 @@ UDPTracker.prototype._request = function (opts) {
common.toUInt32(common.ACTIONS.ANNOUNCE),
transactionId,
self.client.infoHashBuffer,
self.client._peerId,
self.client.peerIdBuffer,
toUInt64(opts.downloaded),
opts.left != null ? toUInt64(opts.left) : new Buffer('FFFFFFFFFFFFFFFF', 'hex'),
toUInt64(opts.uploaded),