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

discovery-swarm

Package Overview
Dependencies
Maintainers
4
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discovery-swarm - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0

9

index.js

@@ -63,5 +63,3 @@ var discovery = require('discovery-channel')

var type = this === self._tcp ? 'tcp' : 'utp'
var ip = connection.remoteAddress || connection.address().address
var port = this.address().port
debug('inbound connection type=%s ip=%s:%d', type, ip, port)
debug('inbound connection type=%s ip=%s:%d', type, connection.remoteAddress, connection.remotePort)
connection.on('error', onerror)

@@ -92,2 +90,3 @@ self.totalConnections++

}
this._utp.unref()
}

@@ -342,4 +341,4 @@

id: null,
host: peer ? peer.host : connection.address().address,
port: peer ? peer.port : connection.address().port,
host: peer ? peer.host : connection.remoteAddress,
port: peer ? peer.port : connection.remotePort,
channel: peer ? peer.channel : null

@@ -346,0 +345,0 @@ }

{
"name": "discovery-swarm",
"version": "5.0.0",
"version": "5.1.0",
"description": "A network swarm that uses discovery-channel to find peers",

@@ -16,3 +16,3 @@ "main": "index.js",

"optionalDependencies": {
"utp-native": "^1.2.2"
"utp-native": "^1.7.0"
},

@@ -19,0 +19,0 @@ "devDependencies": {

@@ -39,7 +39,9 @@ var test = require('tape')

test('two swarms connect and exchange data', function (t) {
test('two swarms connect and exchange data (tcp)', function (t) {
var a = swarm({dht: false, utp: false})
var b = swarm({dht: false, utp: false})
a.on('connection', function (connection) {
a.on('connection', function (connection, info) {
t.ok(info.host && typeof info.host === 'string', 'got info.host')
t.ok(info.port && typeof info.port === 'number', 'got info.port')
connection.write('hello')

@@ -54,3 +56,5 @@ connection.on('data', function (data) {

b.on('connection', function (connection) {
b.on('connection', function (connection, info) {
t.ok(info.host && typeof info.host === 'string', 'got info.host')
t.ok(info.port && typeof info.port === 'number', 'got info.port')
connection.pipe(connection)

@@ -63,2 +67,28 @@ })

test('two swarms connect and exchange data (utp)', function (t) {
var a = swarm({dht: false, tcp: false})
var b = swarm({dht: false, tcp: false})
a.on('connection', function (connection, info) {
t.ok(info.host && typeof info.host === 'string', 'got info.host')
t.ok(info.port && typeof info.port === 'number', 'got info.port')
connection.write('hello')
connection.on('data', function (data) {
a.destroy()
b.destroy()
t.same(data, Buffer('hello'))
t.end()
})
})
b.on('connection', function (connection, info) {
t.ok(info.host && typeof info.host === 'string', 'got info.host')
t.ok(info.port && typeof info.port === 'number', 'got info.port')
connection.pipe(connection)
})
a.join('test')
b.join('test')
})
test('two swarms connect and callback', function (t) {

@@ -65,0 +95,0 @@ var a = swarm({dht: false, utp: false})

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