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

Commit

Permalink
fix: give crypto.verify a buffer (#23)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jacobheun authored Oct 16, 2018
1 parent 33a750e commit 0c8c290
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 124 deletions.
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<your-peer-id>`
`/dns4/ws-star.discovery.libp2p.io/wss/p2p-websocket-star/ipfs/<your-peer-id>`

Note: The address above indicates WebSockets Secure, which can be accessed from both http and https.

Expand Down
29 changes: 0 additions & 29 deletions appveyor.yml

This file was deleted.

15 changes: 0 additions & 15 deletions circle.yml

This file was deleted.

29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
23 changes: 13 additions & 10 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
26 changes: 14 additions & 12 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '<server>', 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 || '<server>', request, data)
}
})
}
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions test/.jshintrc

This file was deleted.

0 comments on commit 0c8c290

Please sign in to comment.