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

Commit 7be50bd

Browse files
authoredJun 22, 2022
fix: use default ws filters instead of connecting to everything (#4142)
Fixes configuration regression, use the default websocket transport filters, e.g. only connect to wss and/or DNS addresses in the browser and anything goes in node. Fixes: #4141
1 parent 0078aad commit 7be50bd

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed
 

‎packages/ipfs-core-config/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
"datastore-level": "^8.0.0",
9393
"err-code": "^3.0.1",
9494
"hashlru": "^2.3.0",
95-
"interface-datastore": "^6.0.2",
95+
"interface-datastore": "^6.1.1",
9696
"ipfs-repo": "^14.0.1",
9797
"ipfs-utils": "^9.0.6",
9898
"is-ipfs": "^6.0.1",

‎packages/ipfs-core-types/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"license": "(Apache-2.0 OR MIT)",
4848
"dependencies": {
4949
"@ipld/dag-pb": "^2.1.3",
50-
"interface-datastore": "^6.0.2",
50+
"interface-datastore": "^6.1.1",
5151
"ipfs-unixfs": "^6.0.9",
5252
"@multiformats/multiaddr": "^10.0.0",
5353
"multiformats": "^9.5.1"

‎packages/ipfs-core/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@
9797
"err-code": "^3.0.1",
9898
"hamt-sharding": "^2.0.1",
9999
"hashlru": "^2.3.0",
100-
"interface-blockstore": "^2.0.2",
101-
"interface-datastore": "^6.0.2",
100+
"interface-blockstore": "^2.0.3",
101+
"interface-datastore": "^6.1.1",
102102
"ipfs-bitswap": "^11.0.0",
103103
"ipfs-core-config": "^0.4.0",
104104
"ipfs-core-types": "^0.11.0",
@@ -143,7 +143,7 @@
143143
"blockstore-datastore-adapter": "^2.0.2",
144144
"delay": "^5.0.0",
145145
"go-ipfs": "^0.12.1",
146-
"interface-blockstore-tests": "^2.0.2",
146+
"interface-blockstore-tests": "^2.0.4",
147147
"interface-ipfs-core": "^0.155.0",
148148
"ipfsd-ctl": "^11.0.0",
149149
"iso-url": "^1.0.0",

‎packages/ipfs-core/src/components/libp2p.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { Bootstrap } from '@libp2p/bootstrap'
1414
import { ipnsValidator } from 'ipns/validator'
1515
import { ipnsSelector } from 'ipns/selector'
1616
import { WebSockets } from '@libp2p/websockets'
17-
import * as WebSocketsFilters from '@libp2p/websockets/filters'
1817
import { Mplex } from '@libp2p/mplex'
1918
import { NOISE } from '@chainsafe/libp2p-noise'
2019

@@ -123,11 +122,7 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId,
123122
contentRouters: [],
124123
peerRouters: [],
125124
peerDiscovery: [],
126-
transports: [
127-
new WebSockets({
128-
filter: WebSocketsFilters.all
129-
})
130-
],
125+
transports: [],
131126
streamMuxers: [
132127
new Mplex({
133128
// temporary fix until we can limit streams on a per-protocol basis
@@ -221,5 +216,14 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId,
221216
})
222217
}
223218

219+
if (libp2pFinalConfig.transports == null) {
220+
libp2pFinalConfig.transports = []
221+
}
222+
223+
// add WebSocket transport if not overridden by user config
224+
if (libp2pFinalConfig.transports.find(t => t[Symbol.toStringTag] === '@libp2p/websockets') == null) {
225+
libp2pFinalConfig.transports.push(new WebSockets())
226+
}
227+
224228
return libp2pFinalConfig
225229
}

‎packages/ipfs/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
},
7676
"devDependencies": {
7777
"@libp2p/webrtc-star-signalling-server": "^1.0.3",
78+
"@libp2p/websockets": "^1.0.8",
7879
"@types/semver": "^7.3.4",
7980
"@types/update-notifier": "^5.0.0",
8081
"aegir": "^37.0.11",

‎packages/ipfs/test/utils/factory.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import * as ipfsModule from 'ipfs-core'
77
import goIpfs from 'go-ipfs'
88
import path, { dirname } from 'path'
99
import { fileURLToPath } from 'url'
10+
import { WebSockets } from '@libp2p/websockets'
11+
import { all as WebSocketsFiltersAll } from '@libp2p/websockets/filters'
1012

1113
const merge = mergeOpts.bind({ ignoreUndefined: true })
1214
let __dirname = ''
@@ -25,7 +27,12 @@ const commonOptions = {
2527
libp2p: {
2628
dialer: {
2729
dialTimeout: 60e3 // increase timeout because travis is slow
28-
}
30+
},
31+
transports: [
32+
new WebSockets({
33+
filter: WebSocketsFiltersAll
34+
})
35+
]
2936
}
3037
},
3138
endpoint: process.env.IPFSD_SERVER

0 commit comments

Comments
 (0)
This repository has been archived.