mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-08 21:31:32 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
c128873a07 | |||
5e2b6df04a | |||
8d2d8c98a0 | |||
30bf5bb161 | |||
c88eaf416c | |||
c7f20383d9 | |||
a86a95c19f | |||
1b7360fcfa | |||
67ca37c356 | |||
0870068ebc |
@ -1,3 +1,4 @@
|
|||||||
|
# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
|
||||||
sudo: false
|
sudo: false
|
||||||
language: node_js
|
language: node_js
|
||||||
|
|
||||||
@ -14,7 +15,6 @@ script:
|
|||||||
- npm run lint
|
- npm run lint
|
||||||
- npm run test
|
- npm run test
|
||||||
- npm run coverage
|
- npm run coverage
|
||||||
- make test
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- export DISPLAY=:99.0
|
- export DISPLAY=:99.0
|
||||||
|
25
CHANGELOG.md
25
CHANGELOG.md
@ -1,3 +1,28 @@
|
|||||||
|
<a name="0.14.2"></a>
|
||||||
|
## [0.14.2](https://github.com/libp2p/js-libp2p/compare/v0.14.1...v0.14.2) (2017-12-15)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="0.14.1"></a>
|
||||||
|
## [0.14.1](https://github.com/libp2p/js-libp2p/compare/v0.14.0...v0.14.1) (2017-12-15)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* prevent "The libp2p node is not started yet" when stopping ([#138](https://github.com/libp2p/js-libp2p/issues/138)) ([c88eaf4](https://github.com/libp2p/js-libp2p/commit/c88eaf4))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="0.14.0"></a>
|
||||||
|
# [0.14.0](https://github.com/libp2p/js-libp2p/compare/v0.13.3...v0.14.0) (2017-12-14)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* remove innactive multiaddrs ([#131](https://github.com/libp2p/js-libp2p/issues/131)) ([1b7360f](https://github.com/libp2p/js-libp2p/commit/1b7360f))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="0.13.3"></a>
|
<a name="0.13.3"></a>
|
||||||
## [0.13.3](https://github.com/libp2p/js-libp2p/compare/v0.13.2...v0.13.3) (2017-12-01)
|
## [0.13.3](https://github.com/libp2p/js-libp2p/compare/v0.13.2...v0.13.3) (2017-12-01)
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ We've come a long way, but this project is still in Alpha, lots of development i
|
|||||||
|
|
||||||
## Background
|
## Background
|
||||||
|
|
||||||
libp2p is the product of a long and arduous quest to understand the evolution of the Internet networking stack. In order to build P2P applications, dev have long had to made custom ad-hoc solutions to fit their needs, sometimes making some hard assumptions about their runtimes and the state of the network at the time of their development. Today, looking back more than 20 years, we see a clear pattern in the types of mechanisms built around the Internet Protocol, IP, which can be found throughout many layers of the OSI layer system, libp2p distils these mechanisms into flat categories and defines clear interfaces that once exposed, enable other protocols and applications to use and swap them, enabling upgradability and adaptability for the runtime, without breaking the API.
|
libp2p is the product of a long and arduous quest to understand the evolution of the Internet networking stack. In order to build P2P applications, devs have long had to made custom ad-hoc solutions to fit their needs, sometimes making some hard assumptions about their runtimes and the state of the network at the time of their development. Today, looking back more than 20 years, we see a clear pattern in the types of mechanisms built around the Internet Protocol, IP, which can be found throughout many layers of the OSI layer system, libp2p distils these mechanisms into flat categories and defines clear interfaces that once exposed, enable other protocols and applications to use and swap them, enabling upgradability and adaptability for the runtime, without breaking the API.
|
||||||
|
|
||||||
We are in the process of writing better documentation, blog posts, tutorials and a formal specification. Today you can find:
|
We are in the process of writing better documentation, blog posts, tutorials and a formal specification. Today you can find:
|
||||||
|
|
||||||
|
29
appveyor.yml
Normal file
29
appveyor.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
|
||||||
|
version: "{build}"
|
||||||
|
|
||||||
|
environment:
|
||||||
|
matrix:
|
||||||
|
- nodejs_version: "6"
|
||||||
|
- nodejs_version: "8"
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
fast_finish: true
|
||||||
|
|
||||||
|
install:
|
||||||
|
# Install Node.js
|
||||||
|
- ps: Install-Product node $env:nodejs_version
|
||||||
|
|
||||||
|
# Upgrade npm
|
||||||
|
- npm install -g npm
|
||||||
|
|
||||||
|
# Output our current versions for debugging
|
||||||
|
- node --version
|
||||||
|
- npm --version
|
||||||
|
|
||||||
|
# Install our package dependencies
|
||||||
|
- npm install
|
||||||
|
|
||||||
|
test_script:
|
||||||
|
- npm run test:node
|
||||||
|
|
||||||
|
build: off
|
2
ci/Jenkinsfile
vendored
Normal file
2
ci/Jenkinsfile
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
// Warning: This file is automatically synced from https://github.com/ipfs/ci-sync so if you want to change it, please change it there and ask someone to sync all repositories.
|
||||||
|
javascript()
|
13
package.json
13
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "libp2p",
|
"name": "libp2p",
|
||||||
"version": "0.13.3",
|
"version": "0.14.2",
|
||||||
"description": "JavaScript base class for libp2p bundles",
|
"description": "JavaScript base class for libp2p bundles",
|
||||||
"main": "src/index.js",
|
"main": "src/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -39,7 +39,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^2.6.0",
|
"async": "^2.6.0",
|
||||||
"libp2p-ping": "~0.6.0",
|
"libp2p-ping": "~0.6.0",
|
||||||
"libp2p-swarm": "~0.33.2",
|
"libp2p-swarm": "~0.34.0",
|
||||||
"mafmt": "^3.0.2",
|
"mafmt": "^3.0.2",
|
||||||
"multiaddr": "^3.0.1",
|
"multiaddr": "^3.0.1",
|
||||||
"peer-book": "~0.5.2",
|
"peer-book": "~0.5.2",
|
||||||
@ -55,22 +55,22 @@
|
|||||||
"libp2p-circuit": "~0.1.4",
|
"libp2p-circuit": "~0.1.4",
|
||||||
"libp2p-kad-dht": "~0.6.0",
|
"libp2p-kad-dht": "~0.6.0",
|
||||||
"libp2p-mdns": "~0.9.1",
|
"libp2p-mdns": "~0.9.1",
|
||||||
"libp2p-multiplex": "~0.5.0",
|
"libp2p-multiplex": "~0.5.1",
|
||||||
"libp2p-railing": "~0.7.1",
|
"libp2p-railing": "~0.7.1",
|
||||||
"libp2p-secio": "~0.8.1",
|
"libp2p-secio": "~0.8.1",
|
||||||
"libp2p-spdy": "~0.11.0",
|
"libp2p-spdy": "~0.11.0",
|
||||||
"libp2p-tcp": "~0.11.1",
|
"libp2p-tcp": "~0.11.1",
|
||||||
"libp2p-webrtc-star": "~0.13.3",
|
"libp2p-webrtc-star": "~0.13.3",
|
||||||
"libp2p-websockets": "~0.10.4",
|
"libp2p-websockets": "~0.10.4",
|
||||||
"libp2p-websocket-star": "~0.7.1",
|
"libp2p-websocket-star": "~0.7.2",
|
||||||
"libp2p-websocket-star-rendezvous": "~0.2.1",
|
"libp2p-websocket-star-rendezvous": "~0.2.2",
|
||||||
"lodash.times": "^4.3.2",
|
"lodash.times": "^4.3.2",
|
||||||
"pre-commit": "^1.2.2",
|
"pre-commit": "^1.2.2",
|
||||||
"pull-goodbye": "0.0.2",
|
"pull-goodbye": "0.0.2",
|
||||||
"pull-serializer": "~0.3.2",
|
"pull-serializer": "~0.3.2",
|
||||||
"pull-stream": "^3.6.1",
|
"pull-stream": "^3.6.1",
|
||||||
"safe-buffer": "^5.1.1",
|
"safe-buffer": "^5.1.1",
|
||||||
"sinon": "^4.1.2",
|
"sinon": "^4.1.3",
|
||||||
"wrtc": "0.0.63"
|
"wrtc": "0.0.63"
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
@ -80,6 +80,7 @@
|
|||||||
"Dmitriy Ryajov <dryajov@gmail.com>",
|
"Dmitriy Ryajov <dryajov@gmail.com>",
|
||||||
"Elven <mon.samuel@qq.com>",
|
"Elven <mon.samuel@qq.com>",
|
||||||
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
||||||
|
"Joel Gustafson <joelg@mit.edu>",
|
||||||
"Lars Gierth <lgierth@users.noreply.github.com>",
|
"Lars Gierth <lgierth@users.noreply.github.com>",
|
||||||
"Maciej Krüger <mkg20001@gmail.com>",
|
"Maciej Krüger <mkg20001@gmail.com>",
|
||||||
"Nuno Nogueira <nunofmn@gmail.com>",
|
"Nuno Nogueira <nunofmn@gmail.com>",
|
||||||
|
24
src/index.js
24
src/index.js
@ -156,15 +156,15 @@ class Node extends EventEmitter {
|
|||||||
// so that we can have webrtc-star addrs without adding manually the id
|
// so that we can have webrtc-star addrs without adding manually the id
|
||||||
const maOld = []
|
const maOld = []
|
||||||
const maNew = []
|
const maNew = []
|
||||||
this.peerInfo.multiaddrs.forEach((ma) => {
|
this.peerInfo.multiaddrs.toArray().forEach((ma) => {
|
||||||
if (!ma.getPeerId()) {
|
if (!ma.getPeerId()) {
|
||||||
maOld.push(ma)
|
maOld.push(ma)
|
||||||
maNew.push(ma.encapsulate('/ipfs/' + this.peerInfo.id.toB58String()))
|
maNew.push(ma.encapsulate('/ipfs/' + this.peerInfo.id.toB58String()))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.peerInfo.multiaddrs.replace(maOld, maNew)
|
this.peerInfo.multiaddrs.replace(maOld, maNew)
|
||||||
const multiaddrs = this.peerInfo.multiaddrs.toArray()
|
|
||||||
|
|
||||||
|
const multiaddrs = this.peerInfo.multiaddrs.toArray()
|
||||||
transports.forEach((transport) => {
|
transports.forEach((transport) => {
|
||||||
if (transport.filter(multiaddrs).length > 0) {
|
if (transport.filter(multiaddrs).length > 0) {
|
||||||
this.swarm.transport.add(
|
this.swarm.transport.add(
|
||||||
@ -200,6 +200,19 @@ class Node extends EventEmitter {
|
|||||||
}
|
}
|
||||||
cb()
|
cb()
|
||||||
},
|
},
|
||||||
|
(cb) => {
|
||||||
|
// detect which multiaddrs we don't have a transport for and remove them
|
||||||
|
const multiaddrs = this.peerInfo.multiaddrs.toArray()
|
||||||
|
transports.forEach((transport) => {
|
||||||
|
multiaddrs.forEach((multiaddr) => {
|
||||||
|
if (!multiaddr.toString().match(/\/p2p-circuit($|\/)/) &&
|
||||||
|
!transports.find((transport) => transport.filter(multiaddr).length > 0)) {
|
||||||
|
this.peerInfo.multiaddrs.delete(multiaddr)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
cb()
|
||||||
|
},
|
||||||
(cb) => {
|
(cb) => {
|
||||||
this.emit('start')
|
this.emit('start')
|
||||||
cb()
|
cb()
|
||||||
@ -211,8 +224,6 @@ class Node extends EventEmitter {
|
|||||||
* Stop the libp2p node by closing its listeners and open connections
|
* Stop the libp2p node by closing its listeners and open connections
|
||||||
*/
|
*/
|
||||||
stop (callback) {
|
stop (callback) {
|
||||||
this._isStarted = false
|
|
||||||
|
|
||||||
if (this.modules.discovery) {
|
if (this.modules.discovery) {
|
||||||
this.modules.discovery.forEach((discovery) => {
|
this.modules.discovery.forEach((discovery) => {
|
||||||
setImmediate(() => discovery.stop(() => {}))
|
setImmediate(() => discovery.stop(() => {}))
|
||||||
@ -231,7 +242,10 @@ class Node extends EventEmitter {
|
|||||||
this.emit('stop')
|
this.emit('stop')
|
||||||
cb()
|
cb()
|
||||||
}
|
}
|
||||||
], callback)
|
], (err) => {
|
||||||
|
this._isStarted = false
|
||||||
|
callback(err)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
isStarted () {
|
isStarted () {
|
||||||
|
40
test/multiaddr-trim.js
Normal file
40
test/multiaddr-trim.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* eslint-env mocha */
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const chai = require('chai')
|
||||||
|
chai.use(require('dirty-chai'))
|
||||||
|
const expect = chai.expect
|
||||||
|
const series = require('async/series')
|
||||||
|
const createNode = require('./utils/node').createNode
|
||||||
|
|
||||||
|
describe('multiaddr trim', () => {
|
||||||
|
it('non used multiaddrs get trimmed', (done) => {
|
||||||
|
let node
|
||||||
|
|
||||||
|
series([
|
||||||
|
(cb) => createNode([
|
||||||
|
'/ip4/0.0.0.0/tcp/999/wss/p2p-webrtc-direct',
|
||||||
|
'/ip4/127.0.0.1/tcp/55555/ws',
|
||||||
|
'/ip4/0.0.0.0/tcp/0/'
|
||||||
|
], (err, _node) => {
|
||||||
|
expect(err).to.not.exist()
|
||||||
|
node = _node
|
||||||
|
const multiaddrs = node.peerInfo.multiaddrs.toArray()
|
||||||
|
// multiaddrs.forEach((ma) => console.log(ma.toString()))
|
||||||
|
expect(multiaddrs).to.have.length(3)
|
||||||
|
cb()
|
||||||
|
}),
|
||||||
|
(cb) => node.start(cb)
|
||||||
|
], (err) => {
|
||||||
|
expect(err).to.not.exist()
|
||||||
|
|
||||||
|
const multiaddrs = node.peerInfo.multiaddrs.toArray()
|
||||||
|
// console.log('--')
|
||||||
|
// multiaddrs.forEach((ma) => console.log(ma.toString()))
|
||||||
|
|
||||||
|
expect(multiaddrs.length).to.at.least(2)
|
||||||
|
expect(multiaddrs[0].toString()).to.match(/^\/ip4\/127\.0\.0\.1\/tcp\/[0-9]+\/ws\/ipfs\/\w+$/)
|
||||||
|
node.stop(done)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
@ -7,3 +7,4 @@ require('./peer-discovery.node')
|
|||||||
require('./peer-routing.node')
|
require('./peer-routing.node')
|
||||||
require('./content-routing.node')
|
require('./content-routing.node')
|
||||||
require('./circuit-relay.node')
|
require('./circuit-relay.node')
|
||||||
|
require('./multiaddr-trim')
|
||||||
|
@ -517,7 +517,7 @@ describe('transports', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('nodeAll.dial nodeWStar using PeerInfo', function (done) {
|
it('nodeAll.dial nodeWStar using PeerInfo', function (done) {
|
||||||
this.timeout(10 * 1000)
|
this.timeout(40 * 1000)
|
||||||
|
|
||||||
nodeAll.dial(nodeWStar.peerInfo, (err) => {
|
nodeAll.dial(nodeWStar.peerInfo, (err) => {
|
||||||
expect(err).to.not.exist()
|
expect(err).to.not.exist()
|
||||||
|
Reference in New Issue
Block a user