From 258d07d00af1474615abb45fc12ab21d8bc332dc Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 8 Sep 2017 09:21:19 +0100 Subject: [PATCH 01/75] Initial commit --- .gitignore | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++ README.md | 2 ++ 3 files changed, 82 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..00cbbdf --- /dev/null +++ b/.gitignore @@ -0,0 +1,59 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bbfffbf --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 libp2p + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c97f062 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# js-libp2p-websocket-star-rendezvous +The rendezvous service for libp2p-websocket-star enabled nodes meet and talk with each other From 9009dcc27e45b0fa8f9f9453074727a9b4577d4b Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 8 Sep 2017 10:35:37 +0100 Subject: [PATCH 02/75] v0.1.0 (#1) * here it goes * kick to start ci --- .gitignore | 67 +++----------- .travis.yml | 29 ++++++ README.md | 46 +++++++++- circle.yml | 14 +++ package.json | 60 +++++++++++++ src/bin.js | 28 ++++++ src/config.js | 23 +++++ src/index.html | 60 +++++++++++++ src/index.js | 57 ++++++++++++ src/routes.js | 177 ++++++++++++++++++++++++++++++++++++ src/utils.js | 120 +++++++++++++++++++++++++ test/.jshintrc | 8 ++ test/rendezvous.spec.js | 195 ++++++++++++++++++++++++++++++++++++++++ 13 files changed, 825 insertions(+), 59 deletions(-) create mode 100644 .travis.yml create mode 100644 circle.yml create mode 100644 package.json create mode 100755 src/bin.js create mode 100644 src/config.js create mode 100644 src/index.html create mode 100644 src/index.js create mode 100644 src/routes.js create mode 100644 src/utils.js create mode 100644 test/.jshintrc create mode 100644 test/rendezvous.spec.js diff --git a/.gitignore b/.gitignore index 00cbbdf..fc26dd1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,59 +1,12 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* +package-lock.json +yarn.lock -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul +**/node_modules +**/*.log +test/setup/tmp-disposable-nodes-addrs.json +dist coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# Typescript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - +**/*.swp +examples/sub-module/**/bundle.js +examples/sub-module/**/*-minified.js +examples/sub-module/*-bundle.js diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..99609a6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +sudo: false +language: node_js + +matrix: + include: + - node_js: 6 + env: CXX=g++-4.8 + - node_js: 8 + env: CXX=g++-4.8 + +script: + - npm run lint + - npm run test + - npm run coverage + +before_script: + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + +after_success: + - npm run coverage-publish + +addons: + firefox: 'latest' + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 diff --git a/README.md b/README.md index c97f062..76c05b3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,44 @@ -# js-libp2p-websocket-star-rendezvous -The rendezvous service for libp2p-websocket-star enabled nodes meet and talk with each other +# libp2p-websocket-star-rendezvous + +[![](https://img.shields.io/badge/made%20by-mkg20001-blue.svg?style=flat-square)](http://ipn.io) +[![Travis](https://travis-ci.org/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=flat-square)](https://travis-ci.org/libp2p/js-libp2p-websocket-star-rendezvous) +[![Circle](https://circleci.com/gh/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=svg)](https://circleci.com/gh/libp2p/js-libp2p-websocket-star-rendezvous) +[![Coverage](https://coveralls.io/repos/github/libp2p/js-libp2p-websocket-star-rendezvous/badge.svg?branch=master)](https://coveralls.io/github/libp2p/js-libp2p-websocket-star-rendezvous?branch=master) +[![david-dm](https://david-dm.org/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websocket-star-rendezvous) + +> The rendezvous service for [libp2p-webrtc-star](https://github.com/libp2p/js-libp2p-websocket-star). + +## Descriptions + +Nodes using `libp2p-websocket-star` will connect to a known point in the network, a rendezvous point where they can learn about other nodes (Discovery) and route their messages to other nodes (2 hop message routing, also known as relay). + +## Usage + +`libp2p-websocket-star` comes with batteries included, that means that you can also spawn your own rendezvous point right from this module. To do that, first insall the module globally in your machine with: + +```bash +> npm install --global libp2p-websocket-star +``` + +This will install a `websockets-star` CLI tool. Now you can spawn the server with: + +```bash +> websockets-star --port=9090 --host=127.0.0.1 +``` + +Defaults: + +- `port` - 13579 +- `host` - '0.0.0.0' + +## Hosted Rendezvous server + +We host a rendezvous server at `ws-star-signal-1.servep2p.com` and `ws-star-signal-2.servep2p.com` that can be used for practical demos and experimentation, it **should not be used for apps in production**. + +A libp2p-websocket-star address, using the signalling server we provide, looks like: + +`/dns4/ws-star-signal-1.servep2p.com/wss/p2p-websocket-star/ipfs/` + +Note: The address above indicates WebSockets Secure, which can be accessed from both http and https. + +LICENSE MIT diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..56f7efb --- /dev/null +++ b/circle.yml @@ -0,0 +1,14 @@ +machine: + node: + version: stable + +dependencies: + pre: + - google-chrome --version + - curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb + - sudo dpkg -i google-chrome.deb || true + - sudo apt-get update + - sudo apt-get install -f + - sudo apt-get install --only-upgrade lsb-base + - sudo dpkg -i google-chrome.deb + - google-chrome --version diff --git a/package.json b/package.json new file mode 100644 index 0000000..ade2d2e --- /dev/null +++ b/package.json @@ -0,0 +1,60 @@ +{ + "name": "libp2p-websocket-star-rendezvous", + "version": "0.0.0", + "description": "The rendezvous service for libp2p-webrtc-star", + "bin": { + "websockets-star": "src/rendezvous/bin.js" + }, + "scripts": { + "rendezvous": "node sig-server/src/bin.js", + "lint": "aegir-lint", + "test": "aegir-test --env node", + "release": "aegir-release --env no-build", + "release-minor": "aegir-release --type minor --env no-build", + "release-major": "aegir-release --type major --env no-build", + "coverage": "aegir-coverage", + "coverage-publish": "aegir-coverage publish" + }, + "keywords": [ + "libp2p", + "websocket" + ], + "author": "Maciej Krüger ", + "license": "MIT", + "dependencies": { + "async": "^2.5.0", + "data-queue": "0.0.2", + "debug": "^3.0.1", + "hapi": "^16.5.2", + "inert": "^4.2.1", + "libp2p-crypto": "^0.10.3", + "mafmt": "^3.0.1", + "merge-recursive": "0.0.3", + "minimist": "^1.2.0", + "multiaddr": "^3.0.1", + "once": "^1.4.0", + "peer-id": "^0.10.1", + "peer-info": "^0.11.0", + "socket.io": "^2.0.3", + "socket.io-client": "^2.0.3", + "socket.io-pull-stream": "^0.1.1", + "uuid": "^3.1.0" + }, + "directories": { + "test": "test" + }, + "devDependencies": { + "aegir": "^11.0.2", + "chai": "^4.1.2", + "dirty-chai": "^2.0.1", + "lodash": "^4.17.4" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/libp2p/js-libp2p-websocket-star.git" + }, + "bugs": { + "url": "https://github.com/libp2p/js-libp2p-websocket-star/issues" + }, + "homepage": "https://github.com/libp2p/js-libp2p-websocket-star#readme" +} diff --git a/src/bin.js b/src/bin.js new file mode 100755 index 0000000..3e21a1d --- /dev/null +++ b/src/bin.js @@ -0,0 +1,28 @@ +#!/usr/bin/env node + +'use strict' + +const signalling = require('./index') +const argv = require('minimist')(process.argv.slice(2)) + +let server + +signalling.start({ + port: argv.port || argv.p || process.env.PORT || 9090, + host: argv.host || argv.h || process.env.HOST || '0.0.0.0', + cryptoChallenge: !(argv.disableCryptoChallenge || process.env.DISABLE_CRYPTO_CHALLENGE) +}, (err, _server) => { + if (err) { + throw err + } + server = _server + + console.log('Listening on:', server.info.uri) +}) + +process.on('SIGINT', () => { + server.stop(() => { + console.log('Signalling server stopped') + process.exit() + }) +}) diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..234d7a2 --- /dev/null +++ b/src/config.js @@ -0,0 +1,23 @@ +'use strict' + +const debug = require('debug') +const log = debug('signalling-server') +log.error = debug('signalling-server:error') + +module.exports = { + log: log, + hapi: { + port: process.env.PORT || 13579, + host: '0.0.0.0', + options: { + connections: { + routes: { + cors: true + } + } + } + }, + refreshPeerListIntervalMS: 10000, + cryptoChallenge: true, + strictMultiaddr: true +} diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..984efbf --- /dev/null +++ b/src/index.html @@ -0,0 +1,60 @@ + + + + + + + Signalling Server + + + + + +
+

This is a libp2p-websocket-star signalling-server

+

Signaling Servers are used in libp2p to allow browsers and clients with restricted port-forwarding to communicate

+
+
+ + + + + diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..8afc1e0 --- /dev/null +++ b/src/index.js @@ -0,0 +1,57 @@ +'use strict' + +const Hapi = require('hapi') +const merge = require('merge-recursive').recursive +const path = require('path') + +exports = module.exports + +exports.start = (options, callback) => { + if (typeof options === 'function') { + callback = options + options = {} + } + + const config = merge(require('./config'), options) + const log = config.log + + const port = options.port || config.hapi.port + const host = options.host || config.hapi.host + + const http = new Hapi.Server(config.hapi.options) + + http.connection({ + port, + host + }) + + http.register({ + register: require('inert') + }, err => { + if (err) { + return callback(err) + } + + http.start((err) => { + if (err) { + return callback(err) + } + + log('signaling server has started on: ' + http.info.uri) + + http.peers = require('./routes')(config, http).peers + + http.route({ + method: 'GET', + path: '/', + handler: (request, reply) => reply.file(path.join(__dirname, 'index.html'), { + confine: false + }) + }) + + callback(null, http) + }) + }) + + return http +} diff --git a/src/routes.js b/src/routes.js new file mode 100644 index 0000000..3704e64 --- /dev/null +++ b/src/routes.js @@ -0,0 +1,177 @@ +'use strict' + +const SocketIO = require('socket.io') +const sp = require('socket.io-pull-stream') +const util = require('./utils') +const uuid = require('uuid') + +module.exports = (config, http) => { + const log = config.log + const io = new SocketIO(http.listener) + const proto = new util.Protocol(config.log) + + proto.addRequest('ss-join', ['multiaddr', 'string', 'function'], join) + proto.addRequest('ss-leave', ['multiaddr'], leave) + proto.addRequest('disconnect', [], disconnect) + proto.addRequest('ss-dial', ['multiaddr', 'multiaddr', 'string', 'function'], dial) // dialFrom, dialTo, dialId, cb + io.on('connection', handle) + + log('create new server', config) + + const peers = {} + const nonces = {} + + this.peers = () => { + return peers + } + + function safeEmit (addr, event, arg) { + const peer = peers[addr] + if (!peer) { + log('trying to emit %s but peer is gone', event) + return + } + + peer.emit(event, arg) + } + + function handle (socket) { + socket.addrs = [] + socket.cleanaddrs = {} + sp(socket, { + codec: 'buffer' + }) + proto.handleSocket(socket) + } + + // join this signaling server network + function join (socket, multiaddr, pub, cb) { + const log = config.log.bind(config.log, '[' + socket.id + ']') + + if (config.strictMultiaddr && !util.validateMa(multiaddr)) { + return cb(new Error('Invalid multiaddr')) + } + + if (config.cryptoChallenge) { + if (!pub.length) { + return cb(new Error('Crypto Challenge required but no Id provided')) + } + + if (!nonces[socket.id]) { + nonces[socket.id] = {} + } + + if (nonces[socket.id][multiaddr]) { + log('response cryptoChallenge', multiaddr) + + nonces[socket.id][multiaddr].key.verify(nonces[socket.id][multiaddr].nonce, Buffer.from(pub, 'hex'), (err, ok) => { + if (err) { return cb(new Error('Crypto error')) } + if (!ok) { return cb(new Error('Signature Invalid')) } + + joinFinalize(socket, multiaddr, cb) + }) + } else { + const addr = multiaddr.split('ipfs/').pop() + + log('do cryptoChallenge', multiaddr, addr) + + util.getIdAndValidate(pub, addr, (err, key) => { + if (err) return cb(err) + const nonce = uuid() + uuid() + + socket.once('disconnect', () => { + delete nonces[socket.id] + }) + + nonces[socket.id][multiaddr] = { nonce: nonce, key: key } + cb(null, nonce) + }) + } + } else joinFinalize(socket, multiaddr, cb) + } + + function joinFinalize (socket, multiaddr, cb) { + const log = config.log.bind(config.log, '[' + socket.id + ']') + peers[multiaddr] = socket + socket.addrs.push(multiaddr) + log('registered as', multiaddr) + + // discovery + + let refreshInterval = setInterval(sendPeers, config.refreshPeerListIntervalMS) + + socket.once('ss-leave', function handleLeave (ma) { + if (ma === multiaddr) { + stopSendingPeers() + } else { + socket.once('ss-leave', handleLeave) + } + }) + + socket.once('disconnect', stopSendingPeers) + + sendPeers() + + function sendPeers () { + Object.keys(peers).forEach((mh) => { + if (mh === multiaddr) { + return + } + + safeEmit(mh, 'ws-peer', multiaddr) + }) + } + + function stopSendingPeers () { + if (refreshInterval) { + clearInterval(refreshInterval) + refreshInterval = null + } + } + + cb() + } + + function leave (socket, multiaddr) { + if (peers[multiaddr]) { + delete peers[multiaddr] + } + } + + function disconnect (socket) { + Object.keys(peers).forEach((mh) => { + if (peers[mh].id === socket.id) { + delete peers[mh] + } + }) + } + + function dial (socket, from, to, dialId, cb) { + const log = config.log.bind(config.log, '[' + dialId + ']') + const s = socket.addrs.filter((a) => a === from)[0] + + if (!s) { + return cb(new Error('Not authorized for this address')) + } + + log(from, 'is dialing', to) + const peer = peers[to] + + if (!peer) { + return cb(new Error('Peer not found')) + } + + socket.createProxy(dialId + '.dialer', peer) + + peer.emit('ss-incomming', dialId, from, err => { + if (err) { + return cb(err) + } + + peer.createProxy(dialId + '.listener', socket) + cb() + }) + } + + return this +} diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 0000000..b2e3752 --- /dev/null +++ b/src/utils.js @@ -0,0 +1,120 @@ +'use strict' + +const multiaddr = require('multiaddr') +const Id = require('peer-id') +const crypto = require('libp2p-crypto') +const mafmt = require('mafmt') + +function isIP (ma) { + const protos = ma.protos() + + if (protos[0].code !== 4 && protos[0].code !== 41) { + return false + } + if (protos[1].code !== 6 && protos[1].code !== 17) { + return false + } + + return true +} + +function cleanUrlSIO (ma) { + const maStrSplit = ma.toString().split('/') + + if (isIP(ma)) { + if (maStrSplit[1] === 'ip4') { + return 'http://' + maStrSplit[2] + ':' + maStrSplit[4] + } else if (maStrSplit[1] === 'ip6') { + return 'http://[' + maStrSplit[2] + ']:' + maStrSplit[4] + } else { + throw new Error('invalid multiaddr: ' + ma.toString()) + } + } else if (multiaddr.isName(ma)) { + const wsProto = ma.protos()[1].name + if (wsProto === 'ws') { + return 'http://' + maStrSplit[2] + } else if (wsProto === 'wss') { + return 'https://' + maStrSplit[2] + } else { + throw new Error('invalid multiaddr: ' + ma.toString()) + } + } else { + throw new Error('invalid multiaddr: ' + ma.toString()) + } +} + +const types = { + string: (v) => (typeof v === 'string'), + object: (v) => (typeof v === 'object'), + multiaddr: (v) => { + if (!types.string(v)) { return } + + try { + multiaddr(v) + return true + } catch (err) { + return false + } + }, + function: (v) => (typeof v === 'function') +} + +function validate (def, data) { + if (!Array.isArray(data)) throw new Error('Data is not an array') + def.forEach((type, index) => { + if (!types[type]) { + throw new Error('Type ' + type + ' does not exist') + } + + if (!types[type](data[index])) { + throw new Error('Data at index ' + index + ' is invalid for type ' + type) + } + }) +} + +function Protocol (log) { + log = log || function noop () {} + + this.requests = {} + this.addRequest = (name, def, handle) => { + this.requests[name] = { def: def, handle: handle } + } + this.handleSocket = (socket) => { + socket.r = {} + for (let request in this.requests) { + const r = this.requests[request] + socket.on(request, function () { + const data = [...arguments] + try { + validate(r.def, data) + data.unshift(socket) + r.handle.apply(null, data) + } catch (err) { + log(err) + log('peer %s has sent invalid data for request %s', socket.id || '', request, data) + } + }) + } + } +} + +function getIdAndValidate (pub, id, cb) { + Id.createFromPubKey(Buffer.from(pub, 'hex'), (err, _id) => { + if (err) { + return cb(new Error('Crypto error')) + } + + if (_id.toB58String() !== id) { + return cb(new Error('Id is not matching')) + } + + return cb(null, crypto.keys.unmarshalPublicKey(Buffer.from(pub, 'hex'))) + }) +} + +exports = module.exports +exports.cleanUrlSIO = cleanUrlSIO +exports.validate = validate +exports.Protocol = Protocol +exports.getIdAndValidate = getIdAndValidate +exports.validateMa = (ma) => mafmt.WebSocketStar.matches(multiaddr(ma)) diff --git a/test/.jshintrc b/test/.jshintrc new file mode 100644 index 0000000..3971b28 --- /dev/null +++ b/test/.jshintrc @@ -0,0 +1,8 @@ +{ + "node": true, + "esnext": true, + "asi": true, + "mocha": true, + "-W016": true, + "unused": true +} diff --git a/test/rendezvous.spec.js b/test/rendezvous.spec.js new file mode 100644 index 0000000..bc8c62e --- /dev/null +++ b/test/rendezvous.spec.js @@ -0,0 +1,195 @@ +/* eslint-env mocha */ +'use strict' + +const chai = require('chai') +const dirtyChai = require('dirty-chai') +const expect = chai.expect +chai.use(dirtyChai) +const io = require('socket.io-client') +const multiaddr = require('multiaddr') +const uuid = require('uuid') + +const rendezvous = require('../src') + +describe('signalling', () => { + const sioOptions = { + transports: ['websocket'], + 'force new connection': true + } + + let sioUrl + let r + let c1 + let c2 + let c3 + let c4 + + let c1mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo1') + let c2mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo2') + let c3mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo3') + let c4mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4') + + it('start and stop signalling server (default port)', (done) => { + rendezvous.start((err, server) => { + expect(err).to.not.exist() + expect(server.info.port).to.equal(13579) + expect(server.info.protocol).to.equal('http') + expect(server.info.address).to.equal('0.0.0.0') + server.stop(done) + }) + }) + + it('start and stop signalling server (custom port)', (done) => { + const options = { + port: 12345 + } + + rendezvous.start(options, (err, server) => { + expect(err).to.not.exist() + expect(server.info.port).to.equal(12345) + expect(server.info.protocol).to.equal('http') + expect(server.info.address).to.equal('0.0.0.0') + server.stop(done) + }) + }) + + it('start signalling server for client tests', (done) => { + const options = { + port: 12345, + refreshPeerListIntervalMS: 1000, + cryptoChallenge: false, + strictMultiaddr: false + } + + rendezvous.start(options, (err, server) => { + expect(err).to.not.exist() + expect(server.info.port).to.equal(12345) + expect(server.info.protocol).to.equal('http') + expect(server.info.address).to.equal('0.0.0.0') + sioUrl = server.info.uri + r = server + done() + }) + }) + + it('zero peers', () => { + expect(Object.keys(r.peers).length).to.equal(0) + }) + + it('connect one client', (done) => { + c1 = io.connect(sioUrl, sioOptions) + c1.on('connect', done) + }) + + it('connect three more clients', (done) => { + let count = 0 + + c2 = io.connect(sioUrl, sioOptions) + c3 = io.connect(sioUrl, sioOptions) + c4 = io.connect(sioUrl, sioOptions) + + c2.on('connect', connected) + c3.on('connect', connected) + c4.on('connect', connected) + + function connected () { + if (++count === 3) { + done() + } + } + }) + + it('ss-join first client', (done) => { + c1.emit('ss-join', c1mh.toString(), '', err => { + expect(err).to.not.exist() + expect(Object.keys(r.peers()).length).to.equal(1) + done() + }) + }) + + it('ss-join and ss-leave second client', (done) => { + c2.emit('ss-join', c2mh.toString(), '', err => { + expect(err).to.not.exist() + expect(Object.keys(r.peers()).length).to.equal(2) + c2.emit('ss-leave', c2mh.toString()) + + setTimeout(() => { + expect(Object.keys(r.peers()).length).to.equal(1) + done() + }, 10) + }) + }) + + it('ss-join and disconnect third client', (done) => { + c3.emit('ss-join', c3mh.toString(), '', err => { + expect(err).to.not.exist() + expect(Object.keys(r.peers()).length).to.equal(2) + c3.disconnect() + setTimeout(() => { + expect(Object.keys(r.peers()).length).to.equal(1) + done() + }, 10) + }) + }) + + it('ss-join the fourth', (done) => { + c1.once('ws-peer', (multiaddr) => { + expect(multiaddr).to.equal(c4mh.toString()) + expect(Object.keys(r.peers()).length).to.equal(2) + done() + }) + c4.emit('ss-join', c4mh.toString(), '', () => {}) + }) + + it('c1 dial c4', done => { + const dialId = uuid() + c4.once('ss-incomming', (dialId, dialFrom, cb) => { + expect(dialId).to.eql(dialId) + expect(dialFrom).to.eql(c1mh.toString()) + cb() + }) + c1.emit('ss-dial', c1mh.toString(), c4mh.toString(), dialId, err => { + expect(err).to.not.exist() + done() + }) + }) + + it('c1 dial c2 fail (does not exist() anymore)', done => { + const dialId = uuid() + c1.emit('ss-dial', c1mh.toString(), c2mh.toString(), dialId, err => { + expect(err).to.exist() + done() + }) + }) + + it('disconnects every client', (done) => { + [c1, c2, c3, c4].forEach((c) => c.disconnect()) + done() + }) + + it('emits ws-peer every second', (done) => { + let peersEmitted = 0 + + c1 = io.connect(sioUrl, sioOptions) + c2 = io.connect(sioUrl, sioOptions) + c1.emit('ss-join', '/ip4/0.0.0.0', '', err => expect(err).to.not.exist()) + c2.emit('ss-join', '/ip4/127.0.0.1', '', err => expect(err).to.not.exist()) + + c1.on('ws-peer', (p) => { + expect(p).to.be.equal('/ip4/127.0.0.1') + check() + }) + + function check () { + if (++peersEmitted === 2) { + done() + } + } + }).timeout(4000) + + it('stop signalling server', (done) => { + c1.disconnect() + c2.disconnect() + r.stop(done) + }) +}) From 047a76dce8bc7ac4d7abec3ec00112c244ab8173 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 8 Sep 2017 10:43:04 +0100 Subject: [PATCH 03/75] chore: update contributors --- package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ade2d2e..2ce2a9e 100644 --- a/package.json +++ b/package.json @@ -56,5 +56,8 @@ "bugs": { "url": "https://github.com/libp2p/js-libp2p-websocket-star/issues" }, - "homepage": "https://github.com/libp2p/js-libp2p-websocket-star#readme" -} + "homepage": "https://github.com/libp2p/js-libp2p-websocket-star#readme", + "contributors": [ + "David Dias " + ] +} \ No newline at end of file From 9d2ac8ada1935f695d74ce331ec98739a0ae45cd Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 8 Sep 2017 10:43:04 +0100 Subject: [PATCH 04/75] chore: release version v0.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ce2a9e..7c86473 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-websocket-star-rendezvous", - "version": "0.0.0", + "version": "0.1.0", "description": "The rendezvous service for libp2p-webrtc-star", "bin": { "websockets-star": "src/rendezvous/bin.js" From 7ff704cebc987790d9d38dcc3d26657c16e43168 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 8 Sep 2017 10:47:27 +0100 Subject: [PATCH 05/75] fix: add main to package.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7c86473..aad18e2 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "libp2p-websocket-star-rendezvous", "version": "0.1.0", "description": "The rendezvous service for libp2p-webrtc-star", + "main": "src/index.js", "bin": { "websockets-star": "src/rendezvous/bin.js" }, @@ -60,4 +61,4 @@ "contributors": [ "David Dias " ] -} \ No newline at end of file +} From 010ed910885e27cff7fa8cf0067c913f0b6aa2a0 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 8 Sep 2017 10:47:31 +0100 Subject: [PATCH 06/75] chore: update contributors --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index aad18e2..ab37a2b 100644 --- a/package.json +++ b/package.json @@ -61,4 +61,4 @@ "contributors": [ "David Dias " ] -} +} \ No newline at end of file From 5091acec864a3832244f618e13eef85cf2b6b371 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 8 Sep 2017 10:47:31 +0100 Subject: [PATCH 07/75] chore: release version v0.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ab37a2b..4c0c213 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-websocket-star-rendezvous", - "version": "0.1.0", + "version": "0.1.1", "description": "The rendezvous service for libp2p-webrtc-star", "main": "src/index.js", "bin": { From 3049ca8fcd1d807bc1d4b532d7033cafb1be55f6 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 8 Sep 2017 10:48:42 +0100 Subject: [PATCH 08/75] fix: point to right location of bin --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4c0c213..8089ad1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "The rendezvous service for libp2p-webrtc-star", "main": "src/index.js", "bin": { - "websockets-star": "src/rendezvous/bin.js" + "websockets-star": "src/bin.js" }, "scripts": { "rendezvous": "node sig-server/src/bin.js", @@ -61,4 +61,4 @@ "contributors": [ "David Dias " ] -} \ No newline at end of file +} From 1cf64d3475f22abfee59c9ac5dad426e571ef0d6 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 8 Sep 2017 10:48:49 +0100 Subject: [PATCH 09/75] chore: update contributors --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8089ad1..d9df329 100644 --- a/package.json +++ b/package.json @@ -61,4 +61,4 @@ "contributors": [ "David Dias " ] -} +} \ No newline at end of file From ab8c87ee8ceb65efaffbdc66f6bf2b94cdc60328 Mon Sep 17 00:00:00 2001 From: David Dias Date: Fri, 8 Sep 2017 10:48:49 +0100 Subject: [PATCH 10/75] chore: release version v0.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d9df329..7dffb6b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-websocket-star-rendezvous", - "version": "0.1.1", + "version": "0.1.2", "description": "The rendezvous service for libp2p-webrtc-star", "main": "src/index.js", "bin": { From de8480710eaa0263b09fccda420d7cb2dd2c476f Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Mon, 11 Sep 2017 15:47:41 +0200 Subject: [PATCH 11/75] fix: small name fix --- package.json | 2 +- src/bin.js | 5 +++-- src/index.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 7dffb6b..1bcf8a3 100644 --- a/package.json +++ b/package.json @@ -61,4 +61,4 @@ "contributors": [ "David Dias " ] -} \ No newline at end of file +} diff --git a/src/bin.js b/src/bin.js index 3e21a1d..b14f45d 100755 --- a/src/bin.js +++ b/src/bin.js @@ -10,7 +10,8 @@ let server signalling.start({ port: argv.port || argv.p || process.env.PORT || 9090, host: argv.host || argv.h || process.env.HOST || '0.0.0.0', - cryptoChallenge: !(argv.disableCryptoChallenge || process.env.DISABLE_CRYPTO_CHALLENGE) + cryptoChallenge: !(argv.disableCryptoChallenge || process.env.DISABLE_CRYPTO_CHALLENGE), + strictMultiaddr: !(argv.disableStrictMultiaddr || process.env.DISABLE_STRICT_MULTIADDR) }, (err, _server) => { if (err) { throw err @@ -22,7 +23,7 @@ signalling.start({ process.on('SIGINT', () => { server.stop(() => { - console.log('Signalling server stopped') + console.log('Rendezvous server stopped') process.exit() }) }) diff --git a/src/index.js b/src/index.js index 8afc1e0..a971828 100644 --- a/src/index.js +++ b/src/index.js @@ -37,7 +37,7 @@ exports.start = (options, callback) => { return callback(err) } - log('signaling server has started on: ' + http.info.uri) + log('rendezvous server has started on: ' + http.info.uri) http.peers = require('./routes')(config, http).peers From 18b805be11219a5709a4dddd79f388e9f43a4e1d Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Fri, 22 Sep 2017 13:52:53 +0200 Subject: [PATCH 12/75] chore: Update hapi - fix: errors are {} - feat: Better info-page --- package.json | 2 +- src/bin.js | 4 ++-- src/index.html | 3 ++- src/routes.js | 8 ++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 1bcf8a3..24843e6 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "async": "^2.5.0", "data-queue": "0.0.2", "debug": "^3.0.1", - "hapi": "^16.5.2", + "hapi": "^16.6.0", "inert": "^4.2.1", "libp2p-crypto": "^0.10.3", "mafmt": "^3.0.1", diff --git a/src/bin.js b/src/bin.js index b14f45d..c4b6f26 100755 --- a/src/bin.js +++ b/src/bin.js @@ -22,8 +22,8 @@ signalling.start({ }) process.on('SIGINT', () => { - server.stop(() => { + server.stop((e) => { console.log('Rendezvous server stopped') - process.exit() + process.exit(e ? 2 : 0) }) }) diff --git a/src/index.html b/src/index.html index 984efbf..f86356f 100644 --- a/src/index.html +++ b/src/index.html @@ -22,8 +22,9 @@

This is a libp2p-websocket-star signalling-server

-

Signaling Servers are used in libp2p to allow browsers and clients with restricted port-forwarding to communicate

+

Signaling Servers are used in libp2p to allow browsers and clients with restricted port-forwarding
to communicate with other peers in the libp2p network

+ » Learn more
diff --git a/src/routes.js b/src/routes.js index 3704e64..c5b8ea6 100644 --- a/src/routes.js +++ b/src/routes.js @@ -49,12 +49,12 @@ module.exports = (config, http) => { const log = config.log.bind(config.log, '[' + socket.id + ']') if (config.strictMultiaddr && !util.validateMa(multiaddr)) { - return cb(new Error('Invalid multiaddr')) + return cb('Invalid multiaddr') } if (config.cryptoChallenge) { if (!pub.length) { - return cb(new Error('Crypto Challenge required but no Id provided')) + return cb('Crypto Challenge required but no Id provided') } if (!nonces[socket.id]) { @@ -65,8 +65,8 @@ module.exports = (config, http) => { log('response cryptoChallenge', multiaddr) nonces[socket.id][multiaddr].key.verify(nonces[socket.id][multiaddr].nonce, Buffer.from(pub, 'hex'), (err, ok) => { - if (err) { return cb(new Error('Crypto error')) } - if (!ok) { return cb(new Error('Signature Invalid')) } + if (err) { return cb('Crypto error') } // the errors NEED to be strings otherwise JSON.stringify() turns them into {} + if (!ok) { return cb('Signature Invalid') } joinFinalize(socket, multiaddr, cb) }) From 1f163b877007477435a42439d5259de6aeddcaad Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Fri, 22 Sep 2017 16:38:01 +0200 Subject: [PATCH 13/75] fix: discovery fix - fix: debug log name Look at the discovery fix. Turns out sometimes not even 'const' can save you from js scope weirdness. --- src/config.js | 4 ++-- src/routes.js | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/config.js b/src/config.js index 234d7a2..b472ce8 100644 --- a/src/config.js +++ b/src/config.js @@ -1,8 +1,8 @@ 'use strict' const debug = require('debug') -const log = debug('signalling-server') -log.error = debug('signalling-server:error') +const log = debug('libp2p-websocket-star-rendezvous') +log.error = debug('libp2p-websocket-star-rendezvous:error') module.exports = { log: log, diff --git a/src/routes.js b/src/routes.js index c5b8ea6..98bdeb4 100644 --- a/src/routes.js +++ b/src/routes.js @@ -18,9 +18,11 @@ module.exports = (config, http) => { log('create new server', config) - const peers = {} + const peers = this._peers = {} const nonces = {} + const getPeers = () => this._peers + this.peers = () => { return peers } @@ -92,7 +94,7 @@ module.exports = (config, http) => { function joinFinalize (socket, multiaddr, cb) { const log = config.log.bind(config.log, '[' + socket.id + ']') - peers[multiaddr] = socket + getPeers()[multiaddr] = socket socket.addrs.push(multiaddr) log('registered as', multiaddr) @@ -102,6 +104,7 @@ module.exports = (config, http) => { socket.once('ss-leave', function handleLeave (ma) { if (ma === multiaddr) { + socket.addrs = socket.addrs.filter(m => m != ma) stopSendingPeers() } else { socket.once('ss-leave', handleLeave) @@ -113,7 +116,7 @@ module.exports = (config, http) => { sendPeers() function sendPeers () { - Object.keys(peers).forEach((mh) => { + Object.keys(getPeers()).forEach((mh) => { if (mh === multiaddr) { return } From cc9ae191cfba74ac460669f02debfb2adb068762 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Fri, 22 Sep 2017 16:40:25 +0200 Subject: [PATCH 14/75] Fix lint --- src/routes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes.js b/src/routes.js index 98bdeb4..3b2b615 100644 --- a/src/routes.js +++ b/src/routes.js @@ -104,7 +104,7 @@ module.exports = (config, http) => { socket.once('ss-leave', function handleLeave (ma) { if (ma === multiaddr) { - socket.addrs = socket.addrs.filter(m => m != ma) + socket.addrs = socket.addrs.filter(m => m !== ma) stopSendingPeers() } else { socket.once('ss-leave', handleLeave) From 4a1ffccb9bdd8c597b3279c631a5a8b133a1130f Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Fri, 22 Sep 2017 16:41:07 +0200 Subject: [PATCH 15/75] refactor: rename test --- test/rendezvous.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rendezvous.spec.js b/test/rendezvous.spec.js index bc8c62e..1082433 100644 --- a/test/rendezvous.spec.js +++ b/test/rendezvous.spec.js @@ -11,7 +11,7 @@ const uuid = require('uuid') const rendezvous = require('../src') -describe('signalling', () => { +describe('rendezvous', () => { const sioOptions = { transports: ['websocket'], 'force new connection': true From fa518b17ebaf419d311d69bd6c5fb4c5849838de Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Fri, 22 Sep 2017 18:12:14 +0200 Subject: [PATCH 16/75] feat: metrics (WIP) - feat: Dockerfile - fix/feat: various other things --- .gitignore | 1 + Dockerfile | 6 +++++ package.json | 5 ++++- src/bin.js | 3 ++- src/config.js | 3 ++- src/index.js | 3 +++ src/routes.js | 50 +++++++++++++++++++++++++++++------------ test/rendezvous.spec.js | 3 ++- 8 files changed, 56 insertions(+), 18 deletions(-) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index fc26dd1..b825b8b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ test/setup/tmp-disposable-nodes-addrs.json dist coverage **/*.swp +**/*.bak examples/sub-module/**/bundle.js examples/sub-module/**/*-minified.js examples/sub-module/*-bundle.js diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cb8547c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM node:8 +COPY . /src +WORKDIR /src +RUN npm i --production +CMD ["npm", "start"] +EXPOSE 9090 diff --git a/package.json b/package.json index 24843e6..6db0906 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "websockets-star": "src/bin.js" }, "scripts": { - "rendezvous": "node sig-server/src/bin.js", + "rendezvous": "node src/bin.js", + "start": "node src/bin.js", "lint": "aegir-lint", "test": "aegir-test --env node", "release": "aegir-release --env no-build", @@ -26,6 +27,7 @@ "async": "^2.5.0", "data-queue": "0.0.2", "debug": "^3.0.1", + "epimetheus": "^1.0.54", "hapi": "^16.6.0", "inert": "^4.2.1", "libp2p-crypto": "^0.10.3", @@ -36,6 +38,7 @@ "once": "^1.4.0", "peer-id": "^0.10.1", "peer-info": "^0.11.0", + "prom-client": "^10.1.0", "socket.io": "^2.0.3", "socket.io-client": "^2.0.3", "socket.io-pull-stream": "^0.1.1", diff --git a/src/bin.js b/src/bin.js index c4b6f26..cd379e7 100755 --- a/src/bin.js +++ b/src/bin.js @@ -11,7 +11,8 @@ signalling.start({ port: argv.port || argv.p || process.env.PORT || 9090, host: argv.host || argv.h || process.env.HOST || '0.0.0.0', cryptoChallenge: !(argv.disableCryptoChallenge || process.env.DISABLE_CRYPTO_CHALLENGE), - strictMultiaddr: !(argv.disableStrictMultiaddr || process.env.DISABLE_STRICT_MULTIADDR) + strictMultiaddr: !(argv.disableStrictMultiaddr || process.env.DISABLE_STRICT_MULTIADDR), + metrics: true }, (err, _server) => { if (err) { throw err diff --git a/src/config.js b/src/config.js index b472ce8..1f6e8f2 100644 --- a/src/config.js +++ b/src/config.js @@ -19,5 +19,6 @@ module.exports = { }, refreshPeerListIntervalMS: 10000, cryptoChallenge: true, - strictMultiaddr: true + strictMultiaddr: false, + metrics: false } diff --git a/src/index.js b/src/index.js index a971828..c2624bf 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,7 @@ const Hapi = require('hapi') const merge = require('merge-recursive').recursive const path = require('path') +const epimetheus = require('epimetheus') exports = module.exports @@ -53,5 +54,7 @@ exports.start = (options, callback) => { }) }) + if (config.metrics) epimetheus.instrument(http) + return http } diff --git a/src/routes.js b/src/routes.js index 3b2b615..e622230 100644 --- a/src/routes.js +++ b/src/routes.js @@ -4,11 +4,20 @@ const SocketIO = require('socket.io') const sp = require('socket.io-pull-stream') const util = require('./utils') const uuid = require('uuid') +const client = require("prom-client") +const fake = { + gauge: { + set: () => {} + }, + counter: { + inc: () => {} + } +} module.exports = (config, http) => { const log = config.log const io = new SocketIO(http.listener) - const proto = new util.Protocol(config.log) + const proto = new util.Protocol(log) proto.addRequest('ss-join', ['multiaddr', 'string', 'function'], join) proto.addRequest('ss-leave', ['multiaddr'], leave) @@ -18,17 +27,21 @@ module.exports = (config, http) => { log('create new server', config) - const peers = this._peers = {} + this._peers = {} const nonces = {} + const peers_metric = config.metrics ? new client.Gauge({ name: 'rendezvous_peers', help: 'peers online now' }) : fake.gauge + const dials_success_total = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total_success', help: 'sucessfully completed dials since server started' }) : fake.counter + const dials_failure_total = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total_failure', help: 'failed dials since server started' }) : fake.counter + const dials_total = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total', help: 'all dials since server started' }) : fake.counter + const getPeers = () => this._peers + const refreshMetrics = () => peers_metric.set(Object.keys(getPeers()).length) - this.peers = () => { - return peers - } + this.peers = () => getPeers() function safeEmit (addr, event, arg) { - const peer = peers[addr] + const peer = getPeers()[addr] if (!peer) { log('trying to emit %s but peer is gone', event) return @@ -95,6 +108,7 @@ module.exports = (config, http) => { function joinFinalize (socket, multiaddr, cb) { const log = config.log.bind(config.log, '[' + socket.id + ']') getPeers()[multiaddr] = socket + refreshMetrics() socket.addrs.push(multiaddr) log('registered as', multiaddr) @@ -104,6 +118,7 @@ module.exports = (config, http) => { socket.once('ss-leave', function handleLeave (ma) { if (ma === multiaddr) { + refreshMetrics() socket.addrs = socket.addrs.filter(m => m !== ma) stopSendingPeers() } else { @@ -136,41 +151,48 @@ module.exports = (config, http) => { } function leave (socket, multiaddr) { - if (peers[multiaddr]) { - delete peers[multiaddr] + if (getPeers()[multiaddr]) { + delete getPeers()[multiaddr] } } function disconnect (socket) { - Object.keys(peers).forEach((mh) => { - if (peers[mh].id === socket.id) { - delete peers[mh] + Object.keys(getPeers()).forEach((mh) => { + if (getPeers()[mh].id === socket.id) { + delete getPeers()[mh] } }) + refreshMetrics() } function dial (socket, from, to, dialId, cb) { const log = config.log.bind(config.log, '[' + dialId + ']') const s = socket.addrs.filter((a) => a === from)[0] + dials_total.inc() + if (!s) { - return cb(new Error('Not authorized for this address')) + dials_failure_total.inc() + return cb('Not authorized for this address') } log(from, 'is dialing', to) - const peer = peers[to] + const peer = getPeers()[to] if (!peer) { - return cb(new Error('Peer not found')) + dials_failure_total.inc() + return cb('Peer not found') } socket.createProxy(dialId + '.dialer', peer) peer.emit('ss-incomming', dialId, from, err => { if (err) { + dials_failure_total.inc() return cb(err) } + dials_success_total.inc() peer.createProxy(dialId + '.listener', socket) cb() }) diff --git a/test/rendezvous.spec.js b/test/rendezvous.spec.js index 1082433..6740b2e 100644 --- a/test/rendezvous.spec.js +++ b/test/rendezvous.spec.js @@ -58,7 +58,8 @@ describe('rendezvous', () => { port: 12345, refreshPeerListIntervalMS: 1000, cryptoChallenge: false, - strictMultiaddr: false + strictMultiaddr: false, + metrics: true } rendezvous.start(options, (err, server) => { From 585525e5a3a10ab46b2191fcdd2a6967ea9e5763 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Fri, 22 Sep 2017 18:14:33 +0200 Subject: [PATCH 17/75] fix: lint --- src/routes.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/routes.js b/src/routes.js index e622230..af880ae 100644 --- a/src/routes.js +++ b/src/routes.js @@ -4,7 +4,7 @@ const SocketIO = require('socket.io') const sp = require('socket.io-pull-stream') const util = require('./utils') const uuid = require('uuid') -const client = require("prom-client") +const client = require('prom-client') const fake = { gauge: { set: () => {} @@ -30,13 +30,13 @@ module.exports = (config, http) => { this._peers = {} const nonces = {} - const peers_metric = config.metrics ? new client.Gauge({ name: 'rendezvous_peers', help: 'peers online now' }) : fake.gauge - const dials_success_total = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total_success', help: 'sucessfully completed dials since server started' }) : fake.counter - const dials_failure_total = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total_failure', help: 'failed dials since server started' }) : fake.counter - const dials_total = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total', help: 'all dials since server started' }) : fake.counter + const peersMetric = config.metrics ? new client.Gauge({ name: 'rendezvous_peers', help: 'peers online now' }) : fake.gauge + const dialsSucessTotal = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total_success', help: 'sucessfully completed dials since server started' }) : fake.counter + const dialsFailureTotal = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total_failure', help: 'failed dials since server started' }) : fake.counter + const dialsTotal = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total', help: 'all dials since server started' }) : fake.counter const getPeers = () => this._peers - const refreshMetrics = () => peers_metric.set(Object.keys(getPeers()).length) + const refreshMetrics = () => peersMetric.set(Object.keys(getPeers()).length) this.peers = () => getPeers() @@ -169,10 +169,10 @@ module.exports = (config, http) => { const log = config.log.bind(config.log, '[' + dialId + ']') const s = socket.addrs.filter((a) => a === from)[0] - dials_total.inc() + dialsTotal.inc() if (!s) { - dials_failure_total.inc() + dialsFailureTotal.inc() return cb('Not authorized for this address') } @@ -180,7 +180,7 @@ module.exports = (config, http) => { const peer = getPeers()[to] if (!peer) { - dials_failure_total.inc() + dialsFailureTotal.inc() return cb('Peer not found') } @@ -188,11 +188,11 @@ module.exports = (config, http) => { peer.emit('ss-incomming', dialId, from, err => { if (err) { - dials_failure_total.inc() + dialsFailureTotal.inc() return cb(err) } - dials_success_total.inc() + dialsSucessTotal.inc() peer.createProxy(dialId + '.listener', socket) cb() }) From 81c8eb75812dbd296f927355321bf121bee0932a Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Fri, 22 Sep 2017 19:08:01 +0200 Subject: [PATCH 18/75] feat: Joins metric - fix: config --- src/index.js | 4 ++-- src/routes.js | 37 +++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/index.js b/src/index.js index c2624bf..a33ed0d 100644 --- a/src/index.js +++ b/src/index.js @@ -1,9 +1,9 @@ 'use strict' const Hapi = require('hapi') -const merge = require('merge-recursive').recursive const path = require('path') const epimetheus = require('epimetheus') +const merge = require('merge-recursive').recursive exports = module.exports @@ -13,7 +13,7 @@ exports.start = (options, callback) => { options = {} } - const config = merge(require('./config'), options) + const config = merge(Object.assign({}, require('./config')), Object.assign({}, options)) const log = config.log const port = options.port || config.hapi.port diff --git a/src/routes.js b/src/routes.js index af880ae..9c713ea 100644 --- a/src/routes.js +++ b/src/routes.js @@ -18,6 +18,7 @@ module.exports = (config, http) => { const log = config.log const io = new SocketIO(http.listener) const proto = new util.Protocol(log) + const getConfig = () => config proto.addRequest('ss-join', ['multiaddr', 'string', 'function'], join) proto.addRequest('ss-leave', ['multiaddr'], leave) @@ -31,9 +32,12 @@ module.exports = (config, http) => { const nonces = {} const peersMetric = config.metrics ? new client.Gauge({ name: 'rendezvous_peers', help: 'peers online now' }) : fake.gauge - const dialsSucessTotal = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total_success', help: 'sucessfully completed dials since server started' }) : fake.counter + const dialsSuccessTotal = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total_success', help: 'sucessfully completed dials since server started' }) : fake.counter const dialsFailureTotal = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total_failure', help: 'failed dials since server started' }) : fake.counter const dialsTotal = config.metrics ? new client.Counter({ name: 'rendezvous_dials_total', help: 'all dials since server started' }) : fake.counter + const joinsSuccessTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total_success', help: 'sucessfully completed joins since server started' }) : fake.counter + const joinsFailureTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total_failure', help: 'failed joins since server started' }) : fake.counter + const joinsTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total', help: 'all joins since server started' }) : fake.counter const getPeers = () => this._peers const refreshMetrics = () => peersMetric.set(Object.keys(getPeers()).length) @@ -63,12 +67,16 @@ module.exports = (config, http) => { function join (socket, multiaddr, pub, cb) { const log = config.log.bind(config.log, '[' + socket.id + ']') - if (config.strictMultiaddr && !util.validateMa(multiaddr)) { + if (getConfig().strictMultiaddr && !util.validateMa(multiaddr)) { + joinsTotal.inc() + joinsFailureTotal.inc() return cb('Invalid multiaddr') } - if (config.cryptoChallenge) { + if (getConfig().cryptoChallenge) { if (!pub.length) { + joinsTotal.inc() + joinsFailureTotal.inc() return cb('Crypto Challenge required but no Id provided') } @@ -80,18 +88,23 @@ module.exports = (config, http) => { log('response cryptoChallenge', multiaddr) nonces[socket.id][multiaddr].key.verify(nonces[socket.id][multiaddr].nonce, Buffer.from(pub, 'hex'), (err, ok) => { - if (err) { return cb('Crypto error') } // the errors NEED to be strings otherwise JSON.stringify() turns them into {} + if (err || !ok) { + joinsTotal.inc() + joinsFailureTotal.inc() + } + if (err) { return cb('Crypto error') } // the errors NEED to be a string otherwise JSON.stringify() turns them into {} if (!ok) { return cb('Signature Invalid') } joinFinalize(socket, multiaddr, cb) }) } else { + joinsTotal.inc() const addr = multiaddr.split('ipfs/').pop() log('do cryptoChallenge', multiaddr, addr) util.getIdAndValidate(pub, addr, (err, key) => { - if (err) return cb(err) + if (err) { joinsFailureTotal.inc(); return cb(err) } const nonce = uuid() + uuid() socket.once('disconnect', () => { @@ -102,19 +115,23 @@ module.exports = (config, http) => { cb(null, nonce) }) } - } else joinFinalize(socket, multiaddr, cb) + } else { + joinsTotal.inc() + joinFinalize(socket, multiaddr, cb) + } } function joinFinalize (socket, multiaddr, cb) { - const log = config.log.bind(config.log, '[' + socket.id + ']') + const log = getConfig().log.bind(getConfig().log, '[' + socket.id + ']') getPeers()[multiaddr] = socket + joinsSuccessTotal.inc() refreshMetrics() socket.addrs.push(multiaddr) log('registered as', multiaddr) // discovery - let refreshInterval = setInterval(sendPeers, config.refreshPeerListIntervalMS) + let refreshInterval = setInterval(sendPeers, getConfig().refreshPeerListIntervalMS) socket.once('ss-leave', function handleLeave (ma) { if (ma === multiaddr) { @@ -166,7 +183,7 @@ module.exports = (config, http) => { } function dial (socket, from, to, dialId, cb) { - const log = config.log.bind(config.log, '[' + dialId + ']') + const log = getConfig().log.bind(getConfig().log, '[' + dialId + ']') const s = socket.addrs.filter((a) => a === from)[0] dialsTotal.inc() @@ -192,7 +209,7 @@ module.exports = (config, http) => { return cb(err) } - dialsSucessTotal.inc() + dialsSuccessTotal.inc() peer.createProxy(dialId + '.listener', socket) cb() }) From 4fbed33667529acae98731e322d85b00d441ee58 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sat, 23 Sep 2017 11:48:10 +0200 Subject: [PATCH 19/75] feat: Update README - feat: Use dumb-init in docker-image --- Dockerfile | 7 ++++--- README.md | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index cb8547c..174655e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM node:8 -COPY . /src -WORKDIR /src +RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && chmod +x /usr/local/bin/dumb-init +COPY . /app +WORKDIR /app RUN npm i --production -CMD ["npm", "start"] +ENTRYPOINT ["/usr/local/bin/dumb-init", "node", "src/bin.js"] EXPOSE 9090 diff --git a/README.md b/README.md index 76c05b3..534e643 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Nodes using `libp2p-websocket-star` will connect to a known point in the network `libp2p-websocket-star` comes with batteries included, that means that you can also spawn your own rendezvous point right from this module. To do that, first insall the module globally in your machine with: ```bash -> npm install --global libp2p-websocket-star +> npm install --global libp2p-websocket-star-rendezvous ``` This will install a `websockets-star` CLI tool. Now you can spawn the server with: @@ -35,6 +35,8 @@ Defaults: We host a rendezvous server at `ws-star-signal-1.servep2p.com` and `ws-star-signal-2.servep2p.com` that can be used for practical demos and experimentation, it **should not be used for apps in production**. +Additionally there is a rendezvous server at `ws-star-signal-3.servep2p.com` running the latest master version. + A libp2p-websocket-star address, using the signalling server we provide, looks like: `/dns4/ws-star-signal-1.servep2p.com/wss/p2p-websocket-star/ipfs/` From d7fba03316703ef02ff16c76d33797aa3fa4c9d4 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sat, 28 Oct 2017 13:42:44 +0200 Subject: [PATCH 20/75] feat: Link directly to readme in about page --- src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index f86356f..0931e3c 100644 --- a/src/index.html +++ b/src/index.html @@ -24,7 +24,7 @@

This is a libp2p-websocket-star signalling-server

Signaling Servers are used in libp2p to allow browsers and clients with restricted port-forwarding
to communicate with other peers in the libp2p network

- » Learn more + » Learn more From b422044b4759c411972536c726f71bd9ef39213f Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sat, 28 Oct 2017 13:52:19 +0200 Subject: [PATCH 21/75] chore: Update deps --- package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 6db0906..da359dc 100644 --- a/package.json +++ b/package.json @@ -26,21 +26,21 @@ "dependencies": { "async": "^2.5.0", "data-queue": "0.0.2", - "debug": "^3.0.1", - "epimetheus": "^1.0.54", - "hapi": "^16.6.0", + "debug": "^3.1.0", + "epimetheus": "^1.0.55", + "hapi": "^16.6.2", "inert": "^4.2.1", "libp2p-crypto": "^0.10.3", - "mafmt": "^3.0.1", + "mafmt": "^3.0.2", "merge-recursive": "0.0.3", "minimist": "^1.2.0", "multiaddr": "^3.0.1", "once": "^1.4.0", - "peer-id": "^0.10.1", + "peer-id": "^0.10.2", "peer-info": "^0.11.0", - "prom-client": "^10.1.0", - "socket.io": "^2.0.3", - "socket.io-client": "^2.0.3", + "prom-client": "^10.2.1", + "socket.io": "^2.0.4", + "socket.io-client": "^2.0.4", "socket.io-pull-stream": "^0.1.1", "uuid": "^3.1.0" }, From 4d8d5fccde5a39f9cf893e4c6b60a529c96dfae6 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sat, 28 Oct 2017 14:04:18 +0200 Subject: [PATCH 22/75] chore: Upgrade to new aegir - fix: lint --- package.json | 17 +++++++++-------- src/bin.js | 4 ++++ src/routes.js | 6 ++++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index da359dc..38539ab 100644 --- a/package.json +++ b/package.json @@ -9,13 +9,14 @@ "scripts": { "rendezvous": "node src/bin.js", "start": "node src/bin.js", - "lint": "aegir-lint", - "test": "aegir-test --env node", - "release": "aegir-release --env no-build", - "release-minor": "aegir-release --type minor --env no-build", - "release-major": "aegir-release --type major --env no-build", - "coverage": "aegir-coverage", - "coverage-publish": "aegir-coverage publish" + "lint": "aegir lint", + "build": "aegir build", + "test": "aegir test --target node", + "release": "aegir test release --target node", + "release-minor": "aegir release --type minor --target node", + "release-major": "aegir release --type major --target node", + "coverage": "aegir coverage", + "coverage-publish": "aegir coverage --provider coveralls" }, "keywords": [ "libp2p", @@ -48,7 +49,7 @@ "test": "test" }, "devDependencies": { - "aegir": "^11.0.2", + "aegir": "^12.1.1", "chai": "^4.1.2", "dirty-chai": "^2.0.1", "lodash": "^4.17.4" diff --git a/src/bin.js b/src/bin.js index cd379e7..7b52cb8 100755 --- a/src/bin.js +++ b/src/bin.js @@ -7,6 +7,8 @@ const argv = require('minimist')(process.argv.slice(2)) let server +/* eslint-disable no-console */ + signalling.start({ port: argv.port || argv.p || process.env.PORT || 9090, host: argv.host || argv.h || process.env.HOST || '0.0.0.0', @@ -28,3 +30,5 @@ process.on('SIGINT', () => { process.exit(e ? 2 : 0) }) }) + +/* eslint-enable no-console */ diff --git a/src/routes.js b/src/routes.js index 9c713ea..c76fd81 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1,5 +1,7 @@ 'use strict' +/* eslint-disable standard/no-callback-literal */ + const SocketIO = require('socket.io') const sp = require('socket.io-pull-stream') const util = require('./utils') @@ -63,6 +65,8 @@ module.exports = (config, http) => { proto.handleSocket(socket) } + /* eslint-disable standard/no-callback-literal - Needed because JSON.stringify(Error) returns "{}" */ + // join this signaling server network function join (socket, multiaddr, pub, cb) { const log = config.log.bind(config.log, '[' + socket.id + ']') @@ -215,5 +219,7 @@ module.exports = (config, http) => { }) } + /* eslint-enable standard/no-callback-literal */ + return this } From 1ee8e4bff27c6fecd4fc16b085077bde3f0a891d Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sat, 28 Oct 2017 14:07:39 +0200 Subject: [PATCH 23/75] refactor: lint comments --- src/bin.js | 2 -- src/routes.js | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/bin.js b/src/bin.js index 7b52cb8..5a75c4d 100755 --- a/src/bin.js +++ b/src/bin.js @@ -30,5 +30,3 @@ process.on('SIGINT', () => { process.exit(e ? 2 : 0) }) }) - -/* eslint-enable no-console */ diff --git a/src/routes.js b/src/routes.js index c76fd81..65a3ebc 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1,6 +1,7 @@ 'use strict' /* eslint-disable standard/no-callback-literal */ +// Needed because JSON.stringify(Error) returns "{}" const SocketIO = require('socket.io') const sp = require('socket.io-pull-stream') @@ -65,8 +66,6 @@ module.exports = (config, http) => { proto.handleSocket(socket) } - /* eslint-disable standard/no-callback-literal - Needed because JSON.stringify(Error) returns "{}" */ - // join this signaling server network function join (socket, multiaddr, pub, cb) { const log = config.log.bind(config.log, '[' + socket.id + ']') @@ -219,7 +218,5 @@ module.exports = (config, http) => { }) } - /* eslint-enable standard/no-callback-literal */ - return this } From df53c25c7be0b2ee05b4088211229c88772cb773 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sat, 28 Oct 2017 14:10:36 +0200 Subject: [PATCH 24/75] fix: {webrtc => websocket} --- .gitignore | 1 + README.md | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b825b8b..1688399 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ yarn.lock test/setup/tmp-disposable-nodes-addrs.json dist coverage +.nyc_output **/*.swp **/*.bak examples/sub-module/**/bundle.js diff --git a/README.md b/README.md index 534e643..c37f86a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Coverage](https://coveralls.io/repos/github/libp2p/js-libp2p-websocket-star-rendezvous/badge.svg?branch=master)](https://coveralls.io/github/libp2p/js-libp2p-websocket-star-rendezvous?branch=master) [![david-dm](https://david-dm.org/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websocket-star-rendezvous) -> The rendezvous service for [libp2p-webrtc-star](https://github.com/libp2p/js-libp2p-websocket-star). +> The rendezvous service for [libp2p-websocket-star](https://github.com/libp2p/js-libp2p-websocket-star). ## Descriptions diff --git a/package.json b/package.json index 38539ab..9477a5f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "libp2p-websocket-star-rendezvous", "version": "0.1.2", - "description": "The rendezvous service for libp2p-webrtc-star", + "description": "The rendezvous service for libp2p-websocket-star", "main": "src/index.js", "bin": { "websockets-star": "src/bin.js" From 9af56078ef81f13e8822cce32311c88693ded042 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sat, 28 Oct 2017 14:26:02 +0200 Subject: [PATCH 25/75] Update README --- README.md | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c37f86a..7b155c2 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Nodes using `libp2p-websocket-star` will connect to a known point in the network ## Usage -`libp2p-websocket-star` comes with batteries included, that means that you can also spawn your own rendezvous point right from this module. To do that, first insall the module globally in your machine with: +`libp2p-websocket-star-rendezvous` is the rendezvous server required for `libp2p-websocket-star` and can be used to start a rendezvous server for development. To do that, first insall the module globally in your machine with: ```bash > npm install --global libp2p-websocket-star-rendezvous @@ -31,6 +31,15 @@ Defaults: - `port` - 13579 - `host` - '0.0.0.0' +## Docker + +A docker image is offered for running this service in production + +``` +docker pull libp2p/websocket-star-rendezvous:release +docker run -d -p 13579:8090 -n rendezvous libp2p/websocket-star-rendezvous:release +``` + ## Hosted Rendezvous server We host a rendezvous server at `ws-star-signal-1.servep2p.com` and `ws-star-signal-2.servep2p.com` that can be used for practical demos and experimentation, it **should not be used for apps in production**. @@ -43,4 +52,29 @@ A libp2p-websocket-star address, using the signalling server we provide, looks l Note: The address above indicates WebSockets Secure, which can be accessed from both http and https. + +### This module uses `pull-streams` + +We expose a streaming interface based on `pull-streams`, rather then on the Node.js core streams implementation (aka Node.js streams). `pull-streams` offers us a better mechanism for error handling and flow control guarantees. If you would like to know more about why we did this, see the discussion at this [issue](https://github.com/ipfs/js-ipfs/issues/362). + +You can learn more about pull-streams at: + +- [The history of Node.js streams, nodebp April 2014](https://www.youtube.com/watch?v=g5ewQEuXjsQ) +- [The history of streams, 2016](http://dominictarr.com/post/145135293917/history-of-streams) +- [pull-streams, the simple streaming primitive](http://dominictarr.com/post/149248845122/pull-streams-pull-streams-are-a-very-simple) +- [pull-streams documentation](https://pull-stream.github.io/) + +#### Converting `pull-streams` to Node.js Streams + +If you are a Node.js streams user, you can convert a pull-stream to a Node.js stream using the module [`pull-stream-to-stream`](https://github.com/pull-stream/pull-stream-to-stream), giving you an instance of a Node.js stream that is linked to the pull-stream. For example: + +```js +const pullToStream = require('pull-stream-to-stream') + +const nodeStreamInstance = pullToStream(pullStreamInstance) +// nodeStreamInstance is an instance of a Node.js Stream +``` + +To learn more about this utility, visit https://pull-stream.github.io/#pull-stream-to-stream. + LICENSE MIT From f5e91fed97808a75a4c037b67eb380979892cdeb Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sat, 28 Oct 2017 14:45:04 +0200 Subject: [PATCH 26/75] fix: package.json --- package.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9477a5f..15ec354 100644 --- a/package.json +++ b/package.json @@ -56,13 +56,14 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/libp2p/js-libp2p-websocket-star.git" + "url": "git+https://github.com/libp2p/js-libp2p-websocket-star-rendezvous.git" }, "bugs": { - "url": "https://github.com/libp2p/js-libp2p-websocket-star/issues" + "url": "https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues" }, - "homepage": "https://github.com/libp2p/js-libp2p-websocket-star#readme", + "homepage": "https://github.com/libp2p/js-libp2p-websocket-star-rendezvous#readme", "contributors": [ - "David Dias " + "David Dias ", + "Maciej Krüger " ] } From 4504fe45711078f7e392bf472ce5bac8f41ad1fc Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sat, 28 Oct 2017 14:46:15 +0200 Subject: [PATCH 27/75] chore: update contributors --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 15ec354..c167cea 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,6 @@ "homepage": "https://github.com/libp2p/js-libp2p-websocket-star-rendezvous#readme", "contributors": [ "David Dias ", - "Maciej Krüger " + "mkg20001 " ] } From 78eab7be25f68ff9fa799c714afd834adbaa0dff Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sat, 28 Oct 2017 14:46:16 +0200 Subject: [PATCH 28/75] chore: release version v0.2.0 --- CHANGELOG.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..aa4f296 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,47 @@ + +# [0.2.0](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.1.2...v0.2.0) (2017-10-28) + + +### Bug Fixes + +* {webrtc => websocket} ([df53c25](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/df53c25)) +* discovery fix - fix: debug log name ([1f163b8](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/1f163b8)) +* lint ([585525e](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/585525e)) +* package.json ([f5e91fe](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/f5e91fe)) +* small name fix ([de84807](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/de84807)) + + +### Features + +* Joins metric - fix: config ([81c8eb7](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/81c8eb7)) +* Link directly to readme in about page ([d7fba03](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/d7fba03)) +* metrics (WIP) - feat: Dockerfile - fix/feat: various other things ([fa518b1](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/fa518b1)) +* Update README - feat: Use dumb-init in docker-image ([4fbed33](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/4fbed33)) + + + + +## [0.1.2](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.1.1...v0.1.2) (2017-09-08) + + +### Bug Fixes + +* point to right location of bin ([3049ca8](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/3049ca8)) + + + + +## [0.1.1](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.1.0...v0.1.1) (2017-09-08) + + +### Bug Fixes + +* add main to package.json ([7ff704c](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/7ff704c)) + + + + +# 0.1.0 (2017-09-08) + + + diff --git a/package.json b/package.json index c167cea..291e9b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-websocket-star-rendezvous", - "version": "0.1.2", + "version": "0.2.0", "description": "The rendezvous service for libp2p-websocket-star", "main": "src/index.js", "bin": { From 21f95d2b5690a47a8c8e6fca43feeeb9d76177c1 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sat, 28 Oct 2017 17:21:03 +0200 Subject: [PATCH 29/75] fix: Docker cmd - feat: Disable metrics option --- .gitignore | 1 + README.md | 8 +++++++- src/bin.js | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1688399..64f6bf2 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ coverage examples/sub-module/**/bundle.js examples/sub-module/**/*-minified.js examples/sub-module/*-bundle.js +docs diff --git a/README.md b/README.md index 7b155c2..c1c98b3 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,13 @@ A docker image is offered for running this service in production ``` docker pull libp2p/websocket-star-rendezvous:release -docker run -d -p 13579:8090 -n rendezvous libp2p/websocket-star-rendezvous:release +docker run -d -p 9090:9090 --name rendezvous libp2p/websocket-star-rendezvous:release +``` + +To disable prometheus metrics run the server with `-e DISABLE_METRICS=1` + +``` +docker run -d -p 9090:9090 --name rendezvous -e DISABLE_METRICS=1 libp2p/websocket-star-rendezvous:release ``` ## Hosted Rendezvous server diff --git a/src/bin.js b/src/bin.js index 5a75c4d..161696f 100755 --- a/src/bin.js +++ b/src/bin.js @@ -14,7 +14,7 @@ signalling.start({ host: argv.host || argv.h || process.env.HOST || '0.0.0.0', cryptoChallenge: !(argv.disableCryptoChallenge || process.env.DISABLE_CRYPTO_CHALLENGE), strictMultiaddr: !(argv.disableStrictMultiaddr || process.env.DISABLE_STRICT_MULTIADDR), - metrics: true + metrics: !(argv.disableMetrics || process.env.DISABLE_METRICS) }, (err, _server) => { if (err) { throw err From 28ef92919080d68ff791dd79d892c85fd6d163d7 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sun, 19 Nov 2017 12:27:08 +0100 Subject: [PATCH 30/75] chore: Upgrade deps - fix: Leave DOS - feat: Code improvments --- package.json | 10 +++++----- src/routes.js | 35 +++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 291e9b9..79856f7 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,8 @@ "author": "Maciej Krüger ", "license": "MIT", "dependencies": { - "async": "^2.5.0", - "data-queue": "0.0.2", + "async": "^2.6.0", + "data-queue": "0.0.3", "debug": "^3.1.0", "epimetheus": "^1.0.55", "hapi": "^16.6.2", @@ -38,8 +38,8 @@ "multiaddr": "^3.0.1", "once": "^1.4.0", "peer-id": "^0.10.2", - "peer-info": "^0.11.0", - "prom-client": "^10.2.1", + "peer-info": "^0.11.1", + "prom-client": "^10.2.2", "socket.io": "^2.0.4", "socket.io-client": "^2.0.4", "socket.io-pull-stream": "^0.1.1", @@ -49,7 +49,7 @@ "test": "test" }, "devDependencies": { - "aegir": "^12.1.1", + "aegir": "^12.1.3", "chai": "^4.1.2", "dirty-chai": "^2.0.1", "lodash": "^4.17.4" diff --git a/src/routes.js b/src/routes.js index 65a3ebc..bceeeb2 100644 --- a/src/routes.js +++ b/src/routes.js @@ -68,7 +68,7 @@ module.exports = (config, http) => { // join this signaling server network function join (socket, multiaddr, pub, cb) { - const log = config.log.bind(config.log, '[' + socket.id + ']') + const log = socket.log = config.log.bind(config.log, '[' + socket.id + ']') if (getConfig().strictMultiaddr && !util.validateMa(multiaddr)) { joinsTotal.inc() @@ -127,6 +127,7 @@ module.exports = (config, http) => { function joinFinalize (socket, multiaddr, cb) { const log = getConfig().log.bind(getConfig().log, '[' + socket.id + ']') getPeers()[multiaddr] = socket + if (!socket.stopSendingPeersIntv) socket.stopSendingPeersIntv = {} joinsSuccessTotal.inc() refreshMetrics() socket.addrs.push(multiaddr) @@ -136,22 +137,14 @@ module.exports = (config, http) => { let refreshInterval = setInterval(sendPeers, getConfig().refreshPeerListIntervalMS) - socket.once('ss-leave', function handleLeave (ma) { - if (ma === multiaddr) { - refreshMetrics() - socket.addrs = socket.addrs.filter(m => m !== ma) - stopSendingPeers() - } else { - socket.once('ss-leave', handleLeave) - } - }) - socket.once('disconnect', stopSendingPeers) sendPeers() function sendPeers () { - Object.keys(getPeers()).forEach((mh) => { + const list = Object.keys(getPeers()) + log(multiaddr, 'sending', (list.length - 1).toString(), 'peer(s)') + list.forEach((mh) => { if (mh === multiaddr) { return } @@ -162,31 +155,41 @@ module.exports = (config, http) => { function stopSendingPeers () { if (refreshInterval) { + log(multiaddr, 'stop sending peers') clearInterval(refreshInterval) refreshInterval = null } } + socket.stopSendingPeersIntv[multiaddr] = stopSendingPeers + cb() } function leave (socket, multiaddr) { - if (getPeers()[multiaddr]) { + if (getPeers()[multiaddr] && getPeers()[multiaddr].id === socket.id) { + socket.log('leaving', multiaddr) delete getPeers()[multiaddr] + socket.addrs = socket.addrs.filter(m => m !== multiaddr) + if (socket.stopSendingPeersIntv[multiaddr]) { + socket.stopSendingPeersIntv[multiaddr]() + delete socket.stopSendingPeersIntv[multiaddr] + } + refreshMetrics() } } function disconnect (socket) { + socket.log('disconnected') Object.keys(getPeers()).forEach((mh) => { if (getPeers()[mh].id === socket.id) { - delete getPeers()[mh] + leave(socket, mh) } }) - refreshMetrics() } function dial (socket, from, to, dialId, cb) { - const log = getConfig().log.bind(getConfig().log, '[' + dialId + ']') + const log = socket.log const s = socket.addrs.filter((a) => a === from)[0] dialsTotal.inc() From 37e5b1f1b3bf8a6306443d507d3ba8fee08f0e3b Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sun, 19 Nov 2017 12:28:25 +0100 Subject: [PATCH 31/75] fix: release command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79856f7..b72e6e1 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "lint": "aegir lint", "build": "aegir build", "test": "aegir test --target node", - "release": "aegir test release --target node", + "release": "aegir release --target node", "release-minor": "aegir release --type minor --target node", "release-major": "aegir release --type major --target node", "coverage": "aegir coverage", From fc0d2b5db95fa05c5accd2a960bc066bf205fe76 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sun, 19 Nov 2017 12:29:02 +0100 Subject: [PATCH 32/75] chore: update contributors From ceff5f0a8f147741b40178fce1083df72ae9e2d8 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Sun, 19 Nov 2017 12:29:02 +0100 Subject: [PATCH 33/75] chore: release version v0.2.1 --- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa4f296..4541210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ + +## [0.2.1](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.0...v0.2.1) (2017-11-19) + + +### Bug Fixes + +* Docker cmd - feat: Disable metrics option ([21f95d2](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/21f95d2)) +* release command ([37e5b1f](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/37e5b1f)) + + + # [0.2.0](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.1.2...v0.2.0) (2017-10-28) diff --git a/package.json b/package.json index b72e6e1..fcf6a57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-websocket-star-rendezvous", - "version": "0.2.0", + "version": "0.2.1", "description": "The rendezvous service for libp2p-websocket-star", "main": "src/index.js", "bin": { From 66be194b42ab3bde4e07d675a0970c16b4d7504e Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Fri, 24 Nov 2017 20:51:30 +0100 Subject: [PATCH 34/75] feat: Add libp2p logo to about page --- src/index.html | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/index.html b/src/index.html index 0931e3c..ff64814 100644 --- a/src/index.html +++ b/src/index.html @@ -21,6 +21,8 @@
+
+ Libp2p Logo

This is a libp2p-websocket-star signalling-server

Signaling Servers are used in libp2p to allow browsers and clients with restricted port-forwarding
to communicate with other peers in the libp2p network

@@ -32,30 +34,32 @@

This is a libp2p-websocket-star signalling-server

var ipv4Regex = /^(\d{1,3}\.){3,3}\d{1,3}$/; var ipv6Regex = /^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i; - var addr = "" + var addr = '' var f = window.location - if (f.hostname.startsWith("[") && f.hostname.endsWith("]")) f.h = f.hostname.match(/\[(.+)\]/)[1] + if (f.hostname.startsWith('[') && f.hostname.endsWith(']')) f.h = f.hostname.match(/\[(.+)\]/)[1] else f.h = f.hostname - f.protoport = f.port ? f.port : f.protocol == "https:" ? 443 : 80 + f.protoport = f.port ? f.port : f.protocol == 'https:' ? 443 : 80 if (f.port && ipv4Regex.test()) { - addr += "/ip4/" + f.h + "/tcp/" + f.port + "/" + addr += '/ip4/' + f.h + '/tcp/' + f.port + '/' } else if (f.port && ipv6Regex.test(f.h)) { - addr += "/ip6/" + f.h + "/tcp/" + f.port + "/" + addr += '/ip6/' + f.h + '/tcp/' + f.port + '/' } else if (f.port) { - addr += "/dns/" + f.h + "/tcp/" + f.port + "/" + addr += '/dns/' + f.h + '/tcp/' + f.port + '/' } else if (ipv4Regex.test(f.h)) { - addr += "/ip4/" + f.h + "/tcp/" + f.protoport + "/" + addr += '/ip4/' + f.h + '/tcp/' + f.protoport + '/' } else if (ipv6Regex.test(f.h)) { - addr += "/ip6/" + f.h + "/tcp/" + f.protoport + "/" + addr += '/ip6/' + f.h + '/tcp/' + f.protoport + '/' } else { - addr += "/dns/" + f.h + "/" + addr += '/dns/' + f.h + '/' } - if (f.protocol == "https:") addr += "wss/" - else addr += "ws/" + if (f.protocol == 'https:') addr += 'wss/' + else addr += 'ws/' - addr += "p2p-websocket-star/" + addr += 'p2p-websocket-star/' - document.getElementById("addr").innerHTML = "You can add this signaling-server with the address " + addr + "" + if (f.protocol == 'file:') addr = '/-.-/' + + document.getElementById('addr').innerHTML = 'You can add this signaling-server with the address ' + addr + '' From 3172e87643f3f8336f5bb4902d1d1f73e8253464 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 27 Nov 2017 07:33:17 +0000 Subject: [PATCH 35/75] chore: add deployment for ipfs infra (#8) --- DEPLOYMENT.md | 17 +++++++++++++++++ Procfile | 1 + Dockerfile => _ | 0 package.json | 5 ++--- 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 DEPLOYMENT.md create mode 100644 Procfile rename Dockerfile => _ (100%) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md new file mode 100644 index 0000000..a36bd91 --- /dev/null +++ b/DEPLOYMENT.md @@ -0,0 +1,17 @@ +# Deployment + +## IPFS Infra + +We have a [dokku](https://github.com/ipfs/ops-requests/issues/31) setup ready for this to be deployed, to deploy simple do (you have to have permission first): + +```sh +# if you already have added the remote, you don't need to do it again +> git remote add dokku dokku@cloud.ipfs.team:ws-star +> git push dokku master +``` + +More info: https://github.com/libp2p/js-libp2p-webrtc-star/pull/48 + +## Other + +// TODO document mkg20001 endpoints diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..28fe750 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: npm run start diff --git a/Dockerfile b/_ similarity index 100% rename from Dockerfile rename to _ diff --git a/package.json b/package.json index fcf6a57..e07d4a9 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,10 @@ "description": "The rendezvous service for libp2p-websocket-star", "main": "src/index.js", "bin": { - "websockets-star": "src/bin.js" + "rendezvous": "src/bin.js" }, "scripts": { - "rendezvous": "node src/bin.js", - "start": "node src/bin.js", + "start": "node src/bin.js --disableCryptoChallenge", "lint": "aegir lint", "build": "aegir build", "test": "aegir test --target node", From 5d11c36e7b21c19fe549da3d7f9f4c636a7ec8ea Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 27 Nov 2017 08:48:14 +0000 Subject: [PATCH 36/75] chore: small refactor --- package.json | 8 ++++---- src/bin.js | 8 +++----- src/index.js | 14 +++++--------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index e07d4a9..bb66cce 100644 --- a/package.json +++ b/package.json @@ -10,10 +10,10 @@ "start": "node src/bin.js --disableCryptoChallenge", "lint": "aegir lint", "build": "aegir build", - "test": "aegir test --target node", - "release": "aegir release --target node", - "release-minor": "aegir release --type minor --target node", - "release-major": "aegir release --type major --target node", + "test": "aegir test -t node", + "release": "aegir release -t node", + "release-minor": "aegir release --type minor -t node", + "release-major": "aegir release --type major -t node", "coverage": "aegir coverage", "coverage-publish": "aegir coverage --provider coveralls" }, diff --git a/src/bin.js b/src/bin.js index 161696f..abfb0d1 100755 --- a/src/bin.js +++ b/src/bin.js @@ -16,17 +16,15 @@ signalling.start({ strictMultiaddr: !(argv.disableStrictMultiaddr || process.env.DISABLE_STRICT_MULTIADDR), metrics: !(argv.disableMetrics || process.env.DISABLE_METRICS) }, (err, _server) => { - if (err) { - throw err - } + if (err) { throw err } server = _server console.log('Listening on:', server.info.uri) }) process.on('SIGINT', () => { - server.stop((e) => { + server.stop((err) => { console.log('Rendezvous server stopped') - process.exit(e ? 2 : 0) + process.exit(err ? 2 : 0) }) }) diff --git a/src/index.js b/src/index.js index a33ed0d..a914afb 100644 --- a/src/index.js +++ b/src/index.js @@ -4,6 +4,7 @@ const Hapi = require('hapi') const path = require('path') const epimetheus = require('epimetheus') const merge = require('merge-recursive').recursive +const defaultConfig = require('./config') exports = module.exports @@ -13,7 +14,7 @@ exports.start = (options, callback) => { options = {} } - const config = merge(Object.assign({}, require('./config')), Object.assign({}, options)) + const config = merge(Object.assign({}, defaultConfig), options) const log = config.log const port = options.port || config.hapi.port @@ -21,14 +22,9 @@ exports.start = (options, callback) => { const http = new Hapi.Server(config.hapi.options) - http.connection({ - port, - host - }) + http.connection({ port, host }) - http.register({ - register: require('inert') - }, err => { + http.register({ register: require('inert') }, (err) => { if (err) { return callback(err) } @@ -54,7 +50,7 @@ exports.start = (options, callback) => { }) }) - if (config.metrics) epimetheus.instrument(http) + if (config.metrics) { epimetheus.instrument(http) } return http } From 143a0a43f7cd7230592329649b029f61f437255b Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 27 Nov 2017 09:31:44 +0000 Subject: [PATCH 37/75] feat: cryptoChallenge can be enabled by default after all! https://github.com/ipfs/js-ipfs/pull/1090/files\#r153143252 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bb66cce..da8aef2 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "rendezvous": "src/bin.js" }, "scripts": { - "start": "node src/bin.js --disableCryptoChallenge", + "start": "node src/bin.js", "lint": "aegir lint", "build": "aegir build", "test": "aegir test -t node", From f39b28c6584f3eda5f79947b2840b815701a3cbd Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Wed, 6 Dec 2017 15:31:36 +0100 Subject: [PATCH 38/75] chore: upgrade deps --- package.json | 10 +++++----- src/routes.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index da8aef2..d71f18e 100644 --- a/package.json +++ b/package.json @@ -30,25 +30,25 @@ "epimetheus": "^1.0.55", "hapi": "^16.6.2", "inert": "^4.2.1", - "libp2p-crypto": "^0.10.3", + "libp2p-crypto": "^0.10.4", "mafmt": "^3.0.2", "merge-recursive": "0.0.3", "minimist": "^1.2.0", "multiaddr": "^3.0.1", "once": "^1.4.0", - "peer-id": "^0.10.2", - "peer-info": "^0.11.1", + "peer-id": "^0.10.3", + "peer-info": "^0.11.3", "prom-client": "^10.2.2", "socket.io": "^2.0.4", "socket.io-client": "^2.0.4", - "socket.io-pull-stream": "^0.1.1", + "socket.io-pull-stream": "^0.1.2", "uuid": "^3.1.0" }, "directories": { "test": "test" }, "devDependencies": { - "aegir": "^12.1.3", + "aegir": "^12.2.0", "chai": "^4.1.2", "dirty-chai": "^2.0.1", "lodash": "^4.17.4" diff --git a/src/routes.js b/src/routes.js index bceeeb2..4df6adf 100644 --- a/src/routes.js +++ b/src/routes.js @@ -42,7 +42,7 @@ module.exports = (config, http) => { const joinsFailureTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total_failure', help: 'failed joins since server started' }) : fake.counter const joinsTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total', help: 'all joins since server started' }) : fake.counter - const getPeers = () => this._peers + const getPeers = () => this._peers // it's a function because, and I'm not kidding, the value of that var is different for every peer that has joined const refreshMetrics = () => peersMetric.set(Object.keys(getPeers()).length) this.peers = () => getPeers() From 13af50ba305287f53990b8c1575c96c0798fedf8 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Wed, 6 Dec 2017 15:37:16 +0100 Subject: [PATCH 39/75] chore: upgrade deps --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d71f18e..12fc5c0 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "prom-client": "^10.2.2", "socket.io": "^2.0.4", "socket.io-client": "^2.0.4", - "socket.io-pull-stream": "^0.1.2", + "socket.io-pull-stream": "^0.1.3", "uuid": "^3.1.0" }, "directories": { From 59c5cb41350db9f1d03d269104cb06ab961cf9ad Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Wed, 6 Dec 2017 16:05:04 +0100 Subject: [PATCH 40/75] misc: lint --- src/routes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes.js b/src/routes.js index 4df6adf..e636d8c 100644 --- a/src/routes.js +++ b/src/routes.js @@ -42,7 +42,7 @@ module.exports = (config, http) => { const joinsFailureTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total_failure', help: 'failed joins since server started' }) : fake.counter const joinsTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total', help: 'all joins since server started' }) : fake.counter - const getPeers = () => this._peers // it's a function because, and I'm not kidding, the value of that var is different for every peer that has joined + const getPeers = () => this._peers // it's a function because, and I'm not kidding, the value of that var is different for every peer that has joined const refreshMetrics = () => peersMetric.set(Object.keys(getPeers()).length) this.peers = () => getPeers() From 54785e3d7bbbdb5385650734ec0129ac03b02d18 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Thu, 7 Dec 2017 20:11:03 +0100 Subject: [PATCH 41/75] misc: Rename Dockerfile to re-enable docker builds --- _ => Dockerfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename _ => Dockerfile (100%) diff --git a/_ b/Dockerfile similarity index 100% rename from _ rename to Dockerfile From 597009e13e4601ca133ded94d1210f40f510a369 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Thu, 7 Dec 2017 20:13:16 +0100 Subject: [PATCH 42/75] chore: update contributors From 90246724444c8b6ffc42a9c36d9df25af3d9d68e Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Thu, 7 Dec 2017 20:13:17 +0100 Subject: [PATCH 43/75] chore: release version v0.2.2 --- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4541210..c7deb1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ + +## [0.2.2](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.1...v0.2.2) (2017-12-07) + + +### Features + +* Add libp2p logo to about page ([66be194](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/66be194)) +* cryptoChallenge can be enabled by default after all! https://github.com/ipfs/js-ipfs/pull/1090/files\#r153143252 ([143a0a4](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/143a0a4)) + + + ## [0.2.1](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.0...v0.2.1) (2017-11-19) diff --git a/package.json b/package.json index 12fc5c0..0436526 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-websocket-star-rendezvous", - "version": "0.2.1", + "version": "0.2.2", "description": "The rendezvous service for libp2p-websocket-star", "main": "src/index.js", "bin": { From 7e6fa8e5d7a37e69b5802e3d7aea974746244dbf Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Tue, 23 Jan 2018 14:08:21 +0100 Subject: [PATCH 44/75] chore: Update deps - docs: Update DEPLOYMENT --- DEPLOYMENT.md | 5 ++++- package.json | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md index a36bd91..046c1ec 100644 --- a/DEPLOYMENT.md +++ b/DEPLOYMENT.md @@ -14,4 +14,7 @@ More info: https://github.com/libp2p/js-libp2p-webrtc-star/pull/48 ## Other -// TODO document mkg20001 endpoints +# mkg20001 +The nodes `ws-star-signal-{2,4,h}.servep2p.com` run on `host0.zion.host` + +Upgrades are done by running `bash /home/maciej/upgrade-rendezvous.sh` which runs docker pull and re-creates the containers diff --git a/package.json b/package.json index 0436526..f035838 100644 --- a/package.json +++ b/package.json @@ -29,15 +29,15 @@ "debug": "^3.1.0", "epimetheus": "^1.0.55", "hapi": "^16.6.2", - "inert": "^4.2.1", - "libp2p-crypto": "^0.10.4", + "inert": "^5.0.1", + "libp2p-crypto": "^0.11.0", "mafmt": "^3.0.2", "merge-recursive": "0.0.3", "minimist": "^1.2.0", - "multiaddr": "^3.0.1", + "multiaddr": "^3.0.2", "once": "^1.4.0", - "peer-id": "^0.10.3", - "peer-info": "^0.11.3", + "peer-id": "^0.10.4", + "peer-info": "^0.11.4", "prom-client": "^10.2.2", "socket.io": "^2.0.4", "socket.io-client": "^2.0.4", @@ -48,7 +48,7 @@ "test": "test" }, "devDependencies": { - "aegir": "^12.2.0", + "aegir": "^12.3.0", "chai": "^4.1.2", "dirty-chai": "^2.0.1", "lodash": "^4.17.4" From 518a6af2fa98a9e4995a43d1d034729117179762 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Mon, 12 Feb 2018 11:19:33 +0100 Subject: [PATCH 45/75] chore: down- and upgrade a few deps to fix issues --- package.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index f035838..f8925f4 100644 --- a/package.json +++ b/package.json @@ -29,29 +29,29 @@ "debug": "^3.1.0", "epimetheus": "^1.0.55", "hapi": "^16.6.2", - "inert": "^5.0.1", - "libp2p-crypto": "^0.11.0", - "mafmt": "^3.0.2", + "inert": "^4.2.1", + "libp2p-crypto": "^0.12.1", + "mafmt": "^4.0.0", "merge-recursive": "0.0.3", "minimist": "^1.2.0", "multiaddr": "^3.0.2", "once": "^1.4.0", - "peer-id": "^0.10.4", - "peer-info": "^0.11.4", + "peer-id": "^0.10.6", + "peer-info": "^0.11.6", "prom-client": "^10.2.2", "socket.io": "^2.0.4", "socket.io-client": "^2.0.4", - "socket.io-pull-stream": "^0.1.3", - "uuid": "^3.1.0" + "socket.io-pull-stream": "^0.1.4", + "uuid": "^3.2.1" }, "directories": { "test": "test" }, "devDependencies": { - "aegir": "^12.3.0", + "aegir": "^12.4.0", "chai": "^4.1.2", "dirty-chai": "^2.0.1", - "lodash": "^4.17.4" + "lodash": "^4.17.5" }, "repository": { "type": "git", From b02fc1de020ebe0207f602f00ec70e6ceee22a4b Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Mon, 12 Feb 2018 11:58:18 +0100 Subject: [PATCH 46/75] chore: update contributors From 7ecb31993a25203909e2568c1820db01174b0c10 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Mon, 12 Feb 2018 11:58:19 +0100 Subject: [PATCH 47/75] chore: release version v0.2.3 --- CHANGELOG.md | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7deb1d..0a60d85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ + +## [0.2.3](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.2...v0.2.3) (2018-02-12) + + + ## [0.2.2](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.1...v0.2.2) (2017-12-07) diff --git a/package.json b/package.json index f8925f4..97176a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-websocket-star-rendezvous", - "version": "0.2.2", + "version": "0.2.3", "description": "The rendezvous service for libp2p-websocket-star", "main": "src/index.js", "bin": { From d18087c9c2d12c0c331a1837b77071d1e76dab13 Mon Sep 17 00:00:00 2001 From: Haad Date: Tue, 6 Mar 2018 12:12:54 +0100 Subject: [PATCH 48/75] fix: make it executable available through websocket-star * Fix installed binary's name Currently, the [documentation](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous#usage) say to start the server, we run `websockets-star --port=9090 --host=127.0.0.1`. However, the binary that the package.json installs is `rendezvous`. This PR will change the name of the binary that gets installed when installed with `npm --global libp2p-websocket-star-rendezvous` to `websockets-star`. Another way to fix this would be to update the [README](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous#usage) `rendezvous --port=9090 --host=127.0.0.1`. Let me know if you feel changing the docs is more appropriate to fix this and I can open a PR for that (and close this). * Install rendezvous binary --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 97176a9..fe6b71a 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "The rendezvous service for libp2p-websocket-star", "main": "src/index.js", "bin": { - "rendezvous": "src/bin.js" + "rendezvous": "src/bin.js", + "websocket-star": "src/bin.js" }, "scripts": { "start": "node src/bin.js", From 5cc9b57f2af288f8fd38d2eb1a4de27f79f94615 Mon Sep 17 00:00:00 2001 From: victorbjelkholm Date: Wed, 7 Mar 2018 23:07:10 +0100 Subject: [PATCH 49/75] Remove EXPOSE of port This way we let the runtime decide the port instead of on build --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 174655e..cc3fba5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,3 @@ COPY . /app WORKDIR /app RUN npm i --production ENTRYPOINT ["/usr/local/bin/dumb-init", "node", "src/bin.js"] -EXPOSE 9090 From 95d23210d72b7c8b5dea3dceaf01214d5813387e Mon Sep 17 00:00:00 2001 From: victorbjelkholm Date: Wed, 7 Mar 2018 23:16:37 +0100 Subject: [PATCH 50/75] Cache docker layers if possible --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index cc3fba5..1d748d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM node:8 RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && chmod +x /usr/local/bin/dumb-init -COPY . /app -WORKDIR /app +WORKDIR /usr/src/app +COPY package.json . RUN npm i --production +COPY . . ENTRYPOINT ["/usr/local/bin/dumb-init", "node", "src/bin.js"] From 3b71233fda3f9b6503391404ba0c88ef84e14166 Mon Sep 17 00:00:00 2001 From: victorbjelkholm Date: Wed, 7 Mar 2018 23:16:52 +0100 Subject: [PATCH 51/75] Always use port + dns4 instead of dns multiaddr --- src/index.html | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/index.html b/src/index.html index ff64814..fa735e6 100644 --- a/src/index.html +++ b/src/index.html @@ -43,14 +43,12 @@

This is a libp2p-websocket-star signalling-server

addr += '/ip4/' + f.h + '/tcp/' + f.port + '/' } else if (f.port && ipv6Regex.test(f.h)) { addr += '/ip6/' + f.h + '/tcp/' + f.port + '/' - } else if (f.port) { - addr += '/dns/' + f.h + '/tcp/' + f.port + '/' } else if (ipv4Regex.test(f.h)) { addr += '/ip4/' + f.h + '/tcp/' + f.protoport + '/' } else if (ipv6Regex.test(f.h)) { addr += '/ip6/' + f.h + '/tcp/' + f.protoport + '/' } else { - addr += '/dns/' + f.h + '/' + addr += '/dns4/' + f.h + '/tcp/' + f.protoport + '/' } if (f.protocol == 'https:') addr += 'wss/' else addr += 'ws/' From 537eaefa3d3198fecc805ae19def17a44910846c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=A0=C9=AA=E1=B4=84=E1=B4=9B=E1=B4=8F=CA=80=20=CA=99?= =?UTF-8?q?=E1=B4=8A=E1=B4=87=CA=9F=E1=B4=8B=CA=9C=E1=B4=8F=CA=9F=E1=B4=8D?= Date: Mon, 19 Mar 2018 06:24:05 +0100 Subject: [PATCH 52/75] Updating CI files (#10) This commit updates all CI scripts to the latest version --- .travis.yml | 3 +++ appveyor.yml | 29 +++++++++++++++++++++++++++++ ci/Jenkinsfile | 2 ++ circle.yml | 1 + 4 files changed, 35 insertions(+) create mode 100644 appveyor.yml create mode 100644 ci/Jenkinsfile diff --git a/.travis.yml b/.travis.yml index 99609a6..5102ee5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 language: node_js @@ -7,6 +8,8 @@ matrix: env: CXX=g++-4.8 - node_js: 8 env: CXX=g++-4.8 + # - node_js: stable + # env: CXX=g++-4.8 script: - npm run lint diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..046bf91 --- /dev/null +++ b/appveyor.yml @@ -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 diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile new file mode 100644 index 0000000..a7da2e5 --- /dev/null +++ b/ci/Jenkinsfile @@ -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() diff --git a/circle.yml b/circle.yml index 56f7efb..0009693 100644 --- a/circle.yml +++ b/circle.yml @@ -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. machine: node: version: stable From 5a2ce873096ff02ec2bdbde2fb1472374f43b601 Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Thu, 22 Mar 2018 20:56:30 +0100 Subject: [PATCH 53/75] docs: Fix README (fixes #18) --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c1c98b3..a3593a8 100644 --- a/README.md +++ b/README.md @@ -14,21 +14,21 @@ Nodes using `libp2p-websocket-star` will connect to a known point in the network ## Usage -`libp2p-websocket-star-rendezvous` is the rendezvous server required for `libp2p-websocket-star` and can be used to start a rendezvous server for development. To do that, first insall the module globally in your machine with: +`libp2p-websocket-star-rendezvous` is the rendezvous server required for `libp2p-websocket-star` and can be used to start a rendezvous server for development. To do that, first install the module globally in your machine with: ```bash > npm install --global libp2p-websocket-star-rendezvous ``` -This will install a `websockets-star` CLI tool. Now you can spawn the server with: +This will install a `rendezvous` CLI tool. Now you can spawn the server with: ```bash -> websockets-star --port=9090 --host=127.0.0.1 +> rendezvous --port=9090 --host=127.0.0.1 ``` Defaults: -- `port` - 13579 +- `port` - 9090 - `host` - '0.0.0.0' ## Docker From 113b996b7ed899dd37d7c0636cbfb555e0dc16a8 Mon Sep 17 00:00:00 2001 From: Victor Bjelkholm Date: Wed, 23 May 2018 12:52:36 +0100 Subject: [PATCH 54/75] Allow nodejs in docker allocate more memory (8GB) License: MIT Signed-off-by: Victor Bjelkholm --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1d748d1..945a5f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,4 +4,4 @@ WORKDIR /usr/src/app COPY package.json . RUN npm i --production COPY . . -ENTRYPOINT ["/usr/local/bin/dumb-init", "node", "src/bin.js"] +ENTRYPOINT ["/usr/local/bin/dumb-init", "node", "--max-old-space-size=8192", "src/bin.js"] From 33a750e608f0f56f6ca5043614d581ef707a08e5 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Mon, 25 Jun 2018 23:35:37 +0200 Subject: [PATCH 55/75] chore: add lead maintainer License: MIT Signed-off-by: Jacob Heun --- README.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a3593a8..1512a92 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,10 @@ > The rendezvous service for [libp2p-websocket-star](https://github.com/libp2p/js-libp2p-websocket-star). +## Lead Maintainer + +[Jacob Heun](https://github.com/jacobheun) + ## Descriptions Nodes using `libp2p-websocket-star` will connect to a known point in the network, a rendezvous point where they can learn about other nodes (Discovery) and route their messages to other nodes (2 hop message routing, also known as relay). diff --git a/package.json b/package.json index fe6b71a..a6f6d52 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "libp2p-websocket-star-rendezvous", "version": "0.2.3", "description": "The rendezvous service for libp2p-websocket-star", + "leadMaintainer": "Jacob Heun ", "main": "src/index.js", "bin": { "rendezvous": "src/bin.js", @@ -22,7 +23,6 @@ "libp2p", "websocket" ], - "author": "Maciej Krüger ", "license": "MIT", "dependencies": { "async": "^2.6.0", From 0c8c290882dfeead64a356dad68e872c8576090b Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Tue, 16 Oct 2018 19:33:02 +0200 Subject: [PATCH 56/75] fix: give crypto.verify a buffer (#23) * chore: remove non jenkins ci * chore: update deps and remove unused jshint * fix: linting * fix: give verify a buffer instead of a string * chore: update readme rendezvous server url --- .travis.yml | 32 -------------------------------- README.md | 6 ++---- appveyor.yml | 29 ----------------------------- circle.yml | 15 --------------- package.json | 29 +++++++++++++++-------------- src/routes.js | 23 +++++++++++++---------- src/utils.js | 26 ++++++++++++++------------ test/.jshintrc | 8 -------- 8 files changed, 44 insertions(+), 124 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml delete mode 100644 circle.yml delete mode 100644 test/.jshintrc diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5102ee5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -# 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 -language: node_js - -matrix: - include: - - node_js: 6 - env: CXX=g++-4.8 - - node_js: 8 - env: CXX=g++-4.8 - # - node_js: stable - # env: CXX=g++-4.8 - -script: - - npm run lint - - npm run test - - npm run coverage - -before_script: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start - -after_success: - - npm run coverage-publish - -addons: - firefox: 'latest' - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 diff --git a/README.md b/README.md index 1512a92..1b9493b 100644 --- a/README.md +++ b/README.md @@ -52,13 +52,11 @@ docker run -d -p 9090:9090 --name rendezvous -e DISABLE_METRICS=1 libp2p/websock ## Hosted Rendezvous server -We host a rendezvous server at `ws-star-signal-1.servep2p.com` and `ws-star-signal-2.servep2p.com` that can be used for practical demos and experimentation, it **should not be used for apps in production**. - -Additionally there is a rendezvous server at `ws-star-signal-3.servep2p.com` running the latest master version. +We host a rendezvous server at `ws-star.discovery.libp2p.io` that can be used for practical demos and experimentation, it **should not be used for apps in production**. A libp2p-websocket-star address, using the signalling server we provide, looks like: -`/dns4/ws-star-signal-1.servep2p.com/wss/p2p-websocket-star/ipfs/` +`/dns4/ws-star.discovery.libp2p.io/wss/p2p-websocket-star/ipfs/` Note: The address above indicates WebSockets Secure, which can be accessed from both http and https. diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 046bf91..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,29 +0,0 @@ -# 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 diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 0009693..0000000 --- a/circle.yml +++ /dev/null @@ -1,15 +0,0 @@ -# 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. -machine: - node: - version: stable - -dependencies: - pre: - - google-chrome --version - - curl -L -o google-chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb - - sudo dpkg -i google-chrome.deb || true - - sudo apt-get update - - sudo apt-get install -f - - sudo apt-get install --only-upgrade lsb-base - - sudo dpkg -i google-chrome.deb - - google-chrome --version diff --git a/package.json b/package.json index a6f6d52..1aa0aea 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "lint": "aegir lint", "build": "aegir build", "test": "aegir test -t node", + "test:node": "aegir test -t node", "release": "aegir release -t node", "release-minor": "aegir release --type minor -t node", "release-major": "aegir release --type major -t node", @@ -25,34 +26,34 @@ ], "license": "MIT", "dependencies": { - "async": "^2.6.0", + "async": "^2.6.1", "data-queue": "0.0.3", "debug": "^3.1.0", - "epimetheus": "^1.0.55", + "epimetheus": "^1.0.92", "hapi": "^16.6.2", "inert": "^4.2.1", - "libp2p-crypto": "^0.12.1", - "mafmt": "^4.0.0", + "libp2p-crypto": "~0.14.0", + "mafmt": "^6.0.2", "merge-recursive": "0.0.3", "minimist": "^1.2.0", - "multiaddr": "^3.0.2", + "multiaddr": "^5.0.0", "once": "^1.4.0", - "peer-id": "^0.10.6", - "peer-info": "^0.11.6", - "prom-client": "^10.2.2", - "socket.io": "^2.0.4", - "socket.io-client": "^2.0.4", - "socket.io-pull-stream": "^0.1.4", + "peer-id": "~0.11.0", + "peer-info": "~0.14.1", + "prom-client": "^11.1.3", + "socket.io": "^2.1.1", + "socket.io-client": "^2.1.1", + "socket.io-pull-stream": "~0.1.5", "uuid": "^3.2.1" }, "directories": { "test": "test" }, "devDependencies": { - "aegir": "^12.4.0", - "chai": "^4.1.2", + "aegir": "^15.3.1", + "chai": "^4.2.0", "dirty-chai": "^2.0.1", - "lodash": "^4.17.5" + "lodash": "^4.17.11" }, "repository": { "type": "git", diff --git a/src/routes.js b/src/routes.js index e636d8c..89d87d3 100644 --- a/src/routes.js +++ b/src/routes.js @@ -90,16 +90,19 @@ module.exports = (config, http) => { if (nonces[socket.id][multiaddr]) { log('response cryptoChallenge', multiaddr) - nonces[socket.id][multiaddr].key.verify(nonces[socket.id][multiaddr].nonce, Buffer.from(pub, 'hex'), (err, ok) => { - if (err || !ok) { - joinsTotal.inc() - joinsFailureTotal.inc() - } - if (err) { return cb('Crypto error') } // the errors NEED to be a string otherwise JSON.stringify() turns them into {} - if (!ok) { return cb('Signature Invalid') } - - joinFinalize(socket, multiaddr, cb) - }) + nonces[socket.id][multiaddr].key.verify( + Buffer.from(nonces[socket.id][multiaddr].nonce), + Buffer.from(pub, 'hex'), + (err, ok) => { + if (err || !ok) { + joinsTotal.inc() + joinsFailureTotal.inc() + } + if (err) { return cb('Crypto error') } // the errors NEED to be a string otherwise JSON.stringify() turns them into {} + if (!ok) { return cb('Signature Invalid') } + + joinFinalize(socket, multiaddr, cb) + }) } else { joinsTotal.inc() const addr = multiaddr.split('ipfs/').pop() diff --git a/src/utils.js b/src/utils.js index b2e3752..3ea0fa3 100644 --- a/src/utils.js +++ b/src/utils.js @@ -82,18 +82,20 @@ function Protocol (log) { this.handleSocket = (socket) => { socket.r = {} for (let request in this.requests) { - const r = this.requests[request] - socket.on(request, function () { - const data = [...arguments] - try { - validate(r.def, data) - data.unshift(socket) - r.handle.apply(null, data) - } catch (err) { - log(err) - log('peer %s has sent invalid data for request %s', socket.id || '', request, data) - } - }) + if (Object.prototype.hasOwnProperty.call(this.requests, request)) { + const r = this.requests[request] + socket.on(request, function () { + const data = [...arguments] + try { + validate(r.def, data) + data.unshift(socket) + r.handle.apply(null, data) + } catch (err) { + log(err) + log('peer %s has sent invalid data for request %s', socket.id || '', request, data) + } + }) + } } } } diff --git a/test/.jshintrc b/test/.jshintrc deleted file mode 100644 index 3971b28..0000000 --- a/test/.jshintrc +++ /dev/null @@ -1,8 +0,0 @@ -{ - "node": true, - "esnext": true, - "asi": true, - "mocha": true, - "-W016": true, - "unused": true -} From 03e3671d028b6c26b633fcd41ac036733c0bfe6c Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Tue, 16 Oct 2018 19:46:45 +0200 Subject: [PATCH 57/75] chore: update contributors --- package.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 1aa0aea..b82dda0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-websocket-star-rendezvous", - "version": "0.2.3", + "version": "0.2.4", "description": "The rendezvous service for libp2p-websocket-star", "leadMaintainer": "Jacob Heun ", "main": "src/index.js", @@ -65,6 +65,9 @@ "homepage": "https://github.com/libp2p/js-libp2p-websocket-star-rendezvous#readme", "contributors": [ "David Dias ", + "Haad ", + "Jacob Heun ", + "Victor Bjelkholm ", "mkg20001 " ] } From 3ba91c0f369aa5a0ca9283eb37a908204a0d7943 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Tue, 16 Oct 2018 19:46:45 +0200 Subject: [PATCH 58/75] chore: release version v0.2.4 License: MIT Signed-off-by: Jacob Heun --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a60d85..17a5f02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ + +## [0.2.4](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.3...v0.2.4) (2018-10-16) + + +### Bug Fixes + +* give crypto.verify a buffer ([#23](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues/23)) ([0c8c290](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/0c8c290)) +* make it executable available through websocket-star ([d18087c](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/d18087c)) + + + ## [0.2.3](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.2...v0.2.3) (2018-02-12) From 696ed928407a9b26d920681f2605ea80255fac2e Mon Sep 17 00:00:00 2001 From: LEE JAE HO Date: Tue, 23 Oct 2018 19:52:13 +0900 Subject: [PATCH 59/75] fix: regex bug for ipv4 test (#24) --- src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index fa735e6..993b796 100644 --- a/src/index.html +++ b/src/index.html @@ -39,7 +39,7 @@

This is a libp2p-websocket-star signalling-server

if (f.hostname.startsWith('[') && f.hostname.endsWith(']')) f.h = f.hostname.match(/\[(.+)\]/)[1] else f.h = f.hostname f.protoport = f.port ? f.port : f.protocol == 'https:' ? 443 : 80 - if (f.port && ipv4Regex.test()) { + if (f.port && ipv4Regex.test(f.h)) { addr += '/ip4/' + f.h + '/tcp/' + f.port + '/' } else if (f.port && ipv6Regex.test(f.h)) { addr += '/ip6/' + f.h + '/tcp/' + f.port + '/' From 41eed04a65a98c7280f62139a8407d005d19f95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Tue, 23 Oct 2018 18:51:51 +0200 Subject: [PATCH 60/75] fix: logo was broken on main page (#25) --- src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.html b/src/index.html index 993b796..ad9e848 100644 --- a/src/index.html +++ b/src/index.html @@ -22,7 +22,7 @@

- Libp2p Logo + Libp2p Logo

This is a libp2p-websocket-star signalling-server

Signaling Servers are used in libp2p to allow browsers and clients with restricted port-forwarding
to communicate with other peers in the libp2p network

From 91db9cf20aa761e4692c5625d894408c99d48877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Fri, 9 Nov 2018 18:48:44 +0100 Subject: [PATCH 61/75] feat: use node 10 in docker image (#26) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 945a5f7..00c9c0f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:8 +FROM node:10 RUN wget -O /usr/local/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64 && chmod +x /usr/local/bin/dumb-init WORKDIR /usr/src/app COPY package.json . From f12aea3457f6300da0665806811d3d86951d335a Mon Sep 17 00:00:00 2001 From: Dirk McCormick Date: Mon, 26 Nov 2018 14:27:34 -0500 Subject: [PATCH 62/75] feat: include existing peers in response to ss-join --- src/routes.js | 3 ++- test/rendezvous.spec.js | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/routes.js b/src/routes.js index 89d87d3..cb1b459 100644 --- a/src/routes.js +++ b/src/routes.js @@ -166,7 +166,8 @@ module.exports = (config, http) => { socket.stopSendingPeersIntv[multiaddr] = stopSendingPeers - cb() + const otherPeers = Object.keys(getPeers()).filter(mh => mh !== multiaddr) + cb(null, null, otherPeers) } function leave (socket, multiaddr) { diff --git a/test/rendezvous.spec.js b/test/rendezvous.spec.js index 6740b2e..56a2043 100644 --- a/test/rendezvous.spec.js +++ b/test/rendezvous.spec.js @@ -101,16 +101,24 @@ describe('rendezvous', () => { }) it('ss-join first client', (done) => { - c1.emit('ss-join', c1mh.toString(), '', err => { + c1.emit('ss-join', c1mh.toString(), '', (err, sig, peers) => { expect(err).to.not.exist() + expect(peers).to.eql([]) expect(Object.keys(r.peers()).length).to.equal(1) done() }) }) it('ss-join and ss-leave second client', (done) => { - c2.emit('ss-join', c2mh.toString(), '', err => { + let c1WsPeerEvent + c1.once('ws-peer', (p) => { + c1WsPeerEvent = p + }) + + c2.emit('ss-join', c2mh.toString(), '', (err, sig, peers) => { expect(err).to.not.exist() + expect(peers).to.eql([c1mh.toString()]) + expect(c1WsPeerEvent).to.equal(c2mh.toString()) expect(Object.keys(r.peers()).length).to.equal(2) c2.emit('ss-leave', c2mh.toString()) @@ -122,8 +130,9 @@ describe('rendezvous', () => { }) it('ss-join and disconnect third client', (done) => { - c3.emit('ss-join', c3mh.toString(), '', err => { + c3.emit('ss-join', c3mh.toString(), '', (err, sig, peers) => { expect(err).to.not.exist() + expect(peers).to.eql([c1mh.toString()]) expect(Object.keys(r.peers()).length).to.equal(2) c3.disconnect() setTimeout(() => { From 3d9b96e958162311f26b0fb0fdbca2f635a4bb7c Mon Sep 17 00:00:00 2001 From: Jim Pick Date: Wed, 28 Nov 2018 01:07:39 +0900 Subject: [PATCH 63/75] fix: remove warning for too many listeners on socket.io sockets (#28) It's fairly normal to have more than 10 listeners on a socket for the rendezvous server. --- src/routes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/routes.js b/src/routes.js index cb1b459..b7b971b 100644 --- a/src/routes.js +++ b/src/routes.js @@ -60,6 +60,7 @@ module.exports = (config, http) => { function handle (socket) { socket.addrs = [] socket.cleanaddrs = {} + socket.setMaxListeners(0) sp(socket, { codec: 'buffer' }) From c624fe815b04ceb42d0a96a77c3a5c71bada5070 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Tue, 27 Nov 2018 14:11:32 +0100 Subject: [PATCH 64/75] chore: update dependencies License: MIT Signed-off-by: Jacob Heun --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index b82dda0..48acefa 100644 --- a/package.json +++ b/package.json @@ -28,29 +28,29 @@ "dependencies": { "async": "^2.6.1", "data-queue": "0.0.3", - "debug": "^3.1.0", + "debug": "^4.1.0", "epimetheus": "^1.0.92", "hapi": "^16.6.2", "inert": "^4.2.1", - "libp2p-crypto": "~0.14.0", + "libp2p-crypto": "~0.14.1", "mafmt": "^6.0.2", "merge-recursive": "0.0.3", "minimist": "^1.2.0", - "multiaddr": "^5.0.0", + "multiaddr": "^5.0.2", "once": "^1.4.0", - "peer-id": "~0.11.0", + "peer-id": "~0.12.0", "peer-info": "~0.14.1", "prom-client": "^11.1.3", "socket.io": "^2.1.1", "socket.io-client": "^2.1.1", "socket.io-pull-stream": "~0.1.5", - "uuid": "^3.2.1" + "uuid": "^3.3.2" }, "directories": { "test": "test" }, "devDependencies": { - "aegir": "^15.3.1", + "aegir": "^17.1.1", "chai": "^4.2.0", "dirty-chai": "^2.0.1", "lodash": "^4.17.11" From 091f65c9c18e63fd307e53b4c0a452a16eb43e42 Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Tue, 27 Nov 2018 14:12:41 +0100 Subject: [PATCH 65/75] chore: add npm publish files whitelisting License: MIT Signed-off-by: Jacob Heun --- package.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package.json b/package.json index 48acefa..01012fb 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,10 @@ "description": "The rendezvous service for libp2p-websocket-star", "leadMaintainer": "Jacob Heun ", "main": "src/index.js", + "files": [ + "dist", + "src" + ], "bin": { "rendezvous": "src/bin.js", "websocket-star": "src/bin.js" From c6a833ece8e96ec07d251e3799e450120b1fac1b Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Tue, 27 Nov 2018 14:27:13 +0100 Subject: [PATCH 66/75] fix: dont use 'this' in root anon function License: MIT Signed-off-by: Jacob Heun --- src/routes.js | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/routes.js b/src/routes.js index b7b971b..8811df1 100644 --- a/src/routes.js +++ b/src/routes.js @@ -31,7 +31,7 @@ module.exports = (config, http) => { log('create new server', config) - this._peers = {} + const _peers = {} const nonces = {} const peersMetric = config.metrics ? new client.Gauge({ name: 'rendezvous_peers', help: 'peers online now' }) : fake.gauge @@ -42,13 +42,10 @@ module.exports = (config, http) => { const joinsFailureTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total_failure', help: 'failed joins since server started' }) : fake.counter const joinsTotal = config.metrics ? new client.Counter({ name: 'rendezvous_joins_total', help: 'all joins since server started' }) : fake.counter - const getPeers = () => this._peers // it's a function because, and I'm not kidding, the value of that var is different for every peer that has joined - const refreshMetrics = () => peersMetric.set(Object.keys(getPeers()).length) - - this.peers = () => getPeers() + const refreshMetrics = () => peersMetric.set(Object.keys(_peers).length) function safeEmit (addr, event, arg) { - const peer = getPeers()[addr] + const peer = _peers[addr] if (!peer) { log('trying to emit %s but peer is gone', event) return @@ -130,7 +127,7 @@ module.exports = (config, http) => { function joinFinalize (socket, multiaddr, cb) { const log = getConfig().log.bind(getConfig().log, '[' + socket.id + ']') - getPeers()[multiaddr] = socket + _peers[multiaddr] = socket if (!socket.stopSendingPeersIntv) socket.stopSendingPeersIntv = {} joinsSuccessTotal.inc() refreshMetrics() @@ -146,7 +143,7 @@ module.exports = (config, http) => { sendPeers() function sendPeers () { - const list = Object.keys(getPeers()) + const list = Object.keys(_peers) log(multiaddr, 'sending', (list.length - 1).toString(), 'peer(s)') list.forEach((mh) => { if (mh === multiaddr) { @@ -167,14 +164,14 @@ module.exports = (config, http) => { socket.stopSendingPeersIntv[multiaddr] = stopSendingPeers - const otherPeers = Object.keys(getPeers()).filter(mh => mh !== multiaddr) + const otherPeers = Object.keys(_peers).filter(mh => mh !== multiaddr) cb(null, null, otherPeers) } function leave (socket, multiaddr) { - if (getPeers()[multiaddr] && getPeers()[multiaddr].id === socket.id) { + if (_peers[multiaddr] && _peers[multiaddr].id === socket.id) { socket.log('leaving', multiaddr) - delete getPeers()[multiaddr] + delete _peers[multiaddr] socket.addrs = socket.addrs.filter(m => m !== multiaddr) if (socket.stopSendingPeersIntv[multiaddr]) { socket.stopSendingPeersIntv[multiaddr]() @@ -186,8 +183,8 @@ module.exports = (config, http) => { function disconnect (socket) { socket.log('disconnected') - Object.keys(getPeers()).forEach((mh) => { - if (getPeers()[mh].id === socket.id) { + Object.keys(_peers).forEach((mh) => { + if (_peers[mh].id === socket.id) { leave(socket, mh) } }) @@ -205,7 +202,7 @@ module.exports = (config, http) => { } log(from, 'is dialing', to) - const peer = getPeers()[to] + const peer = _peers[to] if (!peer) { dialsFailureTotal.inc() @@ -226,5 +223,7 @@ module.exports = (config, http) => { }) } - return this + return { + peers: () => _peers + } } From 841e8d3567761ac06350fbcc9d62140aeaa9b1aa Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Thu, 29 Nov 2018 12:01:03 +0100 Subject: [PATCH 67/75] chore: update contributors --- package.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 01012fb..0bc606a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-websocket-star-rendezvous", - "version": "0.2.4", + "version": "0.3.0", "description": "The rendezvous service for libp2p-websocket-star", "leadMaintainer": "Jacob Heun ", "main": "src/index.js", @@ -69,9 +69,12 @@ "homepage": "https://github.com/libp2p/js-libp2p-websocket-star-rendezvous#readme", "contributors": [ "David Dias ", + "Dirk McCormick ", "Haad ", "Jacob Heun ", - "Victor Bjelkholm ", - "mkg20001 " + "Jim Pick ", + "LEE JAE HO ", + "Maciej Krüger ", + "Victor Bjelkholm " ] } From 56311e0ffb5e23feecac07c8c5fe8cd8f007722a Mon Sep 17 00:00:00 2001 From: Jacob Heun Date: Thu, 29 Nov 2018 12:01:03 +0100 Subject: [PATCH 68/75] chore: release version v0.3.0 License: MIT Signed-off-by: Jacob Heun --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17a5f02..ed9abdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ + +# [0.3.0](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.4...v0.3.0) (2018-11-29) + + +### Bug Fixes + +* dont use 'this' in root anon function ([c6a833e](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/c6a833e)) +* logo was broken on main page ([#25](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues/25)) ([41eed04](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/41eed04)) +* regex bug for ipv4 test ([#24](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues/24)) ([696ed92](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/696ed92)) +* remove warning for too many listeners on socket.io sockets ([#28](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues/28)) ([3d9b96e](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/3d9b96e)) + + +### Features + +* include existing peers in response to ss-join ([f12aea3](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/f12aea3)) +* use node 10 in docker image ([#26](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/issues/26)) ([91db9cf](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/91db9cf)) + + + ## [0.2.4](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.3...v0.2.4) (2018-10-16) From 78cdf22892aede27a705363352fa86e819d9e950 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Tue, 23 Apr 2019 10:52:18 +0100 Subject: [PATCH 69/75] chore: add discourse badge (#30) --- .travis.yml | 28 ++++++++++++++++++++++++++++ README.md | 11 +++++++---- ci/Jenkinsfile | 2 -- package.json | 22 +++++++++++----------- 4 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 .travis.yml delete mode 100644 ci/Jenkinsfile diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..32d81f9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,28 @@ +language: node_js +cache: npm +stages: + - check + - test + - cov + +node_js: + - '10' + +os: + - linux + - osx + - windows + +script: npx nyc -s npm run test:node -- --bail +after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov + +jobs: + include: + - stage: check + script: + - npx aegir commitlint --travis + - npx aegir dep-check -- -i wrtc -i electron-webrtc + - npm run lint + +notifications: + email: false diff --git a/README.md b/README.md index 1b9493b..d29f7b0 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # libp2p-websocket-star-rendezvous [![](https://img.shields.io/badge/made%20by-mkg20001-blue.svg?style=flat-square)](http://ipn.io) -[![Travis](https://travis-ci.org/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=flat-square)](https://travis-ci.org/libp2p/js-libp2p-websocket-star-rendezvous) -[![Circle](https://circleci.com/gh/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=svg)](https://circleci.com/gh/libp2p/js-libp2p-websocket-star-rendezvous) -[![Coverage](https://coveralls.io/repos/github/libp2p/js-libp2p-websocket-star-rendezvous/badge.svg?branch=master)](https://coveralls.io/github/libp2p/js-libp2p-websocket-star-rendezvous?branch=master) -[![david-dm](https://david-dm.org/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websocket-star-rendezvous) +[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) +[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) +[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io) +[![](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-websocket-star-rendezvous) +[![](https://img.shields.io/travis/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=flat-square)](https://travis-ci.com/libp2p/js-libp2p-websocket-star-rendezvous) +[![Dependency Status](https://david-dm.org/libp2p/js-libp2p-websocket-star-rendezvous.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websocket-star-rendezvous) +[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) > The rendezvous service for [libp2p-websocket-star](https://github.com/libp2p/js-libp2p-websocket-star). diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile deleted file mode 100644 index a7da2e5..0000000 --- a/ci/Jenkinsfile +++ /dev/null @@ -1,2 +0,0 @@ -// 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() diff --git a/package.json b/package.json index 0bc606a..9c135e9 100644 --- a/package.json +++ b/package.json @@ -30,23 +30,23 @@ ], "license": "MIT", "dependencies": { - "async": "^2.6.1", + "async": "^2.6.2", "data-queue": "0.0.3", - "debug": "^4.1.0", + "debug": "^4.1.1", "epimetheus": "^1.0.92", "hapi": "^16.6.2", "inert": "^4.2.1", - "libp2p-crypto": "~0.14.1", - "mafmt": "^6.0.2", + "libp2p-crypto": "~0.16.1", + "mafmt": "^6.0.7", "merge-recursive": "0.0.3", "minimist": "^1.2.0", - "multiaddr": "^5.0.2", + "multiaddr": "^6.0.6", "once": "^1.4.0", - "peer-id": "~0.12.0", - "peer-info": "~0.14.1", - "prom-client": "^11.1.3", - "socket.io": "^2.1.1", - "socket.io-client": "^2.1.1", + "peer-id": "~0.12.2", + "peer-info": "~0.15.1", + "prom-client": "^11.3.0", + "socket.io": "^2.2.0", + "socket.io-client": "^2.2.0", "socket.io-pull-stream": "~0.1.5", "uuid": "^3.3.2" }, @@ -54,7 +54,7 @@ "test": "test" }, "devDependencies": { - "aegir": "^17.1.1", + "aegir": "^18.2.2", "chai": "^4.2.0", "dirty-chai": "^2.0.1", "lodash": "^4.17.11" From 331c67e0dc467d33fe26fc230d64b0a51f63545e Mon Sep 17 00:00:00 2001 From: Justin Maier Date: Sun, 30 Jun 2019 11:47:28 +0200 Subject: [PATCH 70/75] Add options for WSS - fixes #31 --- README.md | 17 +++++++++++++++++ src/bin.js | 4 ++++ src/index.js | 17 ++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d29f7b0..4352857 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,23 @@ A libp2p-websocket-star address, using the signalling server we provide, looks l Note: The address above indicates WebSockets Secure, which can be accessed from both http and https. +### Using WSS + +To be able to interact with a rendezvous server from an HTTPS site, you will need to use websocket secure. To host a secure websocket server, you must provide a keypair to the server. + +#### Using key and certificate + +```bash +> rendezvous --key="path/to/key.key" --cert="path/to/cert.cert" +``` + +#### Using PFX with passphrase + +```bash +> rendezvous --pfx="path/to/pair.pfx" --passphrase="passphrase" +``` + + ### This module uses `pull-streams` We expose a streaming interface based on `pull-streams`, rather then on the Node.js core streams implementation (aka Node.js streams). `pull-streams` offers us a better mechanism for error handling and flow control guarantees. If you would like to know more about why we did this, see the discussion at this [issue](https://github.com/ipfs/js-ipfs/issues/362). diff --git a/src/bin.js b/src/bin.js index abfb0d1..2f3d867 100755 --- a/src/bin.js +++ b/src/bin.js @@ -12,6 +12,10 @@ let server signalling.start({ port: argv.port || argv.p || process.env.PORT || 9090, host: argv.host || argv.h || process.env.HOST || '0.0.0.0', + key: argv.key || process.env.KEY, + cert: argv.cert || process.env.CERT, + pfx: argv.pfx || process.env.PFX, + passphrase: argv.passphrase || process.env.PFX_PASSPHRASE, cryptoChallenge: !(argv.disableCryptoChallenge || process.env.DISABLE_CRYPTO_CHALLENGE), strictMultiaddr: !(argv.disableStrictMultiaddr || process.env.DISABLE_STRICT_MULTIADDR), metrics: !(argv.disableMetrics || process.env.DISABLE_METRICS) diff --git a/src/index.js b/src/index.js index a914afb..c55ecaf 100644 --- a/src/index.js +++ b/src/index.js @@ -5,6 +5,7 @@ const path = require('path') const epimetheus = require('epimetheus') const merge = require('merge-recursive').recursive const defaultConfig = require('./config') +const { readFileSync } = require('fs') exports = module.exports @@ -22,7 +23,21 @@ exports.start = (options, callback) => { const http = new Hapi.Server(config.hapi.options) - http.connection({ port, host }) + let tls + if (options.key && options.cert) { + tls = { + key: readFileSync(options.key), + cert: readFileSync(options.cert), + passphrase: options.passphrase + } + } else if (options.pfx && options.passphrase) { + tls = { + pfx: readFileSync(options.pfx), + passphrase: options.passphrase + } + } + + http.connection({ port, host, tls }) http.register({ register: require('inert') }, (err) => { if (err) { From 946e8a18e1d9424d9ab087ce79e92687fef5d9ce Mon Sep 17 00:00:00 2001 From: mkg20001 Date: Fri, 24 Nov 2017 20:51:57 +0100 Subject: [PATCH 71/75] feat: switches to async/await and upgrade hapi to v18 BREAKING CHANGE: All functions that took callbacks now return promises --- package.json | 27 ++++++------- src/bin.js | 48 ++++++++++++---------- src/config.js | 6 +-- src/index.js | 54 ++++++++++--------------- src/utils.js | 17 ++++---- test/rendezvous.spec.js | 88 ++++++++++++++++++++++------------------- 6 files changed, 119 insertions(+), 121 deletions(-) diff --git a/package.json b/package.json index 9c135e9..1298d47 100644 --- a/package.json +++ b/package.json @@ -30,31 +30,30 @@ ], "license": "MIT", "dependencies": { - "async": "^2.6.2", "data-queue": "0.0.3", "debug": "^4.1.1", - "epimetheus": "^1.0.92", - "hapi": "^16.6.2", - "inert": "^4.2.1", - "libp2p-crypto": "~0.16.1", + "epimetheus": "achingbrain/node-epimetheus#hapi-18-support", + "@hapi/hapi": "^18.3.1", + "@hapi/inert": "^5.2.1", + "libp2p-crypto": "~0.17.0", "mafmt": "^6.0.7", "merge-recursive": "0.0.3", "minimist": "^1.2.0", - "multiaddr": "^6.0.6", + "multiaddr": "^6.1.0", "once": "^1.4.0", - "peer-id": "~0.12.2", - "peer-info": "~0.15.1", - "prom-client": "^11.3.0", - "socket.io": "^2.2.0", - "socket.io-client": "^2.2.0", - "socket.io-pull-stream": "~0.1.5", - "uuid": "^3.3.2" + "peer-id": "~0.13.1", + "peer-info": "~0.16.0", + "prom-client": "^11.5.3", + "socket.io": "^2.0.4", + "socket.io-client": "^2.0.4", + "socket.io-pull-stream": "^0.1.1", + "uuid": "^3.1.0" }, "directories": { "test": "test" }, "devDependencies": { - "aegir": "^18.2.2", + "aegir": "^19.0.5", "chai": "^4.2.0", "dirty-chai": "^2.0.1", "lodash": "^4.17.11" diff --git a/src/bin.js b/src/bin.js index 2f3d867..4327db2 100755 --- a/src/bin.js +++ b/src/bin.js @@ -5,30 +5,38 @@ const signalling = require('./index') const argv = require('minimist')(process.argv.slice(2)) -let server - /* eslint-disable no-console */ -signalling.start({ - port: argv.port || argv.p || process.env.PORT || 9090, - host: argv.host || argv.h || process.env.HOST || '0.0.0.0', - key: argv.key || process.env.KEY, - cert: argv.cert || process.env.CERT, - pfx: argv.pfx || process.env.PFX, - passphrase: argv.passphrase || process.env.PFX_PASSPHRASE, - cryptoChallenge: !(argv.disableCryptoChallenge || process.env.DISABLE_CRYPTO_CHALLENGE), - strictMultiaddr: !(argv.disableStrictMultiaddr || process.env.DISABLE_STRICT_MULTIADDR), - metrics: !(argv.disableMetrics || process.env.DISABLE_METRICS) -}, (err, _server) => { - if (err) { throw err } - server = _server +async function start () { + const server = await signalling.start({ + port: argv.port || argv.p || process.env.PORT || 9090, + host: argv.host || argv.h || process.env.HOST || '0.0.0.0', + key: argv.key || process.env.KEY, + cert: argv.cert || process.env.CERT, + pfx: argv.pfx || process.env.PFX, + passphrase: argv.passphrase || process.env.PFX_PASSPHRASE, + cryptoChallenge: !(argv.disableCryptoChallenge || process.env.DISABLE_CRYPTO_CHALLENGE), + strictMultiaddr: !(argv.disableStrictMultiaddr || process.env.DISABLE_STRICT_MULTIADDR), + metrics: !(argv.disableMetrics || process.env.DISABLE_METRICS) + }) console.log('Listening on:', server.info.uri) -}) -process.on('SIGINT', () => { - server.stop((err) => { + process.on('SIGINT', async () => { + try { + await server.stop() + } catch (err) { + console.error(err) + process.exit(2) + } + console.log('Rendezvous server stopped') - process.exit(err ? 2 : 0) + process.exit(0) + }) +} + +start() + .catch((err) => { + console.error(err) + process.exit(2) }) -}) diff --git a/src/config.js b/src/config.js index 1f6e8f2..6a31c85 100644 --- a/src/config.js +++ b/src/config.js @@ -10,10 +10,8 @@ module.exports = { port: process.env.PORT || 13579, host: '0.0.0.0', options: { - connections: { - routes: { - cors: true - } + routes: { + cors: true } } }, diff --git a/src/index.js b/src/index.js index c55ecaf..30cbaef 100644 --- a/src/index.js +++ b/src/index.js @@ -1,28 +1,21 @@ 'use strict' -const Hapi = require('hapi') +const Hapi = require('@hapi/hapi') const path = require('path') const epimetheus = require('epimetheus') const merge = require('merge-recursive').recursive -const defaultConfig = require('./config') +const Inert = require('@hapi/inert') const { readFileSync } = require('fs') exports = module.exports -exports.start = (options, callback) => { - if (typeof options === 'function') { - callback = options - options = {} - } - - const config = merge(Object.assign({}, defaultConfig), options) +exports.start = async (options = {}) => { + const config = merge(Object.assign({}, require('./config')), Object.assign({}, options)) const log = config.log const port = options.port || config.hapi.port const host = options.host || config.hapi.host - const http = new Hapi.Server(config.hapi.options) - let tls if (options.key && options.cert) { tls = { @@ -37,35 +30,30 @@ exports.start = (options, callback) => { } } - http.connection({ port, host, tls }) + const http = new Hapi.Server(Object.assign({ + port, + host, + tls + }, config.hapi.options)) - http.register({ register: require('inert') }, (err) => { - if (err) { - return callback(err) - } + await http.register(Inert) + await http.start() - http.start((err) => { - if (err) { - return callback(err) - } + log('rendezvous server has started on: ' + http.info.uri) - log('rendezvous server has started on: ' + http.info.uri) + http.peers = require('./routes')(config, http).peers - http.peers = require('./routes')(config, http).peers - - http.route({ - method: 'GET', - path: '/', - handler: (request, reply) => reply.file(path.join(__dirname, 'index.html'), { - confine: false - }) - }) - - callback(null, http) + http.route({ + method: 'GET', + path: '/', + handler: (request, reply) => reply.file(path.join(__dirname, 'index.html'), { + confine: false }) }) - if (config.metrics) { epimetheus.instrument(http) } + if (config.metrics) { + epimetheus.instrument(http) + } return http } diff --git a/src/utils.js b/src/utils.js index 3ea0fa3..b026b7c 100644 --- a/src/utils.js +++ b/src/utils.js @@ -101,17 +101,14 @@ function Protocol (log) { } function getIdAndValidate (pub, id, cb) { - Id.createFromPubKey(Buffer.from(pub, 'hex'), (err, _id) => { - if (err) { - return cb(new Error('Crypto error')) - } - - if (_id.toB58String() !== id) { - return cb(new Error('Id is not matching')) - } + Id.createFromPubKey(Buffer.from(pub, 'hex')) + .then(_id => { + if (_id.toB58String() !== id) { + throw Error('Id is not matching') + } - return cb(null, crypto.keys.unmarshalPublicKey(Buffer.from(pub, 'hex'))) - }) + return crypto.keys.unmarshalPublicKey(Buffer.from(pub, 'hex')) + }, cb) } exports = module.exports diff --git a/test/rendezvous.spec.js b/test/rendezvous.spec.js index 56a2043..5d29db5 100644 --- a/test/rendezvous.spec.js +++ b/test/rendezvous.spec.js @@ -12,6 +12,32 @@ const uuid = require('uuid') const rendezvous = require('../src') describe('rendezvous', () => { + it('start and stop signalling server (default port)', async () => { + const server = await rendezvous.start() + + expect(server.info.port).to.equal(13579) + expect(server.info.protocol).to.equal('http') + expect(server.info.address).to.equal('0.0.0.0') + + await server.stop() + }) + + it('start and stop signalling server (custom port)', async () => { + const options = { + port: 12345 + } + + const server = await rendezvous.start(options) + + expect(server.info.port).to.equal(options.port) + expect(server.info.protocol).to.equal('http') + expect(server.info.address).to.equal('0.0.0.0') + + await server.stop() + }) +}) + +describe('signalling server client', () => { const sioOptions = { transports: ['websocket'], 'force new connection': true @@ -29,31 +55,7 @@ describe('rendezvous', () => { let c3mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo3') let c4mh = multiaddr('/ip4/127.0.0.1/tcp/9090/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4') - it('start and stop signalling server (default port)', (done) => { - rendezvous.start((err, server) => { - expect(err).to.not.exist() - expect(server.info.port).to.equal(13579) - expect(server.info.protocol).to.equal('http') - expect(server.info.address).to.equal('0.0.0.0') - server.stop(done) - }) - }) - - it('start and stop signalling server (custom port)', (done) => { - const options = { - port: 12345 - } - - rendezvous.start(options, (err, server) => { - expect(err).to.not.exist() - expect(server.info.port).to.equal(12345) - expect(server.info.protocol).to.equal('http') - expect(server.info.address).to.equal('0.0.0.0') - server.stop(done) - }) - }) - - it('start signalling server for client tests', (done) => { + before(async () => { const options = { port: 12345, refreshPeerListIntervalMS: 1000, @@ -62,15 +64,27 @@ describe('rendezvous', () => { metrics: true } - rendezvous.start(options, (err, server) => { - expect(err).to.not.exist() - expect(server.info.port).to.equal(12345) - expect(server.info.protocol).to.equal('http') - expect(server.info.address).to.equal('0.0.0.0') - sioUrl = server.info.uri - r = server - done() - }) + const server = await rendezvous.start(options) + + expect(server.info.port).to.equal(12345) + expect(server.info.protocol).to.equal('http') + expect(server.info.address).to.equal('0.0.0.0') + sioUrl = server.info.uri + r = server + }) + + after(async () => { + if (c1) { + c1.disconnect() + } + + if (c2) { + c2.disconnect() + } + + if (r) { + await r.stop() + } }) it('zero peers', () => { @@ -196,10 +210,4 @@ describe('rendezvous', () => { } } }).timeout(4000) - - it('stop signalling server', (done) => { - c1.disconnect() - c2.disconnect() - r.stop(done) - }) }) From 7ef54b2debc0e40dfa17aa31feb39301c1af024d Mon Sep 17 00:00:00 2001 From: achingbrain Date: Fri, 19 Jul 2019 18:36:29 +0100 Subject: [PATCH 72/75] chore: use forked module until roylines/node-epimetheus#63 is merged --- package.json | 2 +- src/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 1298d47..351c73c 100644 --- a/package.json +++ b/package.json @@ -32,11 +32,11 @@ "dependencies": { "data-queue": "0.0.3", "debug": "^4.1.1", - "epimetheus": "achingbrain/node-epimetheus#hapi-18-support", "@hapi/hapi": "^18.3.1", "@hapi/inert": "^5.2.1", "libp2p-crypto": "~0.17.0", "mafmt": "^6.0.7", + "menoetius": "~0.0.2", "merge-recursive": "0.0.3", "minimist": "^1.2.0", "multiaddr": "^6.1.0", diff --git a/src/index.js b/src/index.js index 30cbaef..a421b1f 100644 --- a/src/index.js +++ b/src/index.js @@ -2,7 +2,7 @@ const Hapi = require('@hapi/hapi') const path = require('path') -const epimetheus = require('epimetheus') +const menoetius = require('menoetius') const merge = require('merge-recursive').recursive const Inert = require('@hapi/inert') const { readFileSync } = require('fs') @@ -52,7 +52,7 @@ exports.start = async (options = {}) => { }) if (config.metrics) { - epimetheus.instrument(http) + menoetius.instrument(http) } return http From e5c5e12b4a6f10b3a4335fec20108852a1acc0fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Fri, 19 Jul 2019 19:52:37 +0200 Subject: [PATCH 73/75] chore: update contributors --- package.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 351c73c..f0d714d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "libp2p-websocket-star-rendezvous", - "version": "0.3.0", + "version": "0.4.0", "description": "The rendezvous service for libp2p-websocket-star", "leadMaintainer": "Jacob Heun ", "main": "src/index.js", @@ -72,8 +72,11 @@ "Haad ", "Jacob Heun ", "Jim Pick ", + "Justin Maier ", "LEE JAE HO ", - "Maciej Krüger ", - "Victor Bjelkholm " + "Vasco Santos ", + "Victor Bjelkholm ", + "achingbrain ", + "mkg20001 " ] } From e0e799d012f06d9e1e23b1e405d840297ba7255d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Fri, 19 Jul 2019 19:52:37 +0200 Subject: [PATCH 74/75] chore: release version v0.4.0 --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed9abdc..255e4b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ + +# [0.4.0](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.3.0...v0.4.0) (2019-07-19) + + +### Features + +* switches to async/await and upgrade hapi to v18 ([946e8a1](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/commit/946e8a1)) + + +### BREAKING CHANGES + +* All functions that took callbacks now return promises + + + # [0.3.0](https://github.com/libp2p/js-libp2p-websocket-star-rendezvous/compare/v0.2.4...v0.3.0) (2018-11-29) From f72cfb146d8b3fa6611ca134d04245fd8e96cfd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kr=C3=BCger?= Date: Sun, 21 Jul 2019 12:49:39 +0200 Subject: [PATCH 75/75] misc: merge server into server/ (fix #73) --- .gitignore => server/.gitignore | 0 .travis.yml => server/.travis.yml | 0 CHANGELOG.md => server/CHANGELOG.md | 0 DEPLOYMENT.md => server/DEPLOYMENT.md | 0 Dockerfile => server/Dockerfile | 0 LICENSE => server/LICENSE | 0 Procfile => server/Procfile | 0 README.md => server/README.md | 0 package.json => server/package.json | 0 {src => server/src}/bin.js | 0 {src => server/src}/config.js | 0 {src => server/src}/index.html | 0 {src => server/src}/index.js | 0 {src => server/src}/routes.js | 0 {src => server/src}/utils.js | 0 {test => server/test}/rendezvous.spec.js | 0 16 files changed, 0 insertions(+), 0 deletions(-) rename .gitignore => server/.gitignore (100%) rename .travis.yml => server/.travis.yml (100%) rename CHANGELOG.md => server/CHANGELOG.md (100%) rename DEPLOYMENT.md => server/DEPLOYMENT.md (100%) rename Dockerfile => server/Dockerfile (100%) rename LICENSE => server/LICENSE (100%) rename Procfile => server/Procfile (100%) rename README.md => server/README.md (100%) rename package.json => server/package.json (100%) rename {src => server/src}/bin.js (100%) rename {src => server/src}/config.js (100%) rename {src => server/src}/index.html (100%) rename {src => server/src}/index.js (100%) rename {src => server/src}/routes.js (100%) rename {src => server/src}/utils.js (100%) rename {test => server/test}/rendezvous.spec.js (100%) diff --git a/.gitignore b/server/.gitignore similarity index 100% rename from .gitignore rename to server/.gitignore diff --git a/.travis.yml b/server/.travis.yml similarity index 100% rename from .travis.yml rename to server/.travis.yml diff --git a/CHANGELOG.md b/server/CHANGELOG.md similarity index 100% rename from CHANGELOG.md rename to server/CHANGELOG.md diff --git a/DEPLOYMENT.md b/server/DEPLOYMENT.md similarity index 100% rename from DEPLOYMENT.md rename to server/DEPLOYMENT.md diff --git a/Dockerfile b/server/Dockerfile similarity index 100% rename from Dockerfile rename to server/Dockerfile diff --git a/LICENSE b/server/LICENSE similarity index 100% rename from LICENSE rename to server/LICENSE diff --git a/Procfile b/server/Procfile similarity index 100% rename from Procfile rename to server/Procfile diff --git a/README.md b/server/README.md similarity index 100% rename from README.md rename to server/README.md diff --git a/package.json b/server/package.json similarity index 100% rename from package.json rename to server/package.json diff --git a/src/bin.js b/server/src/bin.js similarity index 100% rename from src/bin.js rename to server/src/bin.js diff --git a/src/config.js b/server/src/config.js similarity index 100% rename from src/config.js rename to server/src/config.js diff --git a/src/index.html b/server/src/index.html similarity index 100% rename from src/index.html rename to server/src/index.html diff --git a/src/index.js b/server/src/index.js similarity index 100% rename from src/index.js rename to server/src/index.js diff --git a/src/routes.js b/server/src/routes.js similarity index 100% rename from src/routes.js rename to server/src/routes.js diff --git a/src/utils.js b/server/src/utils.js similarity index 100% rename from src/utils.js rename to server/src/utils.js diff --git a/test/rendezvous.spec.js b/server/test/rendezvous.spec.js similarity index 100% rename from test/rendezvous.spec.js rename to server/test/rendezvous.spec.js