mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-31 10:31:36 +00:00
expose client.peerId
and client.peerIdBuffer
This commit is contained in:
parent
7980e264da
commit
177171b82c
@ -34,11 +34,11 @@ function Client (peerId, port, torrent, opts) {
|
|||||||
if (!opts) opts = {}
|
if (!opts) opts = {}
|
||||||
|
|
||||||
// required
|
// required
|
||||||
self._peerId = Buffer.isBuffer(peerId)
|
self.peerId = typeof peerId === 'string'
|
||||||
? peerId
|
? peerId
|
||||||
: new Buffer(peerId, 'hex')
|
: peerId.toString('hex')
|
||||||
self._peerIdHex = self._peerId.toString('hex')
|
self.peerIdBuffer = new Buffer(self.peerId, 'hex')
|
||||||
self._peerIdBinary = self._peerId.toString('binary')
|
self._peerIdBinary = self.peerIdBuffer.toString('binary')
|
||||||
|
|
||||||
self.infoHash = typeof torrent.infoHash === 'string'
|
self.infoHash = typeof torrent.infoHash === 'string'
|
||||||
? torrent.infoHash
|
? torrent.infoHash
|
||||||
|
@ -194,7 +194,7 @@ UDPTracker.prototype._request = function (opts) {
|
|||||||
common.toUInt32(common.ACTIONS.ANNOUNCE),
|
common.toUInt32(common.ACTIONS.ANNOUNCE),
|
||||||
transactionId,
|
transactionId,
|
||||||
self.client.infoHashBuffer,
|
self.client.infoHashBuffer,
|
||||||
self.client._peerId,
|
self.client.peerIdBuffer,
|
||||||
toUInt64(opts.downloaded),
|
toUInt64(opts.downloaded),
|
||||||
opts.left != null ? toUInt64(opts.left) : new Buffer('FFFFFFFFFFFFFFFF', 'hex'),
|
opts.left != null ? toUInt64(opts.left) : new Buffer('FFFFFFFFFFFFFFFF', 'hex'),
|
||||||
toUInt64(opts.uploaded),
|
toUInt64(opts.uploaded),
|
||||||
|
Loading…
Reference in New Issue
Block a user