Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

torrent-discovery

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

torrent-discovery - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

26

index.js

@@ -28,2 +28,6 @@ module.exports = Discovery

self.infoHash = null
self.infoHashHex = null
self.torrent = null
self._externalDHT = typeof self.dht === 'object'

@@ -40,13 +44,19 @@ self._performedDHTLookup = false

var self = this
if (self.torrent) return
if (torrent && torrent.infoHash) {
if (!self.infoHash && Buffer.isBuffer(torrent) || typeof torrent === 'string') {
self.infoHash = typeof torrent === 'string'
? new Buffer(torrent, 'hex')
: torrent
} else if (!self.torrent && torrent && torrent.infoHash) {
self.torrent = torrent
self.infoHash = torrent.infoHash
self.infoHash = typeof torrent.infoHash === 'string'
? new Buffer(torrent.infoHash, 'hex')
: torrent.infoHash
} else {
if (self.infoHash) return
self.infoHash = torrent
return
}
debug('setTorrent %s', self.infoHash)
self.infoHashHex = self.infoHash.toString('hex')
debug('setTorrent %s', self.infoHashHex)
// If tracker exists, then it was created with just infoHash. Set torrent length

@@ -82,3 +92,3 @@ // so client can report correct information about uploads.

self.dht.on('peer', function (addr, infoHash) {
if (infoHash === self.infoHash) self.emit('peer', addr)
if (infoHash === self.infoHashHex) self.emit('peer', addr)
})

@@ -93,3 +103,3 @@ if (!self._externalDHT) self.dht.listen(port)

var torrent = self.torrent || {
infoHash: self.infoHash,
infoHash: self.infoHashHex,
announce: self.announce

@@ -96,0 +106,0 @@ }

{
"name": "torrent-discovery",
"description": "Discover BitTorrent and WebTorrent peers",
"version": "3.0.2",
"version": "3.0.3",
"author": {

@@ -6,0 +6,0 @@ "name": "Feross Aboukhadijeh",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc