diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-08-21 05:28:08 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-08-21 05:28:08 +0300 |
commit | d6b2d326ca7ffb21ca0812e47e3868f1af94ca0c (patch) | |
tree | 4778af2d080b2f989c532f4ab0c662263720195d /index.js | |
parent | 8bf87eb54e0486191531c25adfce8db78d513cc3 (diff) |
replace 'hat' with 'randombytes'
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -9,13 +9,13 @@ var debug = require('debug')('webtorrent') var DHT = require('bittorrent-dht/client') // browser exclude var EventEmitter = require('events').EventEmitter var extend = require('xtend') -var hat = require('hat') var inherits = require('inherits') var loadIPSet = require('load-ip-set') // browser exclude var parallel = require('run-parallel') var parseTorrent = require('parse-torrent') var path = require('path') var Peer = require('simple-peer') +var randombytes = require('randombytes') var speedometer = require('speedometer') var zeroFill = require('zero-fill') @@ -65,7 +65,7 @@ function WebTorrent (opts) { } else if (Buffer.isBuffer(opts.peerId)) { self.peerId = opts.peerId.toString('hex') } else { - self.peerId = Buffer.from(VERSION_PREFIX + hat(48)).toString('hex') + self.peerId = Buffer.from(VERSION_PREFIX + randombytes(6).toString('hex')).toString('hex') } self.peerIdBuffer = Buffer.from(self.peerId, 'hex') @@ -74,7 +74,7 @@ function WebTorrent (opts) { } else if (Buffer.isBuffer(opts.nodeId)) { self.nodeId = opts.nodeId.toString('hex') } else { - self.nodeId = hat(160) + self.nodeId = randombytes(20).toString('hex') } self.nodeIdBuffer = Buffer.from(self.nodeId, 'hex') |