Skip to content

fix(cli-rs): correctly identify localhost loopback URLs - #67574

Merged
simonklee merged 1 commit into
devfrom
loopback-hosts
Dec 1, 2026
Merged

simonklee merged 1 commit into
devfrom
loopback-hosts

Conversation

@simonklee

Copy link
Copy Markdown
Member

What it does

Ports #67420 to the native CLI. is_loopback (crates/cli/src/commands/pair.rs), which decides which server URLs pair shows a QR code for and how machine orders and checks a machine's addresses, treated any host starting with 127. as loopback (so 127.example.com was), missed a trailing dot (localhost.), and missed an unbracketed ::1. It now strips one trailing dot, accepts localhost, *.localhost, ::1 and [::1], and requires a valid IPv4 loopback address, as service-urls.ts does after #67420.

Checks

loopback_hosts_match_typescript runs the eight hosts of machine.test.ts's "machine reach" case, and pair's links test gains a localhost. row and a 127.example.com row. cargo fmt --check, clippy, check:drift, the commands::pair and commands::machine tests, and the C.9/pair-loopback, C.9/pair, C.9/machine and C.9/machine-server P-CLI scenarios pass.

Port 7750100 (#67420) to is_loopback in crates/cli/src/commands/pair.rs (used by pair QR filtering and machine reach ordering/access checks): strip a trailing dot, recognize unbracketed ::1, and require a valid IPv4 loopback address instead of a 127. prefix so domains like 127.example.com are not treated as loopback.

@opencodejr opencodejr 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.

Looks good. I compiled the old and new is_loopback into a standalone program and ran them on the hosts from loopback_hosts_match_typescript, plus 127.0.0.01 and 127.255.255.255. The base gets localhost., api.localhost., ::1, 127.example.com and 127.0.0.01 wrong; with this change every case is right and matches isLoopback in service-urls.ts. I couldn't run the crate's tests here because the opentui-sys native file was missing.

Public API is unchanged; only the internal loopback check used by pair and machine differs.

@simonklee
simonklee merged commit 7f13a1b into dev Dec 1, 2026
12 checks passed
@simonklee
simonklee deleted the loopback-hosts branch December 1, 2026 20:05
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.

1 participant