Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2016-08-21 05:28:08 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-08-21 05:28:08 +0300
commitd6b2d326ca7ffb21ca0812e47e3868f1af94ca0c (patch)
tree4778af2d080b2f989c532f4ab0c662263720195d /index.js
parent8bf87eb54e0486191531c25adfce8db78d513cc3 (diff)
replace 'hat' with 'randombytes'
Diffstat (limited to 'index.js')
-rw-r--r--index.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/index.js b/index.js
index b0555fb..d0b040c 100644
--- a/index.js
+++ b/index.js
@@ -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')