Skip to content

Commit

Permalink
fix(js-ipfs): enable webrtc for js-ipfs
Browse files Browse the repository at this point in the history
this enables webrtc-based signaling and delegates for experimental
js-ipfs running in extension context (non-Brave) when no custom config
is provided
  • Loading branch information
lidel committed Sep 29, 2020
1 parent 8ca21e3 commit 7ae89e6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions add-on/src/lib/ipfs-client/embedded.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ exports.init = async function init (opts) {
const defaultOpts = JSON.parse(optionDefaults.ipfsNodeConfig)
const userOpts = JSON.parse(opts.ipfsNodeConfig)
const ipfsOpts = mergeOptions(defaultOpts, userOpts, { start: true })
const missing = (array) => (!Array.isArray(array) || !array.length)
const { Addresses } = ipfsOpts.config
if (missing(Addresses.Swarm)) {
Addresses.Swarm = [
'/dns4/wrtc-star1.par.dwebops.pub/tcp/443/wss/p2p-webrtc-star',
'/dns4/wrtc-star2.sjc.dwebops.pub/tcp/443/wss/p2p-webrtc-star'
]
}
if (missing(ipfsOpts.Delegates)) {
Addresses.Delegates = [
'/dns4/node0.delegate.ipfs.io/tcp/443/https',
'/dns4/node1.delegate.ipfs.io/tcp/443/https',
'/dns4/node2.delegate.ipfs.io/tcp/443/https',
'/dns4/node3.delegate.ipfs.io/tcp/443/https'
]
}
node = await Ipfs.create(ipfsOpts)
return node
}
Expand Down

0 comments on commit 7ae89e6

Please sign in to comment.