mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-18 20:21:36 +00:00
replace hat with randombytes
This commit is contained in:
parent
fbca6f20d7
commit
a35f1f8178
@ -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) {
|
||||
|
@ -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,
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user