Skip to content

wgengine,feature: add optional webrtc path to magicsock - #21030

Draft
adrianosela wants to merge 1 commit into
mainfrom
adrianosela/21027-magicsock-webrtc-path-reference
Draft

adrianosela wants to merge 1 commit into
mainfrom
adrianosela/21027-magicsock-webrtc-path-reference

Conversation

@adrianosela

@adrianosela adrianosela commented Aug 29, 2026 •

Copy link
Copy Markdown
Contributor

Add an optional WebRTC connectivity path to magicsock, primarily so
browser (js/wasm) nodes, which cannot open raw UDP sockets, can reach
peers directly instead of always relaying through DERP.

The implementation lives in a new feature/webrtc package that plugs into
magicsock through a hook, so magicsock itself keeps no dependency on
pion/WebRTC. The feature is opt-in: it is linked in only when a program
blank-imports feature/webrtc, and its init registers the manager via
magicsock.HookNewWebRTCManager. When it is not linked, the hook stays
unset and the WebRTC path is absent.

Signaling reuses the existing disco/DERP path rather than a standalone
server: offers, answers, and ICE candidates travel as a single new
TypeWebRTCSignal disco message, so no external signaling server is
needed. Once a data channel is up it appears to the rest of magicsock as
a peer path at the WebRTCMagicIP (127.3.3.41) address, ranked above DERP
but below direct UDP. WebRTC is only attempted when at least one side is
a js node, so native-to-native peers are unaffected.

TS_DEBUG_NEVER_DIRECT_WEBRTC disables the path at runtime for debugging,
falling back to DERP.

Updates #21027

@adrianosela
adrianosela force-pushed the adrianosela/21027-magicsock-webrtc-path-reference branch 12 times, most recently from c987afa to e139bab Compare September 3, 2026 14:31
mat2uken pushed a commit to mat2uken/tailcatsend that referenced this pull request Sep 8, 2026
- Apply WebRTC transport patch based on tailscale/tailscale#21030
- Register feature/webrtc in web wasm bridge, daemon, and native bridge
- Add redundant STUN servers and support custom TURN configuration
- Cache and maintain WebRTC data channels across transfer streams in Web bridge
- Add Web-to-Web WebRTC P2P verification test
@adrianosela
adrianosela force-pushed the adrianosela/21027-magicsock-webrtc-path-reference branch 4 times, most recently from 0eca411 to f548903 Compare September 10, 2026 17:50
@adrianosela
adrianosela force-pushed the adrianosela/21027-magicsock-webrtc-path-reference branch from f548903 to e17a804 Compare September 15, 2026 17:20
@adrianosela
adrianosela force-pushed the adrianosela/21027-magicsock-webrtc-path-reference branch 2 times, most recently from 398d719 to 35a6fab Compare September 25, 2026 18:18
Add an optional WebRTC connectivity path to magicsock, primarily so
browser (js/wasm) nodes, which cannot open raw UDP sockets, can reach
peers directly instead of always relaying through DERP.

The implementation lives in a new feature/webrtc package that plugs into
magicsock through a hook, so magicsock itself keeps no dependency on
pion/WebRTC. The feature is opt-in: it is linked in only when a program
blank-imports feature/webrtc, and its init registers the manager via
magicsock.HookNewWebRTCManager. When it is not linked, the hook stays
unset and the WebRTC path is absent.

Signaling reuses the existing disco/DERP path rather than a standalone
server: offers, answers, and ICE candidates travel as a single new
TypeWebRTCSignal disco message, so no external signaling server is
needed. Once a data channel is up it appears to the rest of magicsock as
a peer path at the WebRTCMagicIP (127.3.3.41) address, ranked above DERP
but below direct UDP. WebRTC is only attempted when at least one side is
a js node, so native-to-native peers are unaffected.

TS_DEBUG_NEVER_DIRECT_WEBRTC disables the path at runtime for debugging,
falling back to DERP.

Updates #21027

Signed-off-by: Adriano Sela Aviles <[email protected]>
@adrianosela
adrianosela force-pushed the adrianosela/21027-magicsock-webrtc-path-reference branch from 35a6fab to 98f7c42 Compare October 20, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant