smoldot icon indicating copy to clipboard operation
smoldot copied to clipboard

wasm-node: Add support for WebRTC

Open tomaka opened this issue 3 years ago • 8 comments
trafficstars

See https://github.com/libp2p/specs/ for how to implement this.

Two things need to be done:

  • [x] Modify the networking code to support transport protocols that natively support substreams.
  • [x] Modify bindings-smoldot-light.js to support WebRTC.

tomaka avatar Nov 30 '21 08:11 tomaka

cc https://github.com/libp2p/specs/issues/220

tomaka avatar Jan 20 '22 18:01 tomaka

As a small note, WebRTC is unfortunately not available from within JS workers (despite WebSockets being available, don't ask me), so we would have to do some messages exchanges between outside and inside the worker to make that work.

tomaka avatar Jan 21 '22 09:01 tomaka

Considering that we might need to add another encryption layer within the DTLS+SCTP stream, it makes sense to me to simply open one SCTP channel for everything and apply Noise+Yamux to it.

As such, I've crossed out the first point.

Modify the networking code to support transport protocols that natively support substreams.

Maybe it turns out that in the end we'll need to do it, but for now it's not necessary.

tomaka avatar Jan 21 '22 15:01 tomaka

WebRTC should solve a problem related to blacklisted IP addresses, which I won't go into details to avoid someone "exploiting" this (though it's not really an exploit, just a way to be annoying).

tomaka avatar Jan 23 '22 20:01 tomaka

What's left from the transport perspective:

  • [x] submit a spec for WebRTC libp2p transport (was done by libp2p maintainers https://github.com/libp2p/specs/pull/412)
  • [ ] finish https://github.com/libp2p/rust-libp2p/pull/2622
  • [x] use the new transport in smoldot

melekes avatar Apr 28 '22 10:04 melekes

After https://github.com/paritytech/smoldot/pull/2352:

  • [x] Add support for a /webrtc (or similar) protocol in Multiaddr.
  • [x] Actually add support for WebRTC in the smoldot JS code (bindings-smoldot-js.ts).
  • [x] Finish the areas where https://github.com/paritytech/smoldot/pull/2352 has left todos, mainly wasm-node/rust/src/platform. This will be more easily done once the JS supports WebRTC, so that we can actually test if things work.

tomaka avatar Jun 07 '22 14:06 tomaka

After https://github.com/paritytech/smoldot/pull/2579, what remains to do is:

  • [x] https://github.com/paritytech/smoldot/pull/2759
  • [ ] Implement the meta-headers in each message.
  • [ ] Stabilize the whole thing by removing the enableExperimentalWebRTC flag.

tomaka avatar Sep 20 '22 10:09 tomaka

Another thing to do is fix compatibility with Firefox. As explained here, Firefox doesn't support getFingerprints and you have to find the fingerprints in the local SDP offer.

tomaka avatar Oct 18 '22 13:10 tomaka

Closing as done.

tomaka avatar Nov 22 '22 10:11 tomaka