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

Bring libp2p-websocket-star to the Transports family! 🌟 #122

Merged
merged 8 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
73 changes: 43 additions & 30 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,63 @@
'use strict'

const Node = require('./test/nodejs-bundle/nodejs-bundle.js')
const PeerInfo = require('peer-info')
const PeerId = require('peer-id')
const pull = require('pull-stream')
const parallel = require('async/parallel')

const rawPeer = require('./test/fixtures/test-peer.json')
const Node = require('./test/utils/bundle.node.js')
const sigServer = require('libp2p-webrtc-star/src/sig-server')
let server
const WebSocketStarRendezvous = require('libp2p-websocket-star-rendezvous')

let wrtcRendezvous
let wsRendezvous
let node
const rawPeer = require('./test/browser-bundle/peer.json')

const before = (done) => {
let count = 0
const ready = () => ++count === 2 ? done() : null
parallel([
(cb) => {
sigServer.start({ port: 15555 }, (err, server) => {
if (err) { return cb(err) }
wrtcRendezvous = server
cb()
})
},
(cb) => {
WebSocketStarRendezvous.start({
port: 14444,
refreshPeerListIntervalMS: 1000,
strictMultiaddr: false,
cryptoChallenge: false
}, (err, _server) => {
if (err) { return cb(err) }
wsRendezvous = _server
cb()
})
},
(cb) => {
PeerId.createFromJSON(rawPeer, (err, peerId) => {
if (err) {
return done(err)
}
const peer = new PeerInfo(peerId)

sigServer.start({ port: 15555 }, (err, _server) => {
if (err) {
throw err
}
server = _server
ready()
})
peer.multiaddrs.add('/ip4/127.0.0.1/tcp/9200/ws')

PeerId.createFromJSON(rawPeer, (err, peerId) => {
if (err) {
return done(err)
node = new Node(peer)
node.handle('/echo/1.0.0', (protocol, conn) => pull(conn, conn))
node.start(cb)
})
}
const peer = new PeerInfo(peerId)

peer.multiaddrs.add('/ip4/127.0.0.1/tcp/9200/ws')

node = new Node(peer)
node.handle('/echo/1.0.0', (protocol, conn) => pull(conn, conn))
node.start(() => ready())
})
], done)
}

const after = (done) => {
setTimeout(() => node.stop((err) => {
if (err) {
return done(err)
}
server.stop(done)
}), 2000)
setTimeout(() => parallel(
[node, wrtcRendezvous, wsRendezvous].map((s) => {
return (cb) => s.stop(cb)
})
, done), 2000)
}

module.exports = {
Expand All @@ -52,4 +66,3 @@ module.exports = {
post: after
}
}

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
"dependencies": {
"async": "^2.6.0",
"libp2p-ping": "~0.6.0",
"libp2p-swarm": "~0.33.1",
"libp2p-swarm": "~0.33.2",
"mafmt": "^3.0.2",
"multiaddr": "^3.0.1",
"peer-book": "~0.5.1",
"peer-id": "~0.10.2",
"peer-info": "~0.11.1"
},
"devDependencies": {
"aegir": "^12.1.3",
"aegir": "^12.2.0",
"chai": "^4.1.2",
"cids": "~0.5.2",
"dirty-chai": "^2.0.1",
Expand All @@ -62,6 +62,8 @@
"libp2p-tcp": "~0.11.1",
"libp2p-webrtc-star": "~0.13.2",
"libp2p-websockets": "~0.10.4",
"libp2p-websocket-star": "~0.5.1",
"libp2p-websocket-star-rendezvous": "~0.2.1",
"lodash.times": "^4.3.2",
"pre-commit": "^1.2.2",
"pull-goodbye": "0.0.2",
Expand Down
121 changes: 0 additions & 121 deletions test/browser-bundle/webrtc-star-only.js

This file was deleted.

Loading