replace hat with randombytes

This commit is contained in:
Feross Aboukhadijeh 2016-08-20 19:37:36 -07:00
parent fbca6f20d7
commit a35f1f8178
3 changed files with 5 additions and 5 deletions

View File

@ -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) {

View File

@ -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,

View File

@ -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",