Skip to content

fix(mobile-pairing): accept ws(s):// reverse-proxy URLs as custom network address - #9800

Closed
brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/issue-9760-mobile-custom-network
Closed

brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/issue-9760-mobile-custom-network

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

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't host[: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.

  • Extend the shared manual-address grammar with a 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 existing parseServerShareAddress precedent.
  • Update the dialog placeholder/hint to document the wss:// form and the WebSocket-upgrade requirement, with locale-catalog parity synced.
  • Add proxy/wss settings-search keywords for the Network Interface section.
  • Document the --pairing-address wss://… URL form and a reverse-proxy troubleshooting bullet in docs/reference/headless-linux-server.md (the flag already accepted it — undocumented).

Downstream is already proven path-safe: mobile parsePairingCode preserves wss://…:443/path endpoints (#9776 test) and RpcClient dials the stored endpoint verbatim.

Not covered here (tracked elsewhere): web-client Local PTYs / host ownership is #9047; the unavailableReason crash was fixed in #9776.

Closes #9760

Verification

  • src/shared/network/manual-address.test.ts: 32 tests (12 new URL-branch cases) green
  • settings suite (100 files / 646 tests), i18n + shared/network suites green
  • tc:web + tc:node clean; oxlint/oxfmt clean; verify:localization-catalog parity green

…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
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fe2d0e33-b93c-4334-983b-444775ea1797

📥 Commits

Reviewing files that changed from the base of the PR and between a69610e and 72b4d77.

📒 Files selected for processing (1)
  • docs/reference/headless-linux-server.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/reference/headless-linux-server.md

📝 Walkthrough

Walkthrough

Manual network address parsing now accepts validated ws:// and wss:// URLs while rejecting unsupported schemes, credentials, query or fragment components, invalid hosts, and invalid ports. Tests cover valid and invalid WebSocket URL forms. The mobile pairing UI, search keywords, and localized strings describe reverse-proxied addresses. Headless Linux server documentation explains external wss:// pairing URLs and WebSocket upgrade forwarding.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and verification, but it omits required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Add the missing template sections, including Screenshots/No visual change, a testing checklist, AI review report, security audit, and Notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: accepting ws(s):// reverse-proxy URLs for mobile custom network addresses.
Linked Issues check ✅ Passed The PR implements the linked issue's mobile reverse-proxy/custom address support and documents it, while explicitly leaving the separate web-client bugs out of scope.
Out of Scope Changes check ✅ Passed The changes stay within the mobile reverse-proxy, docs, validation, search, localization, and test updates needed for the feature.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 483a3d48-dcd1-47c2-8571-cde379e70520

📥 Commits

Reviewing files that changed from the base of the PR and between b25c298 and a69610e.

📒 Files selected for processing (10)
  • docs/reference/headless-linux-server.md
  • src/renderer/src/components/mobile/NetworkInterfacePicker.tsx
  • src/renderer/src/components/settings/mobile-pane-search.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/network/manual-address.test.ts
  • src/shared/network/manual-address.ts
👮 Files not reviewed due to content moderation or server errors (1)
  • src/renderer/src/i18n/locales/ko.json

Comment on lines +69 to +88
// 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 }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 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
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Full WebSocket pairing addresses are already supported by #9912, including reverse-proxy URLs. This older patch can be closed.

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.

[Bug]: Mobile custom network address / reverse-proxy remote access still fragile; web client Local PTYs + unavailableReason crash

1 participant