diff --git a/package.json b/package.json index 1e22522..98762cc 100644 --- a/package.json +++ b/package.json @@ -40,25 +40,26 @@ "bl": "^1.1.2", "buffer-loader": "0.0.1", "chai": "^3.5.0", - "aegir": "^2.1.0", + "aegir": "^2.1.1", "gulp": "^3.9.1", - "istanbul": "^0.4.2", + "istanbul": "^0.4.3", "libp2p-multiplex": "^0.2.1", - "libp2p-spdy": "^0.2.3", + "libp2p-spdy": "^0.3.1", "libp2p-tcp": "^0.4.0", - "libp2p-websockets": "^0.3.1", - "multiaddr": "^1.3.0", - "peer-id": "^0.6.0", - "peer-info": "^0.6.0", + "libp2p-websockets": "^0.3.2", + "multiaddr": "^1.4.0", + "peer-id": "^0.6.6", + "peer-info": "^0.6.2", "pre-commit": "^1.1.2", "stream-pair": "^1.0.3" }, "dependencies": { "babel-runtime": "^6.6.1", "duplex-passthrough": "github:diasdavid/duplex-passthrough", - "ip-address": "^5.0.2", - "multistream-select": "^0.6.1", - "protocol-buffers-stream": "^1.2.0" + "ip-address": "^5.8.0", + "lodash.contains": "^2.4.3", + "multistream-select": "^0.6.5", + "protocol-buffers-stream": "^1.3.1" }, "aegir": { "webpack": { diff --git a/src/index.js b/src/index.js index 89ca24c..a6b1bfe 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,7 @@ const multistream = require('multistream-select') const identify = require('./identify') const DuplexPassThrough = require('duplex-passthrough') +const contains = require('lodash.contains') exports = module.exports = Swarm @@ -87,7 +88,16 @@ function Swarm (peerInfo) { // if no callback is passed, we pass conns to connHandler if (!handler) { handler = connHandler } - const multiaddrs = this.transports[key].filter(peerInfo.multiaddrs) + const multiaddrs = this.transports[key].filter( + peerInfo.multiaddrs.map((addr) => { + // ipfs multiaddrs are not dialable so we drop them here + if (contains(addr.protoNames(), 'ipfs')) { + return addr.decapsulate('ipfs') + } + + return addr + }) + ) this.transports[key].createListener(multiaddrs, handler, (err, maUpdate) => { if (err) { diff --git a/test/08-swarm-without-muxing.node.js b/test/08-swarm-without-muxing.node.js index 4195058..142dc42 100644 --- a/test/08-swarm-without-muxing.node.js +++ b/test/08-swarm-without-muxing.node.js @@ -21,7 +21,7 @@ describe('high level API - 1st without stream multiplexing (on TCP)', function ( peerB = new Peer() peerA.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/9001')) - peerB.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/9002')) + peerB.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/9002/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC')) swarmA = new Swarm(peerA) swarmB = new Swarm(peerB)