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

Commit 104ef1e

Browse files
dryajovdaviddias
authored andcommitted
feat: add circuit relay and aegir 12 (+ big refactor)
1 parent b92bdfe commit 104ef1e

File tree

162 files changed

+754
-345
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+754
-345
lines changed

.aegir.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,48 @@
11
'use strict'
22

3+
const parallel = require('async/parallel')
4+
const ads = require('./test/utils/another-daemon-spawner')
5+
const js = ads.spawnJsNode
6+
const go = ads.spawnGoNode
7+
const stop = ads.stopNodes
8+
9+
/*
10+
* spawns a daemon with ports numbers starting in 10 and ending in `num`
11+
*/
12+
function start (done) {
13+
const base = '/ip4/127.0.0.1/tcp'
14+
15+
if (!process.env.IPFS_TEST) {
16+
parallel([
17+
(cb) => js([`${base}/10007`, `${base}/20007/ws`], true, 31007, 32007, cb),
18+
(cb) => js([`${base}/10008`, `${base}/20008/ws`], true, 31008, 32008, cb),
19+
(cb) => js([`${base}/10012`, `${base}/20012/ws`], true, 31012, 32012, cb),
20+
(cb) => js([`${base}/10013`, `${base}/20013/ws`], true, 31013, 32013, cb),
21+
(cb) => js([`${base}/10014`, `${base}/20014/ws`], true, 31014, 32014, cb),
22+
(cb) => js([`${base}/10015`, `${base}/20015/ws`], true, 31015, 32015, cb)
23+
], done)
24+
} else {
25+
parallel([
26+
(cb) => go([`${base}/10027`, `${base}/20027/ws`], true, 33027, 44027, cb),
27+
(cb) => go([`${base}/10028`, `${base}/20028/ws`], true, 33028, 44028, cb),
28+
(cb) => go([`${base}/10031`, `${base}/20031/ws`], true, 33031, 44031, cb),
29+
(cb) => go([`${base}/10032`, `${base}/20032/ws`], true, 33032, 44032, cb)
30+
], done)
31+
}
32+
}
33+
334
module.exports = {
435
karma: {
536
files: [{
637
pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*',
738
watched: false,
839
served: true,
9-
included: false
40+
included: false,
41+
singleRun: false
1042
}]
43+
},
44+
hooks: {
45+
pre: start,
46+
post: stop
1147
}
1248
}

examples/exchange-files-in-browser/public/js/app.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function start () {
3333
if (!node) {
3434
updateView('starting', node)
3535

36-
node = new self.Ipfs({repo: 'ipfs-' + Math.random()})
36+
node = new self.Ipfs({ repo: 'ipfs-' + Math.random() })
3737

3838
node.on('start', () => {
3939
node.id().then((id) => {
@@ -55,7 +55,7 @@ function stop () {
5555
*/
5656

5757
function createFileBlob (data, multihash) {
58-
const file = new window.Blob(data, {type: 'application/octet-binary'})
58+
const file = new window.Blob(data, { type: 'application/octet-binary' })
5959
const fileUrl = window.URL.createObjectURL(file)
6060

6161
const listItem = document.createElement('div')
@@ -151,7 +151,7 @@ function onDrop (event) {
151151

152152
let myReadableStreamBuffer = new streamBuffers.ReadableStreamBuffer({
153153
// frequency: 10, // in milliseconds.
154-
chunkSize: 32048 // in bytes.
154+
chunkSize: 32048 // in bytes.
155155
})
156156

157157
node.files.createAddStream((err, stream) => {
@@ -200,8 +200,8 @@ function onDrop (event) {
200200
if (files && files.length) {
201201
$multihashInput.value = files[0].hash
202202
$filesStatus.innerHTML = files
203-
.map((e) => `Added ${e.path} as ${e.hash}`)
204-
.join('<br>')
203+
.map((e) => `Added ${e.path} as ${e.hash}`)
204+
.join('<br>')
205205
}
206206
})
207207
.catch(onError)

examples/traverse-ipld-graphs/get-path-accross-formats.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ createNode((err, ipfs) => {
1616

1717
series([
1818
(cb) => {
19-
const someData = new Buffer('capoeira')
19+
const someData = Buffer.from('capoeira')
2020

2121
dagPB.DAGNode.create(someData, (err, node) => {
2222
if (err) {

examples/traverse-ipld-graphs/tree.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ createNode((err, ipfs) => {
1616

1717
series([
1818
(cb) => {
19-
const someData = new Buffer('capoeira')
19+
const someData = Buffer.from('capoeira')
2020

2121
dagPB.DAGNode.create(someData, (err, node) => {
2222
if (err) {

gulpfile.js

Lines changed: 0 additions & 64 deletions
This file was deleted.

package.json

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,29 @@
1919
"npm": ">=3.0.0"
2020
},
2121
"scripts": {
22-
"lint": "aegir-lint",
23-
"coverage": "gulp coverage",
24-
"test": "gulp test --dom",
25-
"test:node": "npm run test:unit:node",
26-
"test:browser": "npm run test:unit:browser",
27-
"test:unit:node": "gulp test:node",
28-
"test:unit:node:core": "TEST=core npm run test:unit:node",
29-
"test:unit:node:http": "TEST=http npm run test:unit:node",
30-
"test:unit:node:gateway": "TEST=gateway npm run test:unit:node",
31-
"test:unit:node:cli": "TEST=cli npm run test:unit:node",
32-
"test:unit:browser": "gulp test:browser",
33-
"test:interop": "npm run test:interop:node",
34-
"test:interop:node": "mocha -t 60000 test/interop/node.js",
35-
"test:interop:browser": "mocha -t 60000 test/interop/browser.js",
22+
"lint": "aegir lint",
23+
"build": "aegir build",
24+
"test": "aegir test -t node -t browser --no-cors",
25+
"test:node": "aegir test -t node",
26+
"test:browser": "aegir test -t browser -t webworker --no-cors",
27+
"release": "aegir release -t node -t browser",
28+
"release-minor": "aegir release --type minor -t node -t browser",
29+
"release-major": "aegir release --type major -t node -t browser",
30+
"test:unit:node": "aegir test -t node",
31+
"test:unit:node:core": "aegir test -t node -f test/core/*.js",
32+
"test:unit:node:http": "aegir test -t node -f test/http-api/index.js",
33+
"test:unit:node:gateway": "aegir test -t node -f test/gateway/index.js",
34+
"test:unit:node:cli": "aegir test -t node -f test/cli/index.js",
35+
"test:unit:browser": "aegir test -t browser --no-cors",
36+
"test:interop": "IPFS_TEST=interop aegir test -t node -t browser -f test/interop",
37+
"test:interop:node": "IPFS_TEST=interop aegir test -t node -f test/interop/node.js",
38+
"test:interop:browser": "IPFS_TEST=interop aegir test -t browser -f test/interop/browser.js",
3639
"test:benchmark": "echo \"Error: no benchmarks yet\" && exit 1",
3740
"test:benchmark:node": "echo \"Error: no benchmarks yet\" && exit 1",
3841
"test:benchmark:node:core": "echo \"Error: no benchmarks yet\" && exit 1",
3942
"test:benchmark:node:http": "echo \"Error: no benchmarks yet\" && exit 1",
4043
"test:benchmark:browser": "echo \"Error: no benchmarks yet\" && exit 1",
41-
"build": "gulp build",
42-
"release": "gulp release",
43-
"release-minor": "gulp release --type minor",
44-
"release-major": "gulp release --type major",
44+
"coverage": "aegir coverage",
4545
"coverage-publish": "aegir-coverage publish"
4646
},
4747
"pre-commit": [
@@ -62,7 +62,7 @@
6262
},
6363
"homepage": "https://github.com/ipfs/js-ipfs#readme",
6464
"devDependencies": {
65-
"aegir": "^11.0.2",
65+
"aegir": "^12.1.3",
6666
"buffer-loader": "0.0.1",
6767
"chai": "^4.1.2",
6868
"delay": "^2.0.0",
@@ -74,7 +74,7 @@
7474
"expose-loader": "^0.7.3",
7575
"form-data": "^2.3.1",
7676
"gulp": "^3.9.1",
77-
"interface-ipfs-core": "~0.32.1",
77+
"interface-ipfs-core": "~0.33.1",
7878
"ipfsd-ctl": "~0.24.0",
7979
"left-pad": "^1.1.3",
8080
"lodash": "^4.17.4",
@@ -90,9 +90,9 @@
9090
"transform-loader": "^0.2.4"
9191
},
9292
"dependencies": {
93-
"async": "^2.5.0",
93+
"async": "^2.6.0",
9494
"bl": "^1.2.1",
95-
"boom": "^6.0.0",
95+
"boom": "^7.1.1",
9696
"byteman": "^1.3.5",
9797
"cids": "^0.5.2",
9898
"debug": "^3.1.0",
@@ -103,20 +103,21 @@
103103
"glob": "^7.1.2",
104104
"hapi": "^16.6.2",
105105
"hapi-set-header": "^1.0.2",
106-
"hoek": "^5.0.0",
107-
"ipfs-api": "^14.3.7",
106+
"hoek": "^5.0.2",
107+
"ipfs-api": "^15.0.1",
108108
"ipfs-bitswap": "~0.17.2",
109-
"ipfs-block": "~0.6.0",
110-
"ipfs-block-service": "~0.12.0",
109+
"ipfs-block": "~0.6.1",
110+
"ipfs-block-service": "~0.13.0",
111111
"ipfs-multipart": "~0.1.0",
112-
"ipfs-repo": "~0.17.0",
113-
"ipfs-unixfs": "~0.1.13",
114-
"ipfs-unixfs-engine": "~0.22.5",
115-
"ipld-resolver": "~0.13.4",
112+
"ipfs-repo": "~0.18.3",
113+
"ipfs-unixfs": "~0.1.14",
114+
"ipfs-unixfs-engine": "~0.23.0",
115+
"ipld-resolver": "~0.14.1",
116116
"is-ipfs": "^0.3.2",
117117
"is-stream": "^1.1.0",
118118
"joi": "^13.0.1",
119-
"libp2p": "~0.12.4",
119+
"libp2p": "~0.13.0",
120+
"libp2p-circuit": "~0.1.4",
120121
"libp2p-floodsub": "~0.11.1",
121122
"libp2p-kad-dht": "~0.5.1",
122123
"libp2p-mdns": "~0.9.1",
@@ -125,12 +126,12 @@
125126
"libp2p-secio": "~0.8.1",
126127
"libp2p-tcp": "~0.11.1",
127128
"libp2p-webrtc-star": "~0.13.2",
128-
"libp2p-websockets": "~0.10.2",
129+
"libp2p-websockets": "~0.10.4",
129130
"lodash.flatmap": "^4.5.0",
130131
"lodash.get": "^4.4.2",
131132
"lodash.sortby": "^4.7.0",
132133
"lodash.values": "^4.3.0",
133-
"mafmt": "^3.0.1",
134+
"mafmt": "^3.0.2",
134135
"mime-types": "^2.1.17",
135136
"mkdirp": "~0.5.1",
136137
"multiaddr": "^3.0.1",
@@ -151,18 +152,18 @@
151152
"pull-stream": "^3.6.1",
152153
"pull-stream-to-stream": "^1.3.4",
153154
"pull-zip": "^2.0.1",
154-
"read-pkg-up": "^2.0.0",
155+
"read-pkg-up": "^3.0.0",
155156
"readable-stream": "2.3.3",
156157
"safe-buffer": "^5.1.1",
157158
"stream-to-pull-stream": "^1.7.2",
158159
"tar-stream": "^1.5.4",
159160
"temp": "~0.8.3",
160161
"through2": "^2.0.3",
161162
"update-notifier": "^2.3.0",
162-
"yargs": "9.0.1"
163+
"yargs": "^10.0.3"
163164
},
164165
"optionalDependencies": {
165-
"prom-client": "^10.2.0",
166+
"prom-client": "^10.2.2",
166167
"prometheus-gc-stats": "^0.5.0"
167168
},
168169
"contributors": [

src/cli/commands/bitswap/stat.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ module.exports = {
1818

1919
stats.Wantlist = stats.Wantlist || []
2020
stats.Wantlist = stats.Wantlist.map((entry) => {
21-
const buf = new Buffer(entry.cid.hash.data)
21+
const buf = Buffer.from(entry.cid.hash.data)
2222
const cid = new CID(entry.cid.version, entry.cid.codec, buf)
2323
return cid.toBaseEncodedString()
2424
})

src/cli/commands/config/edit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = {
8181

8282
function saveConfig (config, next) {
8383
config = utils.isDaemonOn()
84-
? new Buffer(JSON.stringify(config)) : config
84+
? Buffer.from(JSON.stringify(config)) : config
8585

8686
argv.ipfs.config.replace(config, (err) => {
8787
if (err) {

src/cli/commands/pubsub/pub.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module.exports = {
88
builder: {},
99

1010
handler (argv) {
11-
const data = new Buffer(String(argv.data))
11+
const data = Buffer.from(String(argv.data))
1212

1313
argv.ipfs.pubsub.publish(argv.topic, data, (err) => {
1414
if (err) {

src/core/boot.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ module.exports = (self) => {
4141
// fail the whole process.
4242
// TODO: improve datastore and ipfs-repo implemenations so this error is a bit more unified
4343
if (err.message.match(/not found/) || // indexeddb
44-
err.message.match(/ENOENT/) || // fs
45-
err.message.match(/No value/) // memory
46-
) {
44+
err.message.match(/ENOENT/) || // fs
45+
err.message.match(/No value/) // memory
46+
) {
4747
return cb(null, false)
4848
}
4949
return cb(err)

src/core/components/id.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ module.exports = function id (self) {
1414
id: self._peerInfo.id.toB58String(),
1515
publicKey: self._peerInfo.id.pubKey.bytes.toString('base64'),
1616
addresses: self._peerInfo.multiaddrs
17-
.toArray()
18-
.map((ma) => ma.toString())
19-
.filter((ma) => ma.indexOf('ipfs') >= 0)
20-
.sort(),
17+
.toArray()
18+
.map((ma) => ma.toString())
19+
.filter((ma) => ma.indexOf('ipfs') >= 0)
20+
.sort(),
2121
agentVersion: 'js-ipfs',
2222
protocolVersion: '9000'
2323
}))

src/core/components/init-assets.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,14 @@ module.exports = function addDefaultAssets (self, log, callback) {
1515

1616
pull(
1717
pull.values([initDocsPath]),
18-
pull.asyncMap((val, cb) => {
19-
glob(path.join(val, '/**/*'), cb)
20-
}),
18+
pull.asyncMap((val, cb) => glob(path.join(val, '/**/*'), cb)),
2119
pull.flatten(),
2220
pull.map((element) => {
2321
const addPath = element.substring(index + 1)
24-
if (fs.statSync(element).isDirectory()) {
25-
return
26-
}
2722

28-
return {
29-
path: addPath,
30-
content: file(element)
31-
}
23+
if (fs.statSync(element).isDirectory()) { return }
24+
25+
return { path: addPath, content: file(element) }
3226
}),
3327
// Filter out directories, which are undefined from above
3428
pull.filter(Boolean),

0 commit comments

Comments
 (0)