Compare commits

..

9 Commits

Author SHA1 Message Date
David Dias
a579ff818a chore: release version v0.19.5 2016-05-30 15:25:22 +01:00
David Dias
6fa9dfc2f5 chore: update contributors 2016-05-30 15:25:22 +01:00
David Dias
cad6d04295 update aegir 2016-05-30 15:18:10 +01:00
David Dias
215fa08cc8 Merge pull request #72 from diasdavid/fix/spdy-blows-up
fix: Uncaught Error: socket hang up
2016-05-30 15:17:31 +01:00
David Dias
834a15ddca propagete error and close events properly 2016-05-30 15:05:57 +01:00
David Dias
33172f5850 chore: release version v0.19.4 2016-05-29 10:40:09 +01:00
David Dias
6519e0ebd7 chore: update contributors 2016-05-29 10:40:09 +01:00
David Dias
8341249aa6 Merge pull request #71 from diasdavid/fix/lost-getObservedAddrs-call
if there more than a multiaddr option, we would lose the ability to call getObservedAddrs
2016-05-29 10:33:38 +01:00
David Dias
4eed2700b0 if there more than a multiaddr option, we would lose the ability to call getObservedAddrs 2016-05-29 10:21:56 +01:00
5 changed files with 43 additions and 11 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "libp2p-swarm",
"version": "0.19.3",
"version": "0.19.5",
"description": "libp2p swarm implementation in JavaScript",
"main": "lib/index.js",
"jsnext:main": "src/index.js",
@@ -37,7 +37,7 @@
"node": "^4.3.0"
},
"devDependencies": {
"aegir": "^3.0.4",
"aegir": "^3.2.0",
"bl": "^1.1.2",
"buffer-loader": "0.0.1",
"chai": "^3.5.0",
@@ -55,7 +55,7 @@
"dependencies": {
"babel-runtime": "^6.6.1",
"browserify-zlib": "github:ipfs/browserify-zlib",
"duplex-passthrough": "github:diasdavid/duplex-passthrough",
"duplexify": "^3.4.3",
"ip-address": "^5.8.0",
"lodash.contains": "^2.4.3",
"multiaddr": "^2.0.0",

View File

@@ -27,6 +27,7 @@ module.exports = function connection (swarm) {
}
}
// If identify happened, when we have the Id of the conn
if (swarm.identify) {
return gotId()
}

View File

@@ -1,7 +1,7 @@
'use strict'
const multistream = require('multistream-select')
const DuplexPassThrough = require('duplex-passthrough')
const Duplexify = require('duplexify')
const connHandler = require('./default-handler')
@@ -16,7 +16,7 @@ module.exports = function dial (swarm) {
callback = function noop () {}
}
const pt = new DuplexPassThrough()
const pt = new Duplexify()
const b58Id = pi.id.toB58String()
@@ -169,7 +169,8 @@ module.exports = function dial (swarm) {
return callback(err)
}
pt.wrapStream(conn)
pt.setReadable(conn)
pt.setWritable(conn)
pt.peerId = pi.id
callback(null, pt)
})

View File

@@ -1,7 +1,7 @@
'use strict'
const contains = require('lodash.contains')
const DuplexPassThrough = require('duplex-passthrough')
const Duplexify = require('duplexify')
const connHandler = require('./default-handler')
@@ -47,13 +47,15 @@ module.exports = function (swarm) {
// c) multiaddrs should already be a filtered list
// specific for the transport we are using
const pt = new DuplexPassThrough()
const pt = new Duplexify()
next(multiaddrs.shift())
return pt
function next (multiaddr) {
const conn = t.dial(multiaddr, {ready: () => {
pt.wrapStream(conn)
pt.setReadable(conn)
pt.setWritable(conn)
pt.getObservedAddrs = conn.getObservedAddrs.bind(conn)
const cb = callback
callback = noop // this is done to avoid connection drops as connect errors
cb(null, pt)

View File

@@ -19,11 +19,14 @@ describe('stream muxing with spdy (on TCP)', function () {
var peerB
var swarmC
var peerC
var swarmD
var peerD
before((done) => {
peerA = new Peer()
peerB = new Peer()
peerC = new Peer()
peerD = new Peer()
// console.log('peer A', peerA.id.toB58String())
// console.log('peer B', peerB.id.toB58String())
@@ -32,27 +35,32 @@ describe('stream muxing with spdy (on TCP)', function () {
peerA.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/9001'))
peerB.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/9002'))
peerC.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/9003'))
peerD.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/9004'))
swarmA = new Swarm(peerA)
swarmB = new Swarm(peerB)
swarmC = new Swarm(peerC)
swarmD = new Swarm(peerD)
swarmA.transport.add('tcp', new TCP())
swarmB.transport.add('tcp', new TCP())
swarmC.transport.add('tcp', new TCP())
swarmD.transport.add('tcp', new TCP())
parallel([
(cb) => swarmA.transport.listen('tcp', {}, null, cb),
(cb) => swarmB.transport.listen('tcp', {}, null, cb),
(cb) => swarmC.transport.listen('tcp', {}, null, cb)
(cb) => swarmC.transport.listen('tcp', {}, null, cb),
(cb) => swarmD.transport.listen('tcp', {}, null, cb)
], done)
})
after((done) => {
parallel([
(cb) => swarmA.close(cb),
(cb) => swarmB.close(cb)
(cb) => swarmB.close(cb),
// (cb) => swarmC.close(cb)
(cb) => swarmD.close(cb)
], done)
})
@@ -60,6 +68,7 @@ describe('stream muxing with spdy (on TCP)', function () {
swarmA.connection.addStreamMuxer(spdy)
swarmB.connection.addStreamMuxer(spdy)
swarmC.connection.addStreamMuxer(spdy)
swarmD.connection.addStreamMuxer(spdy)
})
it('handle + dial on protocol', (done) => {
@@ -116,6 +125,25 @@ describe('stream muxing with spdy (on TCP)', function () {
})
})
it('leave a stream open, make sure it does not blow up when the socket is closed', (done) => {
swarmD.connection.reuse()
let count = 0
const destroyed = () => ++count === 2 ? done() : null
swarmD.handle('/banana/1.0.0', (conn) => {
conn.on('error', destroyed)
conn.pipe(conn)
})
swarmA.dial(peerD, '/banana/1.0.0', (err, conn) => {
expect(err).to.not.exist
conn.on('error', destroyed)
swarmD.muxedConns[peerA.id.toB58String()].conn.destroy()
})
})
it('close one end, make sure the other does not blow', (done) => {
swarmC.close((err) => {
if (err) throw err