diff --git a/lib/client/udp-tracker.js b/lib/client/udp-tracker.js index 665fc8b..b9ccbb2 100644 --- a/lib/client/udp-tracker.js +++ b/lib/client/udp-tracker.js @@ -5,8 +5,8 @@ var Buffer = require('safe-buffer').Buffer var compact2string = require('compact2string') var debug = require('debug')('bittorrent-tracker:udp-tracker') var dgram = require('dgram') -var hat = require('hat') var inherits = require('inherits') +var randombytes = require('randombytes') var url = require('url') var common = require('../common') @@ -224,7 +224,7 @@ UDPTracker.prototype._request = function (opts) { } function genTransactionId () { - return Buffer.from(hat(32), 'hex') + return randombytes(4) } function toUInt16 (n) { diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index c1095b8..b0aa6b5 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -2,9 +2,9 @@ module.exports = WebSocketTracker var debug = require('debug')('bittorrent-tracker:websocket-tracker') var extend = require('xtend') -var hat = require('hat') var inherits = require('inherits') var Peer = require('simple-peer') +var randombytes = require('randombytes') var Socket = require('simple-websocket') var common = require('../common') @@ -369,7 +369,7 @@ WebSocketTracker.prototype._generateOffers = function (numwant, cb) { checkDone() function generateOffer () { - var offerId = hat(160) + var offerId = randombytes(20).toString('hex') debug('creating peer (from _generateOffers)') var peer = self.peers[offerId] = new Peer({ initiator: true, diff --git a/package.json b/package.json index 54b7b00..d8059fb 100644 --- a/package.json +++ b/package.json @@ -25,13 +25,13 @@ "bn.js": "^4.4.0", "compact2string": "^1.2.0", "debug": "^2.0.0", - "hat": "0.0.3", "inherits": "^2.0.1", "ip": "^1.0.1", "lru": "^3.0.0", "minimist": "^1.1.1", "once": "^1.3.0", "random-iterate": "^1.0.1", + "randombytes": "^2.0.3", "run-parallel": "^1.1.2", "run-series": "^1.0.2", "safe-buffer": "^5.0.0",