smoldot
smoldot copied to clipboard
wasm-node: Add support for WebRTC
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.jsto support WebRTC.
cc https://github.com/libp2p/specs/issues/220
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.
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.
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).
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
After https://github.com/paritytech/smoldot/pull/2352:
- [x] Add support for a
/webrtc(or similar) protocol inMultiaddr. - [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.
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
enableExperimentalWebRTCflag.
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.
Closing as done.