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

fix: use default ws filters instead of connecting to everything #4142

Merged
merged 10 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ipfs-core-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"datastore-level": "^8.0.0",
"err-code": "^3.0.1",
"hashlru": "^2.3.0",
"interface-datastore": "^6.0.2",
"interface-datastore": "^6.1.1",
"ipfs-repo": "^14.0.1",
"ipfs-utils": "^9.0.6",
"is-ipfs": "^6.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/ipfs-core-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"license": "(Apache-2.0 OR MIT)",
"dependencies": {
"@ipld/dag-pb": "^2.1.3",
"interface-datastore": "^6.0.2",
"interface-datastore": "^6.1.1",
"ipfs-unixfs": "^6.0.9",
"@multiformats/multiaddr": "^10.0.0",
"multiformats": "^9.5.1"
Expand Down
6 changes: 3 additions & 3 deletions packages/ipfs-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
"err-code": "^3.0.1",
"hamt-sharding": "^2.0.1",
"hashlru": "^2.3.0",
"interface-blockstore": "^2.0.2",
"interface-datastore": "^6.0.2",
"interface-blockstore": "^2.0.3",
"interface-datastore": "^6.1.1",
"ipfs-bitswap": "^11.0.0",
"ipfs-core-config": "^0.4.0",
"ipfs-core-types": "^0.11.0",
Expand Down Expand Up @@ -143,7 +143,7 @@
"blockstore-datastore-adapter": "^2.0.2",
"delay": "^5.0.0",
"go-ipfs": "^0.12.1",
"interface-blockstore-tests": "^2.0.2",
"interface-blockstore-tests": "^2.0.4",
"interface-ipfs-core": "^0.155.0",
"ipfsd-ctl": "^11.0.0",
"iso-url": "^1.0.0",
Expand Down
16 changes: 10 additions & 6 deletions packages/ipfs-core/src/components/libp2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { Bootstrap } from '@libp2p/bootstrap'
import { ipnsValidator } from 'ipns/validator'
import { ipnsSelector } from 'ipns/selector'
import { WebSockets } from '@libp2p/websockets'
import * as WebSocketsFilters from '@libp2p/websockets/filters'
import { Mplex } from '@libp2p/mplex'
import { NOISE } from '@chainsafe/libp2p-noise'

Expand Down Expand Up @@ -123,11 +122,7 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId,
contentRouters: [],
peerRouters: [],
peerDiscovery: [],
transports: [
new WebSockets({
filter: WebSocketsFilters.all
})
],
transports: [],
streamMuxers: [
new Mplex({
// temporary fix until we can limit streams on a per-protocol basis
Expand Down Expand Up @@ -221,5 +216,14 @@ function getLibp2pOptions ({ options, config, datastore, keychainConfig, peerId,
})
}

if (libp2pFinalConfig.transports == null) {
libp2pFinalConfig.transports = []
}

// add WebSocket transport if not overridden by user config
if (libp2pFinalConfig.transports.find(t => t[Symbol.toStringTag] === '@libp2p/websockets') == null) {
libp2pFinalConfig.transports.push(new WebSockets())
}

return libp2pFinalConfig
}
1 change: 1 addition & 0 deletions packages/ipfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
},
"devDependencies": {
"@libp2p/webrtc-star-signalling-server": "^1.0.3",
"@libp2p/websockets": "^1.0.8",
"@types/semver": "^7.3.4",
"@types/update-notifier": "^5.0.0",
"aegir": "^37.0.11",
Expand Down
9 changes: 8 additions & 1 deletion packages/ipfs/test/utils/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import * as ipfsModule from 'ipfs-core'
import goIpfs from 'go-ipfs'
import path, { dirname } from 'path'
import { fileURLToPath } from 'url'
import { WebSockets } from '@libp2p/websockets'
import { all as WebSocketsFiltersAll } from '@libp2p/websockets/filters'

const merge = mergeOpts.bind({ ignoreUndefined: true })
let __dirname = ''
Expand All @@ -25,7 +27,12 @@ const commonOptions = {
libp2p: {
dialer: {
dialTimeout: 60e3 // increase timeout because travis is slow
}
},
transports: [
new WebSockets({
filter: WebSocketsFiltersAll
})
]
}
},
endpoint: process.env.IPFSD_SERVER
Expand Down