Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Commit

Permalink
feat: update to new webrtc-star, make DHT optional for now (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias authored May 19, 2017
1 parent aa9e7f0 commit e889395
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
},
"homepage": "https://github.com/ipfs/js-libp2p-ipfs-nodejs#readme",
"devDependencies": {
"aegir": "^11.0.1",
"async": "^2.3.0",
"aegir": "^11.0.2",
"async": "^2.4.0",
"chai": "^3.5.0",
"cids": "^0.5.0",
"dirty-chai": "^1.2.2",
"lodash.times": "^4.3.2",
"pre-commit": "^1.2.2",
"pull-stream": "^3.5.0"
"pull-stream": "^3.6.0"
},
"dependencies": {
"libp2p": "~0.9.0",
"libp2p": "~0.9.1",
"libp2p-kad-dht": "~0.1.0",
"libp2p-mdns": "~0.7.0",
"libp2p-multiplex": "~0.4.3",
Expand All @@ -56,7 +56,7 @@
"libp2p-spdy": "~0.10.6",
"libp2p-swarm": "~0.29.1",
"libp2p-tcp": "~0.10.1",
"libp2p-webrtc-star": "~0.9.0",
"libp2p-webrtc-star": "~0.10.0",
"libp2p-websockets": "~0.10.0",
"mafmt": "^2.1.8",
"multiaddr": "^2.3.0",
Expand Down
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ class Node extends libp2p {
muxer: getMuxers(options.muxer),
crypto: [ secio ]
},
discovery: [],
DHT: KadDHT
discovery: []
}

if (options.webRTCStar) {
modules.discovery.push(webRTCStar.discovery)
}

if (options.DHT) {
modules.DHT = KadDHT
}

if (options.mdns) {
const mdns = new MulticastDNS(peerInfo, 'ipfs.local')
modules.discovery.push(mdns)
Expand Down
5 changes: 4 additions & 1 deletion test/content-routing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ describe('.contentRouting', () => {

before((done) => {
const tasks = _times(5, () => (cb) => {
createNode('/ip4/0.0.0.0/tcp/0', { mdns: false }, (err, node) => {
createNode('/ip4/0.0.0.0/tcp/0', {
mdns: false,
DHT: true
}, (err, node) => {
expect(err).to.not.exist()
node.start((err) => cb(err, node))
})
Expand Down
8 changes: 5 additions & 3 deletions test/discovery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@ const echo = utils.echo
describe('discovery', () => {
let nodeA
let nodeB
let port = 24642
let ss

function setup (options) {
before((done) => {
port++
parallel([
(cb) => {
signalling.start({ port: 24642 }, (err, server) => {
signalling.start({ port: port }, (err, server) => {
expect(err).to.not.exist()
ss = server
cb()
})
},
(cb) => createNode([
'/ip4/0.0.0.0/tcp/0',
'/libp2p-webrtc-star/ip4/127.0.0.1/tcp/24642/ws'
`/libp2p-webrtc-star/ip4/127.0.0.1/tcp/${port}/ws`
], options, (err, node) => {
expect(err).to.not.exist()
nodeA = node
Expand All @@ -36,7 +38,7 @@ describe('discovery', () => {
}),
(cb) => createNode([
'/ip4/0.0.0.0/tcp/0',
'/libp2p-webrtc-star/ip4/127.0.0.1/tcp/24642/ws'
`/libp2p-webrtc-star/ip4/127.0.0.1/tcp/${port}/ws`
], options, (err, node) => {
expect(err).to.not.exist()
nodeB = node
Expand Down
5 changes: 4 additions & 1 deletion test/peer-routing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ describe('.peerRouting', () => {

before((done) => {
const tasks = _times(5, () => (cb) => {
createNode('/ip4/0.0.0.0/tcp/0', { mdns: false }, (err, node) => {
createNode('/ip4/0.0.0.0/tcp/0', {
mdns: false,
DHT: true
}, (err, node) => {
expect(err).to.not.exist()
node.start((err) => cb(err, node))
})
Expand Down

0 comments on commit e889395

Please sign in to comment.