Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - feat: Circuit Relay #116

Merged
merged 29 commits into from
Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ad1e6ff
feat: adding circuit relaying
dryajov Apr 9, 2017
3cc9673
feat: new super simplified API
daviddias Mar 27, 2017
58e4f1a
feat: append peer id to multiaddr if not there
daviddias Mar 29, 2017
89c3f44
[WIP] Awesome DHT (#86)
dignifiedquire Apr 6, 2017
afd31be
feat: rework circuit relay for protobufs
dryajov Jul 24, 2017
7acdc96
feat: circuit loading and tests
dryajov Aug 2, 2017
485eebd
fix: clean up _getPeerInfo to work with /p2p-circuit
dryajov Aug 16, 2017
9477389
wip: tests cleaup
dryajov Aug 16, 2017
cc28fd7
test: clean up
dryajov Aug 22, 2017
0c06829
wip
dryajov Oct 23, 2017
973e006
fix: bringing back test reworks and new aegir
dryajov Oct 23, 2017
7da79d5
test: group tests
dryajov Aug 22, 2017
b35dc9f
test: clean up
dryajov Aug 22, 2017
9323ec6
test: adjust test
dryajov Sep 1, 2017
44252de
fix: use getPeerId to determine if the ipfs fragment is missing
dryajov Sep 3, 2017
722bf1f
feat: adding circuit relaying
dryajov Apr 9, 2017
f032652
feat: circuit loading and tests
dryajov Aug 2, 2017
acdd40b
test: clean up
dryajov Aug 22, 2017
13ea93c
wip
dryajov Sep 3, 2017
b68c6cf
feat: upgrade to latest aegir
dryajov Oct 17, 2017
6f8b324
fix: removing unused tests
dryajov Oct 17, 2017
e3be331
feat: cleanup tests
dryajov Oct 23, 2017
decf7c2
fix: create node defautl options
dryajov Oct 23, 2017
7e4b850
chore: upgrade swarm to latest version
dryajov Oct 23, 2017
c7d7ab3
fix: updated aegir and adjust timeouts
dryajov Oct 24, 2017
dd2df80
feat: more timeouts
dryajov Oct 24, 2017
fa9578d
chore: updating deps
dryajov Oct 25, 2017
1830571
fix: circle ci builds
dryajov Oct 25, 2017
e3b04a4
test: timeouts
dryajov Oct 25, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions gulpfile.js → .aegir.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const gulp = require('gulp')
const Node = require('./test/nodejs-bundle/nodejs-bundle.js')
const PeerInfo = require('peer-info')
const PeerId = require('peer-id')
Expand All @@ -12,7 +11,7 @@ let server
let node
const rawPeer = require('./test/browser-bundle/peer.json')

gulp.task('libnode:start', (done) => {
const before = (done) => {
let count = 0
const ready = () => ++count === 2 ? done() : null

Expand All @@ -36,20 +35,21 @@ gulp.task('libnode:start', (done) => {
node.handle('/echo/1.0.0', (protocol, conn) => pull(conn, conn))
node.start(() => ready())
})
})
}

gulp.task('libnode:stop', (done) => {
const after = (done) => {
setTimeout(() => node.stop((err) => {
if (err) {
return done(err)
}
server.stop(done)
}), 2000)
})
}

gulp.task('test:browser:before', ['libnode:start'])
gulp.task('test:node:before', ['libnode:start'])
gulp.task('test:browser:after', ['libnode:stop'])
gulp.task('test:node:after', ['libnode:stop'])
module.exports = {
hooks: {
pre: before,
post: after
}
}

require('aegir/gulp')(gulp)
6 changes: 5 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ dependencies:
pre:
- google-chrome --version
- curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- for v in $(curl http://archive.ubuntu.com/ubuntu/pool/main/n/nss/ | grep "href=" | grep "libnss3.*deb\"" -o | grep -o "libnss3.*deb" | grep "3.28" | grep "14.04"); do curl -L -o $v http://archive.ubuntu.com/ubuntu/pool/main/n/nss/$v; done && rm libnss3-tools*_i386.deb libnss3-dev*_i386.deb
- sudo dpkg -i google-chrome.deb || true
- sudo dpkg -i libnss3*.deb || true
- sudo apt-get update
- sudo apt-get install -f || true
- sudo dpkg -i libnss3*.deb
- sudo apt-get install -f
- sudo apt-get install --only-upgrade lsb-base
- sudo dpkg -i google-chrome.deb
- google-chrome --version
- google-chrome --version
8 changes: 4 additions & 4 deletions examples/protocol-and-stream-muxing/3.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ parallel([
if (err) { throw err }
console.log('Addresses by which both peers are connected')
node1.peerBook
.getAllArray()
.forEach((peer) => console.log('node 1 to node 2:', peer.isConnected().toString()))
.getAllArray()
.forEach((peer) => console.log('node 1 to node 2:', peer.isConnected().toString()))
node2.peerBook
.getAllArray()
.forEach((peer) => console.log('node 2 to node 1:', peer.isConnected().toString()))
.getAllArray()
.forEach((peer) => console.log('node 2 to node 1:', peer.isConnected().toString()))
})
})
55 changes: 28 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"description": "JavaScript base class for libp2p bundles",
"main": "src/index.js",
"scripts": {
"test": "gulp test",
"test:node": "gulp test:node",
"test:browser": "gulp test:browser --dom",
"release": "gulp release --dom",
"release-minor": "gulp release --type minor --dom",
"release-major": "gulp release --type major --dom",
"build": "gulp build",
"lint": "aegir-lint",
"coverage": "aegir-coverage",
"coverage-publish": "aegir-coverage publish"
"lint": "aegir lint",
"build": "aegir build",
"test": "aegir test --target node --target browser --no-parallel",
"test:node": "aegir test --target node --no-parallel",
"test:browser": "aegir test --target browser --no-parallel",
"release": "aegir test release --target node --target browser --no-parallel",
"release-minor": "aegir release --type minor --target node --target browser --no-parallel",
"release-major": "aegir release --type major --target node --target browser --no-parallel",
"coverage": "aegir coverage",
"coverage-publish": "aegir coverage --provider coveralls"
},
"repository": {
"type": "git",
Expand All @@ -39,39 +39,40 @@
"dependencies": {
"async": "^2.5.0",
"libp2p-ping": "~0.6.0",
"libp2p-swarm": "~0.32.4",
"mafmt": "^3.0.1",
"multiaddr": "^3.0.1",
"peer-book": "~0.5.1",
"peer-id": "~0.10.1",
"libp2p-swarm": "~0.33.0",
"mafmt": "^3.0.2",
"multiaddr": "^3.0.0",
"peer-book": "~0.5.0",
"peer-id": "~0.10.0",
"peer-info": "~0.11.0"
},
"devDependencies": {
"aegir": "^11.0.2",
"aegir": "^12.1.0",
"chai": "^4.1.2",
"dirty-chai": "^2.0.1",
"cids": "~0.5.1",
"libp2p-kad-dht": "~0.5.1",
"libp2p-mdns": "~0.9.1",
"dirty-chai": "^2.0.1",
"electron-webrtc": "^0.3.0",
"libp2p-circuit": "^0.1.2",
"libp2p-kad-dht": "~0.5.0",
"libp2p-mdns": "~0.9.0",
"libp2p-multiplex": "~0.5.0",
"libp2p-railing": "~0.7.1",
"libp2p-secio": "~0.8.1",
"libp2p-railing": "~0.7.0",
"libp2p-secio": "~0.8.0",
"libp2p-spdy": "~0.11.0",
"libp2p-tcp": "~0.11.0",
"libp2p-webrtc-star": "~0.13.2",
"libp2p-websockets": "~0.10.1",
"libp2p-tcp": "^0.11.0",
"libp2p-webrtc-star": "^0.13.2",
"libp2p-websockets": "^0.10.4",
"lodash.times": "^4.3.2",
"pre-commit": "^1.2.2",
"pull-goodbye": "0.0.2",
"pull-serializer": "^0.3.2",
"pull-stream": "^3.6.1",
"pull-stream": "^3.6.0",
"safe-buffer": "^5.1.1",
"electron-webrtc": "^0.3.0",
"sinon": "^2.3.6",
"wrtc": "0.0.62"
},
"contributors": [
"Chris Bratlien <[email protected]>",
"Daijiro Wachi <[email protected]>",
"David Dias <[email protected]>",
"Elven <[email protected]>",
"Friedel Ziegelmayer <[email protected]>",
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const Swarm = require('libp2p-swarm')
const PeerId = require('peer-id')
const PeerInfo = require('peer-info')
const PeerBook = require('peer-book')
const mafmt = require('mafmt')
const multiaddr = require('multiaddr')

exports = module.exports
Expand Down Expand Up @@ -43,6 +42,9 @@ class Node extends EventEmitter {
// If muxer exists, we can use Identify
this.swarm.connection.reuse()

// If muxer exists, we can use Relay for listening/dialing
this.swarm.connection.enableCircuitRelay(_options.relay)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be enabled by an option and not by default

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is being handled inside the enableCircuitRelay - https://github.com/libp2p/js-libp2p-swarm/blob/master/src/connection.js#L100.


// Received incommind dial and muxer upgrade happened,
// reuse this muxed connection
this.swarm.on('peer-mux-established', (peerInfo) => {
Expand Down Expand Up @@ -155,7 +157,7 @@ class Node extends EventEmitter {
const maOld = []
const maNew = []
this.peerInfo.multiaddrs.forEach((ma) => {
if (!mafmt.IPFS.matches(ma)) {
if (!ma.getPeerId()) {
maOld.push(ma)
maNew.push(ma.encapsulate('/ipfs/' + this.peerInfo.id.toB58String()))
}
Expand Down
1 change: 1 addition & 0 deletions test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ require('./nodejs-bundle/stream-muxing')
require('./nodejs-bundle/discovery')
require('./nodejs-bundle/peer-routing')
require('./nodejs-bundle/content-routing')
require('./nodejs-bundle/circuit')
Loading