Skip to content

M13.2: AnvilSession::connect_via_proxy_command (FR-55)#10

Merged
UnbreakableMJ merged 1 commit into
mainfrom
feature/m13-2-connect-via-proxy-command
May 4, 2026
Merged

M13.2: AnvilSession::connect_via_proxy_command (FR-55)#10
UnbreakableMJ merged 1 commit into
mainfrom
feature/m13-2-connect-via-proxy-command

Conversation

@UnbreakableMJ

Copy link
Copy Markdown
Contributor

Summary

Adds the public constructor that consumes the ProxyCommand template captured in M12 and the building blocks landed in M13.1 (#6).

Re-opened on a clean rebase off main; previous PR #7 was auto-closed when its base branch was deleted by the M13.1 squash-merge.

Public surface (additive)

  • AnvilSession::connect_via_proxy_command(config: &AnvilConfig, template: &str, alias: &str) -> Result<Self, AnvilError>
    • Token-expands %h %p %r %n %% against config.host, config.port, config.username, and alias.
    • Spawns the expanded command via the platform shell, pipes its stdio, and hands it to russh::client::connect_stream.
    • Rejects the literal none (case-insensitive) — the FR-59 disable sentinel; callers should fall back to connect().

Internal refactor

  • New private HandlerPieces struct + Self::build_handler_pieces helper centralises the russh config + GitwayHandler + auth_banner + verified_fingerprint setup that connect(), connect_via_proxy_command, and (M13.4) connect_via_jump_hosts all need.
  • The existing connect() now calls the same helper; behavior is unchanged.
  • Removed the M13.1-era #![allow(dead_code)] from proxy/mod.rs since spawn_proxy_command and ChildStdio::new are now consumed.

Tests

  • 169 lib + 1 matrix + 6 integration; 0 failures, 5 ignored (the M13.1 child-stdio round-trip tests gated for local --ignored runs; integration coverage in M13.7).

Test plan

  • CI passes (Linux/macOS/Windows + MSRV 1.88).
  • cargo fmt / cargo clippy --all-targets -- -D warnings clean.
  • cargo test --lib --tests --locked green.

Plan: M13.2 of let-us-plan-on-bright-cosmos.md.

🤖 Generated with Claude Code

Adds the public constructor that consumes the ProxyCommand template
captured into ResolvedSshConfig in M12 and the building blocks landed
in M13.1 (token expansion + ChildStdio adapter).

session.rs:
- New private HandlerPieces struct + Self::build_handler_pieces helper
  factor out the russh config + GitwayHandler + auth_banner +
  verified_fingerprint mutex setup that connect() and the new
  connect_via_proxy_command both need. M13.4's connect_via_jump_hosts
  will reuse the same helper. The host-key fingerprint lookup
  (with the StrictHostKeyChecking::AcceptNew tolerance shipped in
  M12.5) lives there now, in one place.

- pub async fn connect_via_proxy_command(config, template, alias):
    1. Reject the literal `none` (case-insensitive) — that's the FR-59
       disable sentinel; callers should reach for connect() instead.
       The ssh_config resolver preserves `none` as a literal so first-
       wins protects it; the dispatcher in M13.6 turns that into a
       call to connect() rather than this method.
    2. Build the handler via build_handler_pieces.
    3. Spawn the ProxyCommand child via crate::proxy::command::
       spawn_proxy_command (token-expanded against config.host /
       config.port / config.username / alias).
    4. Hand the resulting ChildStdio (AsyncRead+AsyncWrite+Unpin+Send)
       to russh::client::connect_stream. russh drives the SSH
       handshake over the child's stdio.
    5. Return the AnvilSession with the same shape as connect() —
       indistinguishable to callers thereafter.

- The existing connect() now calls build_handler_pieces too; behavior
  is identical (same russh::client::connect call, same handler).

proxy/mod.rs:
- Removed the M13.1-era #![allow(dead_code)]; spawn_proxy_command and
  ChildStdio::new are now used by session.rs.

Tests: 173 lib + 1 matrix + 6 integration; 0 failures.

Plan: M13.2 of let-us-plan-on-bright-cosmos.md. Stacked on M13.1 (PR #6).
@UnbreakableMJ
UnbreakableMJ merged commit 3c3f779 into main May 4, 2026
5 checks passed
@UnbreakableMJ
UnbreakableMJ deleted the feature/m13-2-connect-via-proxy-command branch May 4, 2026 10:21
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