feat(webrtc): support webrtc-direct v2#3520
Open
lidel wants to merge 1 commit into
Open
Conversation
Chrome is removing the SDP munging that v1 browser-to-server dials rely on (the WebRTC-NoSdpMangleUfrag field trial), so the listener now also speaks the v2 flow, which carries the client's ICE password in the server ufrag instead of munging. Implements libp2p/specs#715. - listener: parse both halves of the STUN USERNAME, dispatch on the ufrag prefix (v1, v2, or reject an unknown version), recover the v2 client password, and set pion's ICE credentials to match. - udpmux: surface the server and client ufrag separately and key the mux on the server (local) ufrag, which is what pion looks up. - validation: reject STUN USERNAME fragments outside the RFC 8839 ice-char set or length bounds before they reach SDP. - dialer: add opt-in WithDialerVersion(2) that emits the v2 wire format for go-to-go and testing; v1 stays the default. - tests: parsing/validation units plus end-to-end v1 and v2 dials against a single listener.
This was referenced Jun 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
/webrtc-directlets a browser dial a public libp2p server with no signalling and no CA-signed cert. That path works by "munging" the local SDP so the server can predict the browser's ICE credentials, and Chrome is taking that ability away (theWebRTC-NoSdpMangleUfragfield trial). Once it reaches stable, browsers can no longer open/webrtc-directconnections to a go-libp2p server, which is the whole reason the transport exists.I documented it in libp2p/specs#672 (comment)
Fix
v2 spec avoids "munging" and is proposed at:
This PR implements it while maintaining backward-compatibility with v1 clients too
Details
USERNAMEwith no signalling;WithDialerVersion("v2")lets a go node dial v2; v1 stays the default for now. can be flipped in future PR, but also does not matter, GO will not do the dials, JS will (feat: webrtc-direct-v2 js-libp2p#3480), so this is just for formal parity and testingTesting
This keeps browser-to-server connectivity alive once Chrome flips the trial; verified end to end against a real Chrome (v2, munging off) and js-libp2p both ways.
Details: #3499 (comment)
References