mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-14 08:11:36 +00:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
20108d2de8 | |||
15fcfb737c | |||
0fa14c9608 | |||
ac7c8a150e | |||
851c8ee2a3 | |||
7a3f9d08d5 |
33
package.json
33
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "libp2p-swarm",
|
||||
"version": "0.10.5",
|
||||
"version": "0.10.6",
|
||||
"description": "libp2p swarm implementation in JavaScript",
|
||||
"main": "lib/index.js",
|
||||
"jsnext:main": "src/index.js",
|
||||
@ -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": {
|
||||
@ -68,5 +69,13 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"contributors": [
|
||||
"David Dias <daviddias.p@gmail.com>",
|
||||
"David Dias <mail@daviddias.me>",
|
||||
"Francisco Baio Dias <xicombd@gmail.com>",
|
||||
"Pau Ramon Revilla <masylum@gmail.com>",
|
||||
"Richard Littauer <richard.littauer@gmail.com>",
|
||||
"dignifiedquire <dignifiedquire@gmail.com>"
|
||||
]
|
||||
}
|
||||
|
@ -14,11 +14,7 @@ const Info = require('peer-info')
|
||||
const Id = require('peer-id')
|
||||
const multiaddr = require('multiaddr')
|
||||
|
||||
const isNode = !global.window
|
||||
|
||||
const identity = isNode
|
||||
? fs.readFileSync(path.join(__dirname, 'identify.proto'))
|
||||
: require('buffer!./identify.proto')
|
||||
const identity = fs.readFileSync(path.join(__dirname, 'identify.proto'))
|
||||
|
||||
const pbStream = require('protocol-buffers-stream')(identity)
|
||||
|
||||
|
12
src/index.js
12
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) {
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user