diff --git a/client.js b/client.js index 451c942..e07d265 100644 --- a/client.js +++ b/client.js @@ -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 diff --git a/lib/client/udp-tracker.js b/lib/client/udp-tracker.js index 3e3feff..4bd98a5 100644 --- a/lib/client/udp-tracker.js +++ b/lib/client/udp-tracker.js @@ -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),