Files
tailscale/cmd
Adriano Sela Aviles 9d7a6f474e wgengine,feature: add optional webrtc path to magicsock
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]>
2026-09-03 06:40:03 -04:00
..
2026-07-10 14:26:11 -07:00
2026-07-10 14:26:11 -07:00
2026-07-10 14:26:11 -07:00