fix(cli): bracket IPv6 bind literals in SSH forwards - #2552
Merged
Conversation
ForwardSpec accepts IPv6 bind addresses, but ssh_forward_arg() emitted them unbracketed (e.g. ::1:8080:127.0.0.1:8080), which OpenSSH rejects as a bad local forwarding specification. access_url() likewise produced invalid URLs like http://::1:8080/. Extract a shared bracket_ipv6_host() helper and use it in ssh_forward_arg(), access_url() (via format_gateway_url), and format_gateway_url() so IPv6 literals are bracketed consistently. Fixes NVIDIA#2279 Signed-off-by: Russell Bryant <rbryant@redhat.com>
russellb
requested review from
a team,
derekwaynecarr,
maxamillion and
mrunalp
as code owners
July 29, 2026 20:47
Collaborator
|
/ok to test 280ea90 |
mrunalp
approved these changes
Jul 29, 2026
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.
Summary
openshell forward start ::1:8080 <sandbox>built an invalid SSH local-forward argument and an invalid access URL because IPv6 bind literals were never bracketed. This fix brackets IPv6 literals so OpenSSH accepts the-Lspecification and the displayed URL is valid.Related Issue
Fixes #2279
Changes
bracket_ipv6_host()helper incrates/openshell-core/src/forward.rs.ForwardSpec::ssh_forward_arg()now brackets IPv6 bind literals (::1:8080:127.0.0.1:8080→[::1]:8080:127.0.0.1:8080), which OpenSSH accepts.ForwardSpec::access_url()now formats via the existingformat_gateway_url()helper, producinghttp://[::1]:8080/while keeping the wildcard (::/0.0.0.0) →localhostdisplay mapping.format_gateway_url()to reuse the new helper (DRY).The reverse process-matching in
ssh_forward_arg_matches_openshell_loopback_portmatches on the:{port}:127.0.0.1:{port}suffix, so bracketed bind prefixes still match — background-forward validation is unaffected.Testing
mise run pre-commitpasses (Rust lint/format/tests clean; the unrelated pre-existinghelm:lintchart-metadata error is not touched by this change)forward_spec_ssh_forward_arg_brackets_ipv6_literal,forward_spec_access_url_ipv6)Verified locally:
cargo test -p openshell-core --lib(362 passed) andcargo test -p openshell-cli --lib ssh::(40 passed).Checklist