Repository navigation
Accept any hostname (and optional :port) in manual network address entry - #7223
Conversation
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.
📝 WalkthroughWalkthroughThis PR generalizes manual network address handling from MagicDNS-only hostnames to IPv4 addresses or RFC 1123-compatible hostnames with an optional Changes
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)
✅ 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: 2
🧹 Nitpick comments (1)
src/shared/network/manual-address.test.ts (1)
113-119: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd 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 inmanual-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
📒 Files selected for processing (3)
src/renderer/src/components/mobile/NetworkInterfacePicker.tsxsrc/shared/network/manual-address.test.tssrc/shared/network/manual-address.ts
| 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.' |
There was a problem hiding this comment.
🎯 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 || trueRepository: 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 80Repository: 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 120Repository: 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.
| // 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 } | ||
| } |
There was a problem hiding this comment.
🎯 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.
| // 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 } | |
| } |
…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]>
|
🛠️ Taken over and finished by a maintainer. Pushed 4 commits on top of the original (latest Security screen — clean. The diff only loosens client-side validation of a string that already flows unvalidated through IPC into Reproduced first on Three review findings fixed on top of the original patch:
Verification
Not merging — leaving that to a human reviewer. |
|
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. |
|
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. |
|
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! 🐋 |
…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]>
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.netTailscale MagicDNS hostname. This broadens it to accept any RFC 1123 hostname — which still covers*.ts.net— with an optional:portsuffix.This closes a UI-only gap: the main-process pairing-endpoint resolution (
resolvePairingEndpoint/parsePairingAddressOverrideinsrc/main/runtime/runtime-rpc.ts) already accepts any host orhost: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 ahost:portsplit (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.tsxand 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
URLhost 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
origin/main: a unit test assertinghome.example.com,mydomain.example:8443, andmy-nasare accepted fails onmain(all three rejected), and passes on this branch.pnpm vitest run src/shared/network/manual-address.test.ts→ 25 passed.pnpm run typecheck→ clean. Lint:oxlint+pnpm run verify:localization-catalog→ clean (all 5 locales in parity).home.example.comenables Use address (was rejected before); typingfoo.123correctly 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 likehome.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
host:port, not just IPv4 /*.ts.net. Bad input still fails at the form (with the reworded error) rather than at connect time.example.com.), raw-Unicode/IDN hostnames (use punycodexn--…), 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, matchingparsePairingAddressOverride.mobile:getPairingQRIPC 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.