refactor: make SSH connection async using tokio::net::TcpStream#129
Merged
Conversation
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.
This pull request refactors the SSH and SFTP connection logic to use asynchronous (async/await) Rust APIs instead of blocking calls, improving performance and responsiveness, especially in the UI. It also updates related UI and helper functions to use the new async signatures, removing unnecessary
spawn_blockingwrappers and simplifying code.Core async/await migration and API changes:
establish_ssh_sessioninsrc/ssh_engine.rsto be fully async, usingtokio's async networking and DNS lookup, and moved blocking SSH session setup intospawn_blockingfor safety. The function signature now takes an ownedOption<String>for passwords instead of a borrowed reference. [1] [2]deploy_pubkeyandrun_remote_commandto be async functions, with their internal SSH session setup and remote command execution performed inspawn_blocking. Their signatures now require owned types and are awaited directly. [1] [2]UI and usage updates:
src/ui/docker.rs,src/ui/monitor.rs, andsrc/ui/ssh_keys.rsto call the new asyncrun_remote_commandanddeploy_pubkeyfunctions directly, removing redundantspawn_blockingwrappers and adjusting for the new signatures. [1] [2] [3] [4] [5] [6]SFTP connection improvements:
get_or_connect_sftpto use the new async SSH session logic and moved only the SFTP handle creation intospawn_blocking, reducing unnecessary thread usage.These changes modernize the SSH/SFTP handling, improve performance, and simplify the async/UI integration.