Skip to content

Accept any hostname (and optional :port) in manual network address entry - #7223

Merged
nwparker merged 5 commits into
stablyai:mainfrom
Daily-AC:manual-address-any-hostname
Jul 3, 2026
Merged

nwparker merged 5 commits into
stablyai:mainfrom
Daily-AC:manual-address-any-hostname

Conversation

@Daily-AC

@Daily-AC Daily-AC commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #7222. parseManualNetworkAddress (used by the custom-address dialog in Settings → Mobile → Network Interface and by the same picker on the mobile pairing screen) only accepted an IPv4 address or a *.ts.net Tailscale MagicDNS hostname. This broadens it to accept any RFC 1123 hostname — which still covers *.ts.net — with an optional :port suffix.

This closes a UI-only gap: the main-process pairing-endpoint resolution (resolvePairingEndpoint / parsePairingAddressOverride in src/main/runtime/runtime-rpc.ts) already accepts any host or host:port; the renderer regex was the only thing blocking users who reach their desktop through a DDNS domain, a plain LAN hostname, or a self-hosted relay on a non-standard port. Previously the only workaround was calling the pairing IPC by hand from DevTools.

What changed

  • src/shared/network/manual-address.ts — replaced the MagicDNS-only regex with a general RFC 1123 hostname grammar plus a host:port split (port validated 1–65535). IPv4 validation is unchanged.
  • src/shared/network/manual-address.test.ts — updated the IPv4/MagicDNS error copy, dropped the now-invalid "rejects non-Tailscale hostnames" case, and added coverage for plain/DDNS hostnames, host:port, port boundaries, multi-colon rejection, the ambiguous-IPv4 guard, and leading-zero ports.
  • src/renderer/src/components/mobile/NetworkInterfacePicker.tsx and the five locale catalogs — updated the custom-address dialog's placeholder/hint to describe the wider grammar.

Design principle: renderer stays a strict subset of the backend

The renderer validator must never accept an address the main process would silently dial as a different host. The main process feeds the address into the WHATWG URL host parser, which reinterprets a host whose last label is numeric (123, foo.123, foo.0x1) as IPv4 (123 → 0.0.0.123) or fails and falls back to a different host. So the validator explicitly rejects any host with a numeric/hex final label as a mistyped IP, and rejects IPv6 / multi-colon / scheme / credential / path / whitespace input — all of which stay well inside what the backend can resolve.

Evidence

  • Reproduced first on origin/main: a unit test asserting home.example.com, mydomain.example:8443, and my-nas are accepted fails on main (all three rejected), and passes on this branch.
  • Unit tests: pnpm vitest run src/shared/network/manual-address.test.ts → 25 passed.
  • Typecheck: pnpm run typecheck → clean. Lint: oxlint + pnpm run verify:localization-catalog → clean (all 5 locales in parity).
  • UI verified in a dev build (Settings → Mobile pairing → Add custom address…): the dialog renders the new copy; typing home.example.com enables Use address (was rejected before); typing foo.123 correctly keeps it disabled. Screenshots attached in the PR conversation.

ELI5

There's a box where you type your computer's address so your phone can connect to it. It used to only allow two kinds of addresses: a numeric IP, or a special Tailscale name ending in .ts.net. If your home address was a normal web-style name like home.example.com, the box refused it — even though the app behind the box already knew how to use it. This change teaches the box to accept normal hostnames (and an optional :port), while still turning away typo'd IPs and things the app can't actually dial.

Trade-offs

  • User-visible behavior change: the custom-address field now accepts any RFC 1123 hostname and host:port, not just IPv4 / *.ts.net. Bad input still fails at the form (with the reworded error) rather than at connect time.
  • Deliberately stricter than the backend in the safe direction: trailing-dot FQDNs (example.com.), raw-Unicode/IDN hostnames (use punycode xn--…), all-numeric or numeric-final-label hosts, and IPv6 are rejected at the form even though the backend URL layer might coerce some of them. This keeps the UI from "validating" an address the main process would dial as something else. IPv6 remains out of scope, matching parsePairingAddressOverride.
  • No changes to the mobile:getPairingQR IPC surface, no new dependencies, no platform-specific behavior — pure shared-function + copy change.

This PR was taken over and finished by a maintainer: merged latest main, fixed three review findings (the ambiguous-IPv4 guard also missing numeric-tail hostnames, an unbounded/leading-zero port, and the en.json + 4 locale catalogs that left the copy change inert), added the reproduction and UI evidence, and verified tests/typecheck/lint.

parseManualNetworkAddress only accepted an IPv4 address or a Tailscale
MagicDNS (*.ts.net) hostname, so users behind a dynamic residential IP
who rely on a DDNS domain or self-hosted relay had no way to enter it
in the desktop UI short of bypassing validation via DevTools/IPC.

The main process already resolves any host: resolvePairingEndpoint
and parsePairingAddressOverride in src/main/runtime/runtime-rpc.ts
accept an arbitrary hostname and an optional host:port. This change
brings the renderer-side validation in line with what pairing already
supports: any RFC 1123 hostname (a superset that still covers
*.ts.net), optionally suffixed with :port (1-65535). IPv4 validation
is unchanged, including still rejecting malformed dotted-numeric input
instead of silently treating it as an all-digit hostname.

Updates the custom-address dialog copy in NetworkInterfacePicker.tsx
to describe the wider grammar.
@coderabbitai

coderabbitai Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR generalizes manual network address handling from MagicDNS-only hostnames to IPv4 addresses or RFC 1123-compatible hostnames with an optional :port suffix. The parser now trims and validates input, splits host and port with a single-colon rule, and enforces host length and port bounds. Tests expand coverage for accepted hostname forms, port edge cases, and whitespace rejection. Mobile dialog copy and localized strings were updated to describe the broader address formats.

Changes

  • Parser logic now accepts IPv4 or hostnames plus optional port.
  • Tests now cover the new hostname and port rules.
  • Mobile documentation and dialog strings now describe IPs, hostnames, DDNS, and :port.

Sequence Diagram(s)

Not applicable.

Related Issues: None specified.

Related PRs: None specified.

Suggested labels: area: shared, area: mobile, type: enhancement

Suggested reviewers: None specified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change well but does not follow the required template sections, especially Screenshots, AI Review Report, Security Audit, and Notes. Reformat the PR description to use the repository template and add the missing required sections, including screenshots status, review report, security audit, and notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code changes match #7222 by accepting RFC 1123 hostnames plus optional ports, while preserving IPv4 checks and rejecting ambiguous numeric forms.
Out of Scope Changes check ✅ Passed The PR stays scoped to manual address parsing, tests, and dialog copy/locales, with no unrelated code changes apparent.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly matches the main change: manual network address entry now accepts any hostname with an optional :port.

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: 2

🧹 Nitpick comments (1)
src/shared/network/manual-address.test.ts (1)

113-119: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add coverage for a bare single-label numeric hostname.

This suite tests dotted all-numeric rejection but has no case for a bare numeric label (e.g. "123"), which per the production comment should be accepted as a legal RFC 1123 label. Adding this test would have caught the regex gap noted in manual-address.ts (Lines 43-49).

✅ Suggested additional test
     it('does not treat a malformed IPv4-shaped input as a valid all-digit hostname', () => {
       // Bare-digit labels are legal RFC 1123 hostname labels, but a dotted
       // all-numeric string is almost certainly a mistyped IP, not a hostname.
       for (const bad of ['1.2.3', '1.2.3.4.5', '256.0.0.1', '999.999.999.999']) {
         expect(parseManualNetworkAddress(bad).ok).toBe(false)
       }
     })
+
+    it('accepts a bare single-label numeric hostname', () => {
+      expect(parseManualNetworkAddress('123').ok).toBe(true)
+    })

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2febe2c2-bbae-4183-86bf-fd96cd21a3b4

📥 Commits

Reviewing files that changed from the base of the PR and between a84f737 and 899ba89.

📒 Files selected for processing (3)
  • src/renderer/src/components/mobile/NetworkInterfacePicker.tsx
  • src/shared/network/manual-address.test.ts
  • src/shared/network/manual-address.ts

Comment on lines 83 to +89
placeholder: translate(
'auto.components.mobile.CustomNetworkAddressDialog.placeholder',
'my-mac.ts.net or 192.168.1.50'
'my-mac.ts.net, home.example.com, or 192.168.1.50'
),
hint: translate(
'auto.components.mobile.CustomNetworkAddressDialog.hint',
'Enter an IP address or a Tailscale hostname (ends in .ts.net).'
'Enter an IP address or a hostname — a Tailscale MagicDNS name, a DDNS domain, or a LAN hostname — optionally with :port.'

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== file outline ==\n'
ast-grep outline src/renderer/src/components/mobile/NetworkInterfacePicker.tsx --view expanded || true

printf '\n== target snippets ==\n'
sed -n '1,180p' src/renderer/src/components/mobile/NetworkInterfacePicker.tsx | cat -n

printf '\n== locale key search ==\n'
rg -n "auto\.components\.mobile\.CustomNetworkAddressDialog\.(placeholder|hint)" src/renderer/src/i18n -S || true

printf '\n== i18n pipeline refs ==\n'
rg -n "locales/en\.json|translate\(|CustomNetworkAddressDialog" src/renderer/src -S || true

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== target component snippet =='
sed -n '70,100p' src/renderer/src/components/mobile/NetworkInterfacePicker.tsx | cat -n

echo
echo '== locale entries in en.json =='
python3 - <<'PY'
import json, pathlib
p = pathlib.Path('src/renderer/src/i18n/locales/en.json')
data = json.loads(p.read_text())
keys = [
    'auto.components.mobile.CustomNetworkAddressDialog.placeholder',
    'auto.components.mobile.CustomNetworkAddressDialog.hint',
]
for k in keys:
    cur = data
    for part in k.split('.'):
        if part not in cur:
            print(k, '=> MISSING')
            break
        cur = cur[part]
    else:
        print(k, '=>', cur)
PY

echo
echo '== translate implementation =='
rg -n "function translate|const translate|export .*translate" src/renderer/src/i18n src/renderer/src -S | head -n 20

echo
echo '== i18n pipeline refs =='
rg -n "en\.json|generate.*locale|locale.*generate|translations" src/renderer/src/i18n src/renderer/src -S | head -n 80

Repository: stablyai/orca

Length of output: 3962


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== i18n.ts snippet =='
sed -n '1,180p' src/renderer/src/i18n/i18n.ts | cat -n

echo
echo '== locale-related tooling =='
rg -n "en\.json|locales/|translate\(key, fallback|fallback" src/renderer/src/i18n package.json . -S | head -n 120

Repository: stablyai/orca

Length of output: 18878


Update the English locale entries for these strings too. translate() reads the bundled src/renderer/src/i18n/locales/en.json first, so this TSX fallback change won’t reach normal English builds until the locale source is regenerated or edited alongside it.

Comment thread src/shared/network/manual-address.ts Outdated
Comment on lines +43 to +49
// Why: an all-digit dotted string (e.g. `256.0.0.1`, `1.2.3.4.5`) is a
// mistyped IPv4 address, not a hostname, even though bare numeric labels
// are technically legal per RFC 1123. Falling through to HOSTNAME_REGEX
// for these would silently "accept" IP typos as unresolvable hostnames.
if (/^[0-9]+(?:\.[0-9]+)*$/.test(host)) {
return { ok: false, error: ERROR_MESSAGE }
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

All-digit hostname check also rejects legitimate single-label numeric hostnames.

The comment says bare numeric labels are legal RFC 1123 and only dotted all-numeric strings should be rejected as IP typos, but the regex /^[0-9]+(?:\.[0-9]+)*$/ also matches a bare single-label numeric string (no dot at all), since the dotted group is * (zero-or-more). A hostname like "123" would be incorrectly rejected here even though it's a valid RFC 1123 label and the code's own reasoning says it should be allowed to fall through to HOSTNAME_REGEX.

🐛 Proposed fix: require at least one dot before rejecting as IPv4-typo
-  if (/^[0-9]+(?:\.[0-9]+)*$/.test(host)) {
+  if (/^[0-9]+(?:\.[0-9]+)+$/.test(host)) {
     return { ok: false, error: ERROR_MESSAGE }
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Why: an all-digit dotted string (e.g. `256.0.0.1`, `1.2.3.4.5`) is a
// mistyped IPv4 address, not a hostname, even though bare numeric labels
// are technically legal per RFC 1123. Falling through to HOSTNAME_REGEX
// for these would silently "accept" IP typos as unresolvable hostnames.
if (/^[0-9]+(?:\.[0-9]+)*$/.test(host)) {
return { ok: false, error: ERROR_MESSAGE }
}
// Why: an all-digit dotted string (e.g. `256.0.0.1`, `1.2.3.4.5`) is a
// mistyped IPv4 address, not a hostname, even though bare numeric labels
// are technically legal per RFC 1123. Falling through to HOSTNAME_REGEX
// for these would silently "accept" IP typos as unresolvable hostnames.
if (/^[0-9]+(?:\.[0-9]+)+$/.test(host)) {
return { ok: false, error: ERROR_MESSAGE }
}

nwparker and others added 4 commits July 3, 2026 12:30
…s, lint

- Require a dot in the IPv4-typo guard so a bare numeric label (`123`)
  validates as a legal RFC 1123 hostname, matching the code's own comment
  and the main-process resolver; add coverage.
- Update en.json + es/ja/ko/zh placeholder/hint to the broadened grammar
  (translate() reads en.json before the TSX fallback, so the copy change
  was previously inert; the other locales described the old ts.net-only rule).
- Replace indexOf(...)!==-1 with includes() to satisfy oxlint.

Co-authored-by: Orca <[email protected]>
Review surfaced two ways the renderer could accept an address the main
process handles differently:
- All-numeric hosts (bare `123` and dotted `256.0.0.1`) are now rejected.
  The WHATWG URL host parser downstream reinterprets a numeric host as IPv4
  (`123` -> `0.0.0.123`), so accepting one would validate an address the
  pairing resolver silently dials as a different host.
- Ports with leading zeros are rejected. `^[0-9]+$` let an arbitrarily long
  zero-padded string past the range check and inflate the returned address
  beyond the hostname length cap that the old whole-string check enforced.

Co-authored-by: Orca <[email protected]>
WHATWG URL host parsing treats a host whose last label is numeric
(`foo.123`, `foo.0x1`) as an IPv4 signal, so the pairing resolver would
fail to parse it and silently dial a fallback host. Widen the ambiguous-IP
guard to a single last-label check that subsumes the earlier all-numeric
case, keeping the renderer a strict subset of what the backend resolves
correctly. Normal hostnames whose last label merely contains digits
(`host2.example.com`) are unaffected.

Co-authored-by: Orca <[email protected]>
@nwparker

nwparker commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

🛠️ Taken over and finished by a maintainer. Pushed 4 commits on top of the original (latest main merged in).

Security screen — clean. The diff only loosens client-side validation of a string that already flows unvalidated through IPC into resolvePairingEndpoint; no CI/dependency/workflow/credential changes. Critically, the loosened renderer grammar stays a strict subset of what the main-process resolver accepts: it rejects credentials (user:pass@host), schemes, paths, whitespace, IPv6/multi-colon, and (see below) numeric-final-label hosts — none of which can reach a shell (the address only ever reaches the WHATWG URL constructor).

Reproduced first on origin/main — a unit test asserting home.example.com, mydomain.example:8443, and my-nas validate fails on main (all three rejected) and passes here.

Three review findings fixed on top of the original patch:

  1. Ambiguous-IPv4 guard was incomplete — it only rejected fully-numeric hosts, but the WHATWG URL parser also treats a host whose last label is numeric/hex (foo.123, foo.0x1) as IPv4 and then dials a fallback host. Widened to a single last-label check (which also cleanly subsumes the bare-123 case CodeRabbit flagged).
  2. Unbounded / leading-zero port — ^[0-9]+$ let example.com:00…08080 past the range check and inflate the returned address beyond the old length cap. Now rejects leading-zero ports.
  3. Copy change was inert — translate() reads en.json before the TSX fallback, so the English build still showed the old copy, and es/ja/ko/zh still described the old .ts.net-only rule. Updated all five catalogs.

Verification

  • pnpm vitest run src/shared/network/manual-address.test.ts → 25 passed
  • pnpm run typecheck → clean · oxlint + verify:localization-catalog → clean (5 locales in parity)
  • UI in a dev build (Settings → Mobile pairing → Add custom address…): dialog renders the new placeholder/hint; home.example.com enables Use address (rejected before); foo.123 correctly stays disabled.

Not merging — leaving that to a human reviewer.

@nwparker
nwparker merged commit 2153ef9 into stablyai:main Jul 3, 2026
@nwparker

nwparker commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Merged — this passed our review bar. @Daily-AC thanks for the contribution! We validated the gap against the main-process parser, kept your loosened grammar, and hardened it further (numeric-final-label IPv4 ambiguity guard, leading-zero port rejection, all-5-locale copy update) before merging.

@nwparker

nwparker commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Appreciate this, @Daily-AC. The renderer being stricter than the backend it hands off to was a real papercut for DDNS and self-hosted setups, and you fixed it at exactly the right layer. Thanks for looking out for the self-hosting crowd — merged.

@nwparker

nwparker commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Thanks so much for this 🙏 Love that it came from your own DDNS / self-hosted setup — those are exactly the papercuts that slip past us because our test machines don't hit them. You made pairing nicer for everyone running their own box. Appreciate you! 🐋

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…try (stablyai#7223)

* Allow arbitrary hostnames in manual network address entry

parseManualNetworkAddress only accepted an IPv4 address or a Tailscale
MagicDNS (*.ts.net) hostname, so users behind a dynamic residential IP
who rely on a DDNS domain or self-hosted relay had no way to enter it
in the desktop UI short of bypassing validation via DevTools/IPC.

The main process already resolves any host: resolvePairingEndpoint
and parsePairingAddressOverride in src/main/runtime/runtime-rpc.ts
accept an arbitrary hostname and an optional host:port. This change
brings the renderer-side validation in line with what pairing already
supports: any RFC 1123 hostname (a superset that still covers
*.ts.net), optionally suffixed with :port (1-65535). IPv4 validation
is unchanged, including still rejecting malformed dotted-numeric input
instead of silently treating it as an all-digit hostname.

Updates the custom-address dialog copy in NetworkInterfacePicker.tsx
to describe the wider grammar.

* Polish manual-address takeover: fix bare-numeric guard, sync 5 locales, lint

- Require a dot in the IPv4-typo guard so a bare numeric label (`123`)
  validates as a legal RFC 1123 hostname, matching the code's own comment
  and the main-process resolver; add coverage.
- Update en.json + es/ja/ko/zh placeholder/hint to the broadened grammar
  (translate() reads en.json before the TSX fallback, so the copy change
  was previously inert; the other locales described the old ts.net-only rule).
- Replace indexOf(...)!==-1 with includes() to satisfy oxlint.

Co-authored-by: Orca <[email protected]>

* Keep validator a strict subset of the backend resolver

Review surfaced two ways the renderer could accept an address the main
process handles differently:
- All-numeric hosts (bare `123` and dotted `256.0.0.1`) are now rejected.
  The WHATWG URL host parser downstream reinterprets a numeric host as IPv4
  (`123` -> `0.0.0.123`), so accepting one would validate an address the
  pairing resolver silently dials as a different host.
- Ports with leading zeros are rejected. `^[0-9]+$` let an arbitrarily long
  zero-padded string past the range check and inflate the returned address
  beyond the hostname length cap that the old whole-string check enforced.

Co-authored-by: Orca <[email protected]>

* Reject any numeric final label, not just fully-numeric hosts

WHATWG URL host parsing treats a host whose last label is numeric
(`foo.123`, `foo.0x1`) as an IPv4 signal, so the pairing resolver would
fail to parse it and silently dial a fallback host. Widen the ambiguous-IP
guard to a single last-label check that subsumes the earlier all-numeric
case, keeping the renderer a strict subset of what the backend resolves
correctly. Normal hostnames whose last label merely contains digits
(`host2.example.com`) are unaffected.

Co-authored-by: Orca <[email protected]>

---------

Co-authored-by: Neil <[email protected]>
Co-authored-by: Orca <[email protected]>
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.

Manual network address entry rejects any hostname that isn't *.ts.net

2 participants