Repository navigation
fix(mobile-pairing): accept ws(s):// reverse-proxy URLs as custom network address - #9800
brennanb2025 wants to merge 2 commits into
Conversation
…work address The main process has passed a full ws(s):// pairing-address override through verbatim (scheme, port, and path) since #9776, but the Custom network address dialog still rejected anything that was not host[:port], so a reverse-proxied endpoint like wss://home.example.com/orca could not be entered. Extend the manual-address grammar with a ws(s):// URL branch (path allowed; credentials, query, and fragment rejected), update the dialog copy, add proxy/wss settings-search keywords, and document the --pairing-address URL form for headless servers. Closes #9760
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughManual network address parsing now accepts validated 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 483a3d48-dcd1-47c2-8571-cde379e70520
📒 Files selected for processing (10)
docs/reference/headless-linux-server.mdsrc/renderer/src/components/mobile/NetworkInterfacePicker.tsxsrc/renderer/src/components/settings/mobile-pane-search.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/network/manual-address.test.tssrc/shared/network/manual-address.ts
👮 Files not reviewed due to content moderation or server errors (1)
- src/renderer/src/i18n/locales/ko.json
| // Why: WHATWG URL already validates host and caps the port, so this only adds | ||
| // what pairing forbids: credentials, query, and fragment stay out of the QR | ||
| // endpoint (path is meaningful for reverse proxies, the rest are typos), and | ||
| // `:0` — which URL permits but WebSocket cannot dial — is rejected. | ||
| function parseWebSocketUrlAddress(input: string): ParseManualAddressResult { | ||
| let url: URL | ||
| try { | ||
| url = new URL(input) | ||
| } catch { | ||
| return { ok: false, error: ERROR_MESSAGE } | ||
| } | ||
| if (!url.hostname || url.username || url.password || url.search || url.hash) { | ||
| return { ok: false, error: ERROR_MESSAGE } | ||
| } | ||
| if (url.port !== '' && !isValidPort(url.port)) { | ||
| return { ok: false, error: ERROR_MESSAGE } | ||
| } | ||
| return { ok: true, address: input } | ||
| } | ||
|
|
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Unbounded address length for zero-padded WS(S) ports.
new URL() normalizes url.port (stripping leading zeros) before isValidPort ever sees it, so a port like :${'0'.repeat(1000)}8080 parses to canonical 8080 and passes validation — but return { ok: true, address: input } returns the original, unbounded-length string. The sibling raw host:port path explicitly guards against exactly this (see the isValidPort "Why" comment at Line 103-105: "Reject leading zeros: a canonical port has none, and allowing them lets an arbitrarily long zero-padded string (00…08080) slip past the range check and inflate the returned address past the hostname length cap."), and there's no equivalent length cap for the ws(s):// branch.
This lets a mistyped/pasted address (or the QR-code-embedding downstream consumer) end up with an effectively unbounded string, since parseWebSocketUrlAddress has no overall length check at all.
🛡️ Proposed fix: cap the overall input length
function parseWebSocketUrlAddress(input: string): ParseManualAddressResult {
let url: URL
try {
url = new URL(input)
} catch {
return { ok: false, error: ERROR_MESSAGE }
}
if (!url.hostname || url.username || url.password || url.search || url.hash) {
return { ok: false, error: ERROR_MESSAGE }
}
if (url.port !== '' && !isValidPort(url.port)) {
return { ok: false, error: ERROR_MESSAGE }
}
+ // Why: `new URL()` normalizes away leading zeros in the port before we
+ // validate it above, so a zero-padded port (e.g. `:${'0'.repeat(1000)}8080`)
+ // still validates while `input` — returned verbatim below — stays huge.
+ if (input.length > MAX_WS_ADDRESS_LENGTH) {
+ return { ok: false, error: ERROR_MESSAGE }
+ }
return { ok: true, address: input }
}…60-mobile-custom-network # Conflicts: # docs/reference/headless-linux-server.md
|
Full WebSocket pairing addresses are already supported by #9912, including reverse-proxy URLs. This older patch can be closed. |
Summary
Remaining piece of #9760 after #9776. The main process passes a full
ws(s)://pairing-address override through verbatim — scheme, port, and path (resolvePairingEndpoint) — but the Custom network address dialog's validator (parseManualNetworkAddress) still rejected anything that wasn'thost[:port]. So the exact input from the issue report,wss://www.<domain>:443, could not be entered, and a reverse-proxied endpoint with a path (wss://home.example.com/orca/runtime) had no way in at all.ws(s)://URL branch: path allowed (that's what reverse proxies need); credentials, query, and fragment rejected as typo-safety; explicit port validated. Mirrors the existingparseServerShareAddressprecedent.wss://form and the WebSocket-upgrade requirement, with locale-catalog parity synced.proxy/wsssettings-search keywords for the Network Interface section.--pairing-address wss://…URL form and a reverse-proxy troubleshooting bullet indocs/reference/headless-linux-server.md(the flag already accepted it — undocumented).Downstream is already proven path-safe: mobile
parsePairingCodepreserveswss://…:443/pathendpoints (#9776 test) andRpcClientdials the stored endpoint verbatim.Not covered here (tracked elsewhere): web-client Local PTYs / host ownership is #9047; the
unavailableReasoncrash was fixed in #9776.Closes #9760
Verification
src/shared/network/manual-address.test.ts: 32 tests (12 new URL-branch cases) greentc:web+tc:nodeclean; oxlint/oxfmt clean;verify:localization-catalogparity green