discovery-swarm
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -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": { |
36
test.js
@@ -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}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26931
623