Get TURN from the server instead of URL params - #12
Merged
Conversation
TURN credentials used to reach the phone as query params, put there by an untracked dev helper the launcher's QR pointed at. The QR now goes straight to this app and carries no credentials — and it couldn't, since this repo is public — so rtcConfig() takes its ICE servers from the server's /api/ice. The fetch runs once at load into a module-level cache. connect() awaits it before building the RTCPeerConnection, whose ICE servers are fixed at construction; by the time anyone taps Join it has long since settled. Callers don't use the return value, so connect() stays synchronous for them. A Leave or a second Join while the fetch is still in flight bumps a generation counter in _closeConnections(), so a superseded attempt can't open a peer behind it. Query params still override for a one-off device, and a missing /api/ice falls back to STUN, which still covers same-network play.
Contributor
|
🚀 Preview for |
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.
TURN credentials used to reach the phone as query params, put there by an untracked dev helper the launcher's QR pointed at. The QR now goes straight to this app (space-console/game-launcher-web#15) and carries no credentials — and it couldn't, since this repo is public. So
rtcConfig()takes its ICE servers from the server's/api/ice(space-console/web-api#6).The fetch runs once at load into a module-level cache.
connect()awaits it before building theRTCPeerConnection, whose ICE servers are fixed at construction; by the time anyone taps Join it has long since settled. Callers don't use the return value, soconnect()stays synchronous for them.A Leave or a second Join while the fetch is still in flight bumps a generation counter in
_closeConnections(), so a superseded attempt can't open a peer behind it.Query params still override for a one-off device, and a missing
/api/icefalls back to STUN, which still covers same-network play.Verified
npm run lintclean./api/icefetch present in the served bundle.Merge before space-console/web-api#6 — its build pulls this repo's
gh-pages, which only republishes after this lands onmain.