mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-14 16:21:34 +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",
|
"name": "libp2p-swarm",
|
||||||
"version": "0.10.5",
|
"version": "0.10.6",
|
||||||
"description": "libp2p swarm implementation in JavaScript",
|
"description": "libp2p swarm implementation in JavaScript",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"jsnext:main": "src/index.js",
|
"jsnext:main": "src/index.js",
|
||||||
@ -40,25 +40,26 @@
|
|||||||
"bl": "^1.1.2",
|
"bl": "^1.1.2",
|
||||||
"buffer-loader": "0.0.1",
|
"buffer-loader": "0.0.1",
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"aegir": "^2.1.0",
|
"aegir": "^2.1.1",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"istanbul": "^0.4.2",
|
"istanbul": "^0.4.3",
|
||||||
"libp2p-multiplex": "^0.2.1",
|
"libp2p-multiplex": "^0.2.1",
|
||||||
"libp2p-spdy": "^0.2.3",
|
"libp2p-spdy": "^0.3.1",
|
||||||
"libp2p-tcp": "^0.4.0",
|
"libp2p-tcp": "^0.4.0",
|
||||||
"libp2p-websockets": "^0.3.1",
|
"libp2p-websockets": "^0.3.2",
|
||||||
"multiaddr": "^1.3.0",
|
"multiaddr": "^1.4.0",
|
||||||
"peer-id": "^0.6.0",
|
"peer-id": "^0.6.6",
|
||||||
"peer-info": "^0.6.0",
|
"peer-info": "^0.6.2",
|
||||||
"pre-commit": "^1.1.2",
|
"pre-commit": "^1.1.2",
|
||||||
"stream-pair": "^1.0.3"
|
"stream-pair": "^1.0.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-runtime": "^6.6.1",
|
"babel-runtime": "^6.6.1",
|
||||||
"duplex-passthrough": "github:diasdavid/duplex-passthrough",
|
"duplex-passthrough": "github:diasdavid/duplex-passthrough",
|
||||||
"ip-address": "^5.0.2",
|
"ip-address": "^5.8.0",
|
||||||
"multistream-select": "^0.6.1",
|
"lodash.contains": "^2.4.3",
|
||||||
"protocol-buffers-stream": "^1.2.0"
|
"multistream-select": "^0.6.5",
|
||||||
|
"protocol-buffers-stream": "^1.3.1"
|
||||||
},
|
},
|
||||||
"aegir": {
|
"aegir": {
|
||||||
"webpack": {
|
"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 Id = require('peer-id')
|
||||||
const multiaddr = require('multiaddr')
|
const multiaddr = require('multiaddr')
|
||||||
|
|
||||||
const isNode = !global.window
|
const identity = fs.readFileSync(path.join(__dirname, 'identify.proto'))
|
||||||
|
|
||||||
const identity = isNode
|
|
||||||
? fs.readFileSync(path.join(__dirname, 'identify.proto'))
|
|
||||||
: require('buffer!./identify.proto')
|
|
||||||
|
|
||||||
const pbStream = require('protocol-buffers-stream')(identity)
|
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 multistream = require('multistream-select')
|
||||||
const identify = require('./identify')
|
const identify = require('./identify')
|
||||||
const DuplexPassThrough = require('duplex-passthrough')
|
const DuplexPassThrough = require('duplex-passthrough')
|
||||||
|
const contains = require('lodash.contains')
|
||||||
|
|
||||||
exports = module.exports = Swarm
|
exports = module.exports = Swarm
|
||||||
|
|
||||||
@ -87,7 +88,16 @@ function Swarm (peerInfo) {
|
|||||||
// if no callback is passed, we pass conns to connHandler
|
// if no callback is passed, we pass conns to connHandler
|
||||||
if (!handler) { handler = 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) => {
|
this.transports[key].createListener(multiaddrs, handler, (err, maUpdate) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -21,7 +21,7 @@ describe('high level API - 1st without stream multiplexing (on TCP)', function (
|
|||||||
peerB = new Peer()
|
peerB = new Peer()
|
||||||
|
|
||||||
peerA.multiaddr.add(multiaddr('/ip4/127.0.0.1/tcp/9001'))
|
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)
|
swarmA = new Swarm(peerA)
|
||||||
swarmB = new Swarm(peerB)
|
swarmB = new Swarm(peerB)
|
||||||
|
Reference in New Issue
Block a user