Skip to content

[WIP] feat(webrtc): add experimental WebRTC transport to litep2p backend#12315

Draft
gab8i wants to merge 3 commits into
masterfrom
gab_webrtc
Draft

[WIP] feat(webrtc): add experimental WebRTC transport to litep2p backend#12315
gab8i wants to merge 3 commits into
masterfrom
gab_webrtc

Conversation

@gab8i

@gab8i gab8i commented Jun 9, 2026

Copy link
Copy Markdown

Description

Add webrtc-direct support to the litep2p backend

  • webrtc-direct support gated behind a new --experimental-webrtc CLI flag.
  • WebRTC listen_addr entries are skipped with a warning unless enabled.
  • Persist the DTLS certificate to <net_config_path>/webrtc_certificate so the node keeps a stable identity across restarts. Fall back to an ephemeral cert otherwise.
  • update network type to support WebRTCDirect

Integration

No behavioral change unless --experimental-webrtc is explicitly enabled.

Review Notes

This PR adds experimental webrtc-direct transport support to the litep2p network backend. It is fully opt-in: nothing changes for existing nodes unless the operator explicitly passes --experimental-webrtc and supplies a webrtc-direct listen address. Default backend (litep2p) behavior, the libp2p backend, and all existing transports are untouched.

Checklist

  • My PR follows the labeling requirements of this project (at minimum one label for T required)
    • External contributors: Use /cmd label <label-name> to add labels
    • Maintainers can also add labels manually
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

Add webrtc-direct support to the litep2p backend,
gated behind a new `--experimental-webrtc` CLI flag.

- WebRTC `listen_addr` entries are skipped with a warning unless enabled.
- Persist the DTLS certificate to `<net_config_path>/webrtc_certificate`
  so the node keeps a stable identity across restarts.
  Fall back to an ephemeral cert otherwise.
- update network type to support `WebRTCDirect`
@gab8i gab8i requested review from lexnv and skunert June 9, 2026 14:44
@gab8i gab8i self-assigned this Jun 9, 2026
@socket-security

socket-security Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedcargo/​thiserror@​2.0.12 ⏵ 2.0.188010093100100
Updatedcargo/​sqlx@​0.8.2 ⏵ 0.8.696100100100100

View full report

@gab8i gab8i added feature T0-node This PR/Issue is related to the topic “node”. labels Jun 9, 2026
@gab8i

gab8i commented Jun 9, 2026

Copy link
Copy Markdown
Author

/cmd prdoc --audience node_dev --bump patch

nodelay: true,
..Default::default()
})
.with_webrtc({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we shouldn't call with_webrtc if the provided listen addresses are empty.

One extra thing would be to warn if:

  • experimental webrtc feature is enabled
  • no webrtc addresses are provide

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's easy to adjust. The idea was to keep the same approach for each transport layer, to support this litep2p does a no-op if config contains no listen addresses.

I will add the warnings and update the code to only call with_webrtc if webrtc_address is not empty!

Comment on lines +70 to +71
/// Experimental: `/ip4/0.0.0.0/udp/<port>/webrtc-direct` and
/// `/ip6/[::]/udp/<port>/webrtc-direct`. Only works on litep2p network backend.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Should we specify that 0.0.0.0 isn't allowed and that the proper external IP address should be configured instead? Maybe we should double check for interface 0.0.0.0 in the provided list?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature T0-node This PR/Issue is related to the topic “node”.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants