Skip to content

chore(deps): update russh, use crates.io of hakoniwa, update deps - #642

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/progress
Jul 6, 2026
Merged

chore(deps): update russh, use crates.io of hakoniwa, update deps#642
twitchyliquid64 merged 1 commit into
mainfrom
tom/progress

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Jul 6, 2026

Copy link
Copy Markdown
Member

Code diff is the breaking change in russh where you indicate channel success/failure via a new type ChannelOpenHandle, which you can throw around async tasks, vs being forced to return Result<bool, _>

Summary by CodeRabbit

  • Bug Fixes
    • Improved SSH connection handling for session and direct TCP channels, with clearer accept/reject behavior.
    • Unauthorized or invalid connection attempts are now rejected more consistently, including bad session details, invalid ports, and upstream connection failures.
    • Upgraded workspace dependencies to newer releases, including a newer SSH library version and a released hakoniwa package.

@twitchyliquid64
twitchyliquid64 enabled auto-merge (squash) July 6, 2026 16:46
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Cargo.toml updates the hakoniwa dependency from a git-pinned revision to crates.io version 1.7.2 and bumps russh from 0.61 to 0.62. connection.rs reworks channel_open_session and channel_open_direct_tcpip to use ChannelOpenHandle, replacing boolean returns with reply.accept()/reject() calls and Result<(), Error>.

Changes

russh Upgrade and Channel-Open Handler Rework

Layer / File(s) Summary
Dependency version bumps
Cargo.toml
hakoniwa moves from a git-pinned revision to crates.io release 1.7.2 (same features retained), and russh is bumped from 0.61 to 0.62.
Session channel-open handler update
crates/minimald/src/connection.rs
Imports ChannelOpenHandle; channel_open_session now rejects non-local auth or accepts via reply.reject/reply.accept, returning Result<(), Error> instead of Result<bool, Error>.
Direct-tcpip channel-open validation and connection flow
crates/minimald/src/connection.rs
channel_open_direct_tcpip signature updated to take a ChannelOpenHandle; auth checks, username/UUID validation, session lookup, port-range checks, and upstream TCP connect/timeout handling now reject via ChannelOpenFailure values, while success accepts the channel, spawns the relay task, and returns Ok(()).

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • gominimal/minimal#278: Both PRs modify the hakoniwa dependency entry in Cargo.toml, updating version/revision while keeping the same features.

Suggested labels: dependencies, rust

Suggested reviewers: 0chroma, evanspearman, norrietaylor

Poem

A rabbit hops through crates anew,
hakoniwa fresh, russh 0.62 too,
Channels now reject or accept with grace,
no more bools, just a tidy trace,
Thump thump — the tunnels relay through! 🐇🔌

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main dependency updates, including russh and switching hakoniwa to crates.io.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
crates/minimald/src/connection.rs (2)

464-465: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Stale doc comment: handler no longer returns false.

channel_open_direct_tcpip now returns Result<(), Self::Error> and rejects via ChannelOpenHandle; the doc comment referencing "rejected by returning false" is outdated.

📝 Proposed fix
-    /// Only authenticated (local) connections may forward ports; unauthenticated
-    /// connections are rejected by returning `false`.
+    /// Only authenticated (local) connections may forward ports; unauthenticated
+    /// connections are rejected via `reply.reject(...)`.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/minimald/src/connection.rs` around lines 464 - 465, Update the stale
doc comment on the `channel_open_direct_tcpip` handler in `connection.rs` so it
matches the current `Result<(), Self::Error>` behavior instead of saying
unauthenticated connections are rejected by returning `false`. Keep the comment
aligned with the actual rejection path used by `ChannelOpenHandle`, and refer to
the handler’s current signature/authorization behavior rather than the old
boolean-return wording.

277-296: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Consider dropping the connection lock before awaiting reply.reject()/reply.accept().

s is held across the network-bound .await calls at lines 287 and 294, even though it's no longer needed once the auth check/channel-insert is done. channel_open_direct_tcpip avoids this by scoping the lock to a block (lines 484-491) before any reply call. Matching that pattern here removes an unnecessary async-mutex-held-across-I/O window that could add lock contention for other connection state accesses (e.g. handle_channel_close, env_request) racing on the same connection.

♻️ Proposed fix
     async fn channel_open_session(
         &mut self,
         c: RuChannel<Msg>,
         reply: ChannelOpenHandle,
         _: &mut Session,
     ) -> Result<(), Self::Error> {
-        let mut s = self.0.lock().await;
-        if s.auth != Auth::Local {
+        let is_local = {
+            let s = self.0.lock().await;
+            s.auth == Auth::Local
+        };
+        if !is_local {
             reply
                 .reject(russh::ChannelOpenFailure::AdministrativelyProhibited)
                 .await; // indicate failure
             return Ok(());
         }

         protocol_trace!("Minting session channel with id {}", c.id());
-        s.channels.insert(c.id(), Channel::new_session(c.id(), c));
+        {
+            let mut s = self.0.lock().await;
+            s.channels.insert(c.id(), Channel::new_session(c.id(), c));
+        }

         reply.accept().await; // indicate success
         Ok(())
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/minimald/src/connection.rs` around lines 277 - 296, In
channel_open_session, the connection mutex guard s is held across the network
await on reply.reject()/reply.accept(), which is unnecessary after the auth
check and channel insert. Scope the lock to only cover the Auth::Local check and
s.channels.insert, then drop it before calling either reply method, following
the same pattern used by channel_open_direct_tcpip to avoid holding the async
lock during I/O.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/minimald/src/connection.rs`:
- Around line 464-465: Update the stale doc comment on the
`channel_open_direct_tcpip` handler in `connection.rs` so it matches the current
`Result<(), Self::Error>` behavior instead of saying unauthenticated connections
are rejected by returning `false`. Keep the comment aligned with the actual
rejection path used by `ChannelOpenHandle`, and refer to the handler’s current
signature/authorization behavior rather than the old boolean-return wording.
- Around line 277-296: In channel_open_session, the connection mutex guard s is
held across the network await on reply.reject()/reply.accept(), which is
unnecessary after the auth check and channel insert. Scope the lock to only
cover the Auth::Local check and s.channels.insert, then drop it before calling
either reply method, following the same pattern used by
channel_open_direct_tcpip to avoid holding the async lock during I/O.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 36167bda-9f08-4cc9-930c-79acb4429fdb

📥 Commits

Reviewing files that changed from the base of the PR and between e7c2674 and 571cccc.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • Cargo.toml
  • crates/minimald/src/connection.rs

@twitchyliquid64
twitchyliquid64 merged commit 4da49ab into main Jul 6, 2026
57 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/progress branch July 6, 2026 17:20
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.

2 participants