earthstar-project / earthstar

Storage for private, distributed, offline-first applications.
https://earthstar-project.org
GNU Lesser General Public License v3.0
624 stars 18 forks source link

Direct p2p online sync with WebRTC #296

Open sgwilym opened 1 year ago

sgwilym commented 1 year ago

What's the problem you want solved?

Earthstar uses servers for syncing over the internet. The servers act as always-online peers which keep a replica of all data themselves. This can be very useful for cases where peers aren't online at the same time, or when the server uses their replica to provide other services.

However, this ties servers to specific shares, and makes it necessary for them to be able to host (possibly large amounts of) data. It also means that users have to host their own servers, which can be difficult.

Is there a solution you'd like to recommend?

I think we should make it possible for servers to act as signalling servers to help peers connect directly to one another. Such servers would not have to host any data, and would be able to serve any Earthstar peers regardless of which shares they're interested in.

This would be conceptually similar to SSB room servers.

This would require at least two components OTOH:

I've never done anything with WebRTC or TURN/STUN servers so there's a lot to be figured out, but I think the broad strokes are right.

sgwilym commented 1 year ago

This would even be complementary with the existing model of servers as 'always online peers': those servers would also be able to connect to signalling servers and sync over WebRTC.

Then it would be possible to have the best of both worlds:


And a kind of wishlist for the signalling server:

Not sure how that'd be achieved just yet.