Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
chore: backport libp2p noise as fallback for secio (#3074) (#3211)
Browse files Browse the repository at this point in the history
Adds `libp2p-noise` encryption protocol as a fallback for `libp2p-secio`. This replicates what happened in [ipfs/go-ipfs/releases/v0.5.0](https://github.com/ipfs/go-ipfs/releases/tag/v0.5.0).

>SECIO Deprecation Notice
>SECIO should be considered to be well on the way to deprecation and will be
>completely disabled in either the next release (0.6.0, ~mid May) or the one
>following that (0.7.0, ~end of June). Before SECIO is disabled, support will be
>added for the NOISE transport for compatibility with other IPFS implementations.

From what I know, this is likely to happen for `0.7.0`.

We currently have interop tests for using noise in [libp2p/interop/test/connect](https://github.com/libp2p/interop/tree/master/test/connect). I think there are enough for now, but when we use noise as default in JS and GO, we will definitely want to make sure we have more verbose interop before we switch to default. AFAIK, with the current setup of `ipfsd-ctl` we cannot specify what libp2p modules to use.

Co-authored-by: Vasco Santos <vasco.santos@moxy.studio>
Co-authored-by: Alex Potsides <alex@achingbrain.net>
  • Loading branch information
3 people committed Aug 12, 2020
1 parent 997d936 commit fad81d6
Show file tree
Hide file tree
Showing 28 changed files with 39 additions and 30 deletions.
2 changes: 1 addition & 1 deletion examples/browser-add-readable-stream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"keywords": [],
"license": "MIT",
"devDependencies": {
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"test-ipfs-example": "^2.0.3"
}
}
2 changes: 1 addition & 1 deletion examples/browser-browserify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"concat-stream": "^2.0.0",
"execa": "^4.0.0",
"http-server": "^0.11.1",
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"test-ipfs-example": "^2.0.3"
},
"browser": {
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"dot-prop": "^5.0.0",
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"ipfs-css": "^0.13.1",
"react": "^16.8.6",
"react-dom": "^16.8.6",
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-mfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"webpack-cli": "^3.3.11"
},
"dependencies": {
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"mime-sniffer": "~0.0.3"
}
}
2 changes: 1 addition & 1 deletion examples/browser-parceljs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"ipfs": "^0.45.0"
"ipfs": "^0.46.0"
},
"devDependencies": {
"@babel/cli": "^7.1.5",
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-readablestream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"webpack": "^4.28.4"
},
"dependencies": {
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"it-to-stream": "^0.1.1",
"videostream": "^3.2.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-script-tag/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"test-ipfs-example": "^2.0.3"
},
"dependencies": {
"ipfs": "^0.45.0"
"ipfs": "^0.46.0"
}
}
2 changes: 1 addition & 1 deletion examples/browser-video-streaming/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"test-ipfs-example": "^2.0.3"
},
"dependencies": {
"ipfs": "^0.45.0"
"ipfs": "^0.46.0"
}
}
2 changes: 1 addition & 1 deletion examples/browser-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"core-js": "^3.6.4",
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"vue": "^2.6.11"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/browser-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"webpack-dev-server": "^3.1.14"
},
"dependencies": {
"ipfs": "^0.45.0"
"ipfs": "^0.46.0"
},
"browserslist": [
">1%",
Expand Down
4 changes: 2 additions & 2 deletions examples/circuit-relaying/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"author": "Dmitriy Ryajov <dryajov@gmail.com>",
"license": "MIT",
"dependencies": {
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"ipfs-pubsub-room": "^2.0.1"
},
"devDependencies": {
"execa": "^4.0.0",
"ipfs-css": "^0.13.1",
"ipfs-http-client": "^44.1.1",
"ipfs-http-client": "^44.2.0",
"parcel-bundler": "^1.12.4",
"tachyons": "^4.9.1",
"test-ipfs-example": "^2.0.3"
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-ipfs-repo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"license": "MIT",
"dependencies": {
"datastore-fs": "^1.1.0",
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"ipfs-repo": "^3.0.0",
"it-all": "^1.0.1"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/custom-libp2p/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"license": "MIT",
"dependencies": {
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"libp2p": "^0.27.7",
"libp2p-bootstrap": "^0.10.3",
"libp2p-kad-dht": "^0.18.7",
Expand Down
4 changes: 2 additions & 2 deletions examples/exchange-files-in-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"browserify": "^16.2.3",
"execa": "^4.0.0",
"http-server": "^0.11.1",
"ipfs-http-client": "^44.1.1"
"ipfs-http-client": "^44.2.0"
},
"dependencies": {
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"it-all": "^1.0.1",
"it-last": "^1.0.1",
"test-ipfs-example": "^2.0.3"
Expand Down
4 changes: 2 additions & 2 deletions examples/explore-ethereum-blockchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"keywords": [],
"license": "MIT",
"devDependencies": {
"ipfs": "^0.45.0",
"ipfs-http-client": "^44.1.1",
"ipfs": "^0.46.0",
"ipfs-http-client": "^44.2.0",
"test-ipfs-example": "^2.0.3"
}
}
2 changes: 1 addition & 1 deletion examples/ipfs-101/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"author": "David Dias <daviddias@ipfs.io>",
"license": "MIT",
"dependencies": {
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"it-all": "^1.0.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/run-in-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"devDependencies": {
"electron": "^6.0.0",
"electron-rebuild": "^1.8.4",
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"test-ipfs-example": "^2.0.3"
},
"greenkeeper": {
Expand Down
2 changes: 1 addition & 1 deletion examples/running-multiple-nodes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"test-ipfs-example": "^2.0.3"
},
"dependencies": {
"ipfs": "^0.45.0"
"ipfs": "^0.46.0"
}
}
2 changes: 1 addition & 1 deletion examples/traverse-ipld-graphs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test-ipfs-example": "^2.0.3"
},
"dependencies": {
"ipfs": "^0.45.0",
"ipfs": "^0.46.0",
"ipld-block": "^0.9.1"
}
}
5 changes: 1 addition & 4 deletions packages/interface-ipfs-core/src/block/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ module.exports = (common, options) => {
})

it('should return an error for an invalid CID', () => {
return expect(ipfs.block.get('invalid')).to.eventually.be.rejected
.and.be.an.instanceOf(Error)
.and.have.property('message')
.that.include('Non-base58 character')
return expect(ipfs.block.get('invalid')).to.eventually.be.rejected()
})
})
}
6 changes: 5 additions & 1 deletion packages/interface-ipfs-core/src/object/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ module.exports = (common, options) => {
const cid = await ipfs.object.put(node1b)
const node = await ipfs.object.get(cid)
expect(node1b.Data).to.deep.equal(node.Data)
expect(node1b.Links).to.deep.equal(node.Links)
expect(node1b.Links).to.deep.equal(node.Links.map(l => ({
Name: l.Name,
Tsize: l.Tsize,
Hash: l.Hash
})))
})
})
}
2 changes: 1 addition & 1 deletion packages/ipfs/.aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let sigServerB
let ipfsdServer

module.exports = {
bundlesize: { maxSize: '446kB' },
bundlesize: { maxSize: '545kB' },
karma: {
files: [{
pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*',
Expand Down
1 change: 1 addition & 0 deletions packages/ipfs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ List of the main packages that make up the IPFS ecosystem.
| [`libp2p-mdns`](//github.com/libp2p/js-libp2p-mdns) | [![npm](https://img.shields.io/npm/v/libp2p-mdns.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-mdns/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-mdns.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-mdns) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-mdns/master)](https://travis-ci.com/libp2p/js-libp2p-mdns) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-mdns/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-mdns) | [Jacob Heun](mailto:jacobheun@gmail.com) |
| [`libp2p-bootstrap`](//github.com/libp2p/js-libp2p-bootstrap) | [![npm](https://img.shields.io/npm/v/libp2p-bootstrap.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-bootstrap/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-bootstrap.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-bootstrap) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-bootstrap/master)](https://travis-ci.com/libp2p/js-libp2p-bootstrap) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-bootstrap/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-bootstrap) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
| [`libp2p-secio`](//github.com/libp2p/js-libp2p-secio) | [![npm](https://img.shields.io/npm/v/libp2p-secio.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-secio/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-secio.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-secio) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-secio/master)](https://travis-ci.com/libp2p/js-libp2p-secio) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-secio/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-secio) | [Friedel Ziegelmayer](mailto:dignifiedquire@gmail.com) |
| [`libp2p-noise`](//github.com/NodeFactoryIo/js-libp2p-noise) | [![npm](https://img.shields.io/npm/v/libp2p-noise.svg?maxAge=86400&style=flat-square)](//github.com/NodeFactoryIo/js-libp2p-noise/releases) | [![Deps](https://david-dm.org/NodeFactoryIo/js-libp2p-noise.svg?style=flat-square)](https://david-dm.org/NodeFactoryIo/js-libp2p-noise) | [![Travis CI](https://flat.badgen.net/travis/NodeFactoryIo/js-libp2p-noise/master)](https://travis-ci.com/NodeFactoryIo/js-libp2p-noise) | [![codecov](https://codecov.io/gh/NodeFactoryIo/js-libp2p-noise/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/NodeFactoryIo/js-libp2p-noise) | N/A |
| [`libp2p-tcp`](//github.com/libp2p/js-libp2p-tcp) | [![npm](https://img.shields.io/npm/v/libp2p-tcp.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-tcp/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-tcp.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-tcp) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-tcp/master)](https://travis-ci.com/libp2p/js-libp2p-tcp) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-tcp/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-tcp) | [Jacob Heun](mailto:jacobheun@gmail.com) |
| [`libp2p-webrtc-star`](//github.com/libp2p/js-libp2p-webrtc-star) | [![npm](https://img.shields.io/npm/v/libp2p-webrtc-star.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-webrtc-star/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-webrtc-star.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-webrtc-star) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-webrtc-star/master)](https://travis-ci.com/libp2p/js-libp2p-webrtc-star) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-webrtc-star/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-webrtc-star) | [Vasco Santos](mailto:vasco.santos@moxy.studio) |
| [`libp2p-websocket-star`](//github.com/libp2p/js-libp2p-websocket-star) | [![npm](https://img.shields.io/npm/v/libp2p-websocket-star.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-websocket-star/releases) | [![Deps](https://david-dm.org/libp2p/js-libp2p-websocket-star.svg?style=flat-square)](https://david-dm.org/libp2p/js-libp2p-websocket-star) | [![Travis CI](https://flat.badgen.net/travis/libp2p/js-libp2p-websocket-star/master)](https://travis-ci.com/libp2p/js-libp2p-websocket-star) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-websocket-star/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-websocket-star) | [Jacob Heun](mailto:jacobheun@gmail.com) |
Expand Down
1 change: 1 addition & 0 deletions packages/ipfs/package-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
["libp2p/js-libp2p-mdns", "libp2p-mdns"],
["libp2p/js-libp2p-bootstrap", "libp2p-bootstrap"],
["libp2p/js-libp2p-secio", "libp2p-secio"],
["NodeFactoryIo/js-libp2p-noise", "libp2p-noise"],
["libp2p/js-libp2p-tcp", "libp2p-tcp"],
["libp2p/js-libp2p-webrtc-star", "libp2p-webrtc-star"],
["libp2p/js-libp2p-websocket-star", "libp2p-websocket-star"],
Expand Down
1 change: 1 addition & 0 deletions packages/ipfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
"libp2p-keychain": "^0.6.0",
"libp2p-mdns": "^0.13.1",
"libp2p-mplex": "^0.9.3",
"libp2p-noise": "^1.1.1",
"libp2p-record": "^0.7.3",
"libp2p-secio": "^0.12.2",
"libp2p-tcp": "^0.14.5",
Expand Down
4 changes: 3 additions & 1 deletion packages/ipfs/src/core/runtime/libp2p-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const WS = require('libp2p-websockets')
const WebRTCStar = require('libp2p-webrtc-star')
const Multiplex = require('libp2p-mplex')
const { NOISE } = require('libp2p-noise')
const SECIO = require('libp2p-secio')
const KadDHT = require('libp2p-kad-dht')
const GossipSub = require('libp2p-gossipsub')
Expand All @@ -24,7 +25,8 @@ module.exports = () => {
Multiplex
],
connEncryption: [
SECIO
SECIO,
NOISE
],
peerDiscovery: [],
dht: KadDHT,
Expand Down
4 changes: 3 additions & 1 deletion packages/ipfs/src/core/runtime/libp2p-nodejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const KadDHT = require('libp2p-kad-dht')
const GossipSub = require('libp2p-gossipsub')
const Multiplex = require('libp2p-mplex')
const SECIO = require('libp2p-secio')
const { NOISE } = require('libp2p-noise')
const ipnsUtils = require('../ipns/routing/utils')

module.exports = () => {
Expand All @@ -25,7 +26,8 @@ module.exports = () => {
Multiplex
],
connEncryption: [
SECIO
SECIO,
NOISE
],
peerDiscovery: [
MulticastDNS
Expand Down
1 change: 1 addition & 0 deletions packages/ipfs/src/http/gateway/resources/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = {
throw Boom.boomify(err, { statusCode: 404 })
case (errorToString.startsWith('Error: multihash length inconsistent')):
case (errorToString.startsWith('Error: Non-base58 character')):
case (errorToString.startsWith('Error: invalid character')):
throw Boom.boomify(err, { statusCode: 400 })
default:
log.error(err)
Expand Down

0 comments on commit fad81d6

Please sign in to comment.