mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 20:21:36 +00:00
Changed infoHash to always be hex
This commit is contained in:
parent
da760b08f2
commit
ab3482fc4f
@ -40,11 +40,11 @@ function Client (peerId, port, torrent, opts) {
|
||||
self._peerIdHex = self._peerId.toString('hex')
|
||||
self._peerIdBinary = self._peerId.toString('binary')
|
||||
|
||||
self._infoHash = Buffer.isBuffer(torrent.infoHash)
|
||||
self._infoHashBuffer = Buffer.isBuffer(torrent.infoHash)
|
||||
? torrent.infoHash
|
||||
: new Buffer(torrent.infoHash, 'hex')
|
||||
self._infoHashHex = self._infoHash.toString('hex')
|
||||
self._infoHashBinary = self._infoHash.toString('binary')
|
||||
self._infoHash = self._infoHashBuffer.toString('hex')
|
||||
self._infoHashBinary = self._infoHashBuffer.toString('binary')
|
||||
|
||||
self.torrentLength = torrent.length
|
||||
self.destroyed = false
|
||||
@ -54,7 +54,7 @@ function Client (peerId, port, torrent, opts) {
|
||||
self._rtcConfig = opts.rtcConfig
|
||||
self._wrtc = opts.wrtc
|
||||
|
||||
debug('new client %s', self._infoHashHex)
|
||||
debug('new client %s', self._infoHash)
|
||||
|
||||
var webrtcSupport = !!self._wrtc || typeof window !== 'undefined'
|
||||
|
||||
|
@ -68,7 +68,7 @@ HTTPTracker.prototype.scrape = function (opts) {
|
||||
? opts.infoHash.map(function (infoHash) {
|
||||
return infoHash.toString('binary')
|
||||
})
|
||||
: (opts.infoHash || self.client._infoHash).toString('binary')
|
||||
: (opts.infoHash || self.client._infoHashBuffer).toString('binary')
|
||||
var params = {
|
||||
info_hash: infoHashes
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ UDPTracker.prototype._request = function (opts) {
|
||||
}
|
||||
var infoHashes = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0)
|
||||
? opts.infoHash.map(function (infoHash) { return infoHash.toString('hex') })
|
||||
: (opts.infoHash || self.client._infoHash).toString('hex')
|
||||
: (opts.infoHash || self.client._infoHashBuffer).toString('hex')
|
||||
|
||||
for (var i = 0, len = (msg.length - 8) / 12; i < len; i += 1) {
|
||||
self.client.emit('scrape', {
|
||||
@ -193,7 +193,7 @@ UDPTracker.prototype._request = function (opts) {
|
||||
connectionId,
|
||||
common.toUInt32(common.ACTIONS.ANNOUNCE),
|
||||
transactionId,
|
||||
self.client._infoHash,
|
||||
self.client._infoHashBuffer,
|
||||
self.client._peerId,
|
||||
toUInt64(opts.downloaded),
|
||||
opts.left != null ? toUInt64(opts.left) : new Buffer('FFFFFFFFFFFFFFFF', 'hex'),
|
||||
@ -211,7 +211,7 @@ UDPTracker.prototype._request = function (opts) {
|
||||
|
||||
var infoHash = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0)
|
||||
? Buffer.concat(opts.infoHash)
|
||||
: (opts.infoHash || self.client._infoHash)
|
||||
: (opts.infoHash || self.client._infoHashBuffer)
|
||||
|
||||
send(Buffer.concat([
|
||||
connectionId,
|
||||
|
@ -137,7 +137,7 @@ WebSocketTracker.prototype._onSocketData = function (data) {
|
||||
if (data.info_hash !== self.client._infoHashBinary) {
|
||||
debug(
|
||||
'ignoring websocket data from %s for %s (looking for %s: reused socket)',
|
||||
self.announceUrl, common.binaryToHex(data.info_hash), self.client._infoHashHex
|
||||
self.announceUrl, common.binaryToHex(data.info_hash), self.client._infoHash
|
||||
)
|
||||
return
|
||||
}
|
||||
@ -149,7 +149,7 @@ WebSocketTracker.prototype._onSocketData = function (data) {
|
||||
|
||||
debug(
|
||||
'received %s from %s for %s',
|
||||
JSON.stringify(data), self.announceUrl, self.client._infoHashHex
|
||||
JSON.stringify(data), self.announceUrl, self.client._infoHash
|
||||
)
|
||||
|
||||
var failure = data['failure reason']
|
||||
|
Loading…
Reference in New Issue
Block a user