Context
A user with a webnative filesystem that contains public and private, encrypted, data. We will refer to this filesystem as just data, because that’s all it is to IPFS.
Setup
- All the data lives in a S3 bucket, this data is never deleted.
- The data is available through our IPFS cluster.
- A js-ipfs instance in a shared web worker, accessed by apps on different domains through an iframe.
- The js-ipfs instance contains a partial set of the data. Here we pin the data the user is actually using. This data is stored in indexedDB.
- The user has multiple devices, and thus multiple js-ipfs instances.
Problem
To increase the performance of the system locally, connectivity between devices, and reduce the load on our IPFS cluster, we want to pin the js-ipfs instance data to the user’s local IPFS nodes. I want to emphasise that these local nodes are totally optional, the system works without them. That said, the additional local nodes would greatly benefit the user, because if they’d switch devices, they would get the data much faster (that is, if the second device finds the other one in sufficient time).
Technically speaking, the problem is, how do I directly connect the js-ipfs node with the local node(s). There is no easy way to connect to my local IPFS Desktop node, or Brave’s in-browser node, from js-ipfs.
Solutions
The most straightforward solution I could think of was to:
- Enable the WS transport on the local nodes. For the solution to really work, this should be enabled by default. Related issue: Leveraging ws://localhost provided by local IPFS node · Issue #177 · ipfs/in-web-browsers · GitHub
- Use a custom libp2p instance with js-ipfs so we can dial to
ws
addresses in addition towss
. - Attempt connections to various default local addresses. Try connecting with localhost on IPFS Desktop’s default port. Same with Brave, etc.
I imagine there’s various issues with this:
- Gozala has mentioned that there are security issues regarding the unsecured
ws
transports. - Instead of attempting connections with various addresses, we should be sure there is actually something to connect to before we make the attempt. What if users changed the default ports?