New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bittorrent-dht

Package Overview
Dependencies
Maintainers
1
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bittorrent-dht - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

40

client.js

@@ -322,6 +322,2 @@ module.exports = DHT

self._addNode(addr, nodeId)
process.nextTick(function () {
// TODO: only emit this event for new nodes
self.emit('node', addr, nodeId, addr)
})
}

@@ -335,7 +331,7 @@

* @param {string=} from addr
* @return {boolean} was the node valid and added to the table
* @return {boolean} was the node valid and new and added to the table
*/
DHT.prototype._addNode = function (addr, nodeId, from) {
var self = this
if (self.destroyed) return false
if (self.destroyed) return
nodeId = idToBuffer(nodeId)

@@ -345,3 +341,3 @@

self._debug('skipping addNode %s %s; invalid id length', addr, idToHexString(nodeId))
return false
return
}

@@ -351,13 +347,18 @@

self._debug('skip addNode %s %s; that is us!', addr, idToHexString(nodeId))
return false
return
}
var contact = {
var existing = self.nodes.get(nodeId)
if (existing && existing.addr === addr) return
self.nodes.add({
id: nodeId,
addr: addr
}
self.nodes.add(contact)
})
process.nextTick(function () {
self.emit('node', addr, nodeId, from)
})
self._debug('addNode %s %s discovered from %s', idToHexString(nodeId), addr, from)
return true
}

@@ -458,4 +459,3 @@

.forEach(function (contact) {
var valid = self._addNode(contact.addr, contact.id, contact.from)
if (valid) self.emit('node', contact.addr, contact.id, contact.from)
self._addNode(contact.addr, contact.id, contact.from)
})

@@ -715,5 +715,3 @@

// self._debug('adding (potentially) new node %s %s', idToHexString(nodeId), addr)
var valid = self._addNode(addr, nodeId, addr)
// TODO: only emit this event for new nodes
if (valid) self.emit('node', addr, nodeId, addr)
self._addNode(addr, nodeId, addr)
}

@@ -874,5 +872,3 @@

res.nodes.forEach(function (node) {
var valid = self._addNode(node.addr, node.id, addr)
// TODO: only emit this event for new nodes
if (valid) self.emit('node', node.addr, node.id, addr)
self._addNode(node.addr, node.id, addr)
})

@@ -943,5 +939,3 @@ }

res.nodes.forEach(function (node) {
var valid = self._addNode(node.addr, node.id, addr)
// TODO: only emit this event for new nodes
if (valid) self.emit('node', node.addr, node.id, addr)
self._addNode(node.addr, node.id, addr)
})

@@ -948,0 +942,0 @@ }

{
"name": "bittorrent-dht",
"description": "Simple, robust, BitTorrent DHT implementation",
"version": "3.1.1",
"version": "3.2.0",
"author": {

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

@@ -81,1 +81,20 @@ var common = require('./common')

})
test('`addNode` only emits events for new nodes', function (t) {
t.plan(1)
var dht = new DHT({ bootstrap: false })
common.failOnWarningOrError(t, dht)
dht.on('node', function () {
if (--togo < 0) t.fail()
})
var nodeId = common.randomId()
dht.addNode('127.0.0.1:9999', nodeId)
dht.addNode('127.0.0.1:9999', nodeId)
dht.addNode('127.0.0.1:9999', nodeId)
var togo = 1
setTimeout(t.pass(), 100)
})
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