Repository navigation
fix(cli-rs): correctly identify localhost loopback URLs - #67574
Merged
Merged
Conversation
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.
Contributor
There was a problem hiding this comment.
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.
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does
Ports #67420 to the native CLI.
is_loopback(crates/cli/src/commands/pair.rs), which decides which server URLspairshows a QR code for and howmachineorders and checks a machine's addresses, treated any host starting with127.as loopback (so127.example.comwas), missed a trailing dot (localhost.), and missed an unbracketed::1. It now strips one trailing dot, acceptslocalhost,*.localhost,::1and[::1], and requires a valid IPv4 loopback address, asservice-urls.tsdoes after #67420.Checks
loopback_hosts_match_typescriptruns the eight hosts ofmachine.test.ts's "machine reach" case, andpair's links test gains alocalhost.row and a127.example.comrow.cargo fmt --check,clippy,check:drift, thecommands::pairandcommands::machinetests, and theC.9/pair-loopback,C.9/pair,C.9/machineandC.9/machine-serverP-CLI scenarios pass.