Comments (1)
感谢您的提议。
关于您提议的三点,
- 中断:在
run_local
模式下,所有操作都需要同步完成,所以无论是scp
还是exec
都无法增加这个api,但是在run_backend
模式下,或许可以增加类似的api。对于SSH来说,用户每开启一个channel,在服务器端都是并发执行的,所以如果只是为了多任务执行,可以使用run_backend
模式同时打开多个channel,如果是为了阻止先前命令产生的副作用,那还是需要一个cancel
或者abort
的api,之前设计的时候没有考虑到。 - scp传输完成率:基于当前的设计,
local
模式或许可以在log里面增加相关打印,但是依然是前述问题,因为同步执行,无法提供单独api。backend
模式目前的处理是先把文件全部读入内存然后提交到后台线程进行传输,所以可以提供所需api,会在后续更新中留意。 - 异步:如果只是单纯的指异步地执行ssh的相关操作,那么
run_backend
模式已经有了相关实现,保留同步执行的目的是为了兼容单线程执行环境(WASI,虽然目前对WASI的适配还在进行中)。如果是指async
关键词的异步代码,这个改动或许有些巨大,需要把所有使用where S: Read + Write
签名的方法全部重写,目前好像还没有一个好的方案能用同一套底层代码同时支持同步和异步io,关于这个改动是否要进行还在考虑中,或许会新开一个库来实现,因为并不是所有场景都适合引入异步进行时。
如果还有更多建议与问题,烦请告知
BRs.
P.S. 关于并发执行的POC,您可以尝试
use ssh_rs::ssh;
fn main() {
ssh::enable_log();
let mut session = ssh::create_session()
.username("ubuntu")
.password("password")
.private_key_path("./id_rsa")
.connect("127.0.0.1:22")
.unwrap()
.run_backend();
let exec = session.open_exec().unwrap();
let exec2 = session.open_exec().unwrap();
const CMD: &str = "sleep 10 && date";
// send the command to server
println!("Send command {}", CMD);
exec.send_command(CMD).unwrap();
exec2.send_command(CMD).unwrap();
// process other data
println!("Do someother thing");
// get command result
let vec: Vec<u8> = exec.get_result().unwrap();
println!("{}", String::from_utf8(vec).unwrap());
let vec2: Vec<u8> = exec2.get_result().unwrap();
println!("{}", String::from_utf8(vec2).unwrap());
// Close session.
session.close();
}
from ssh-rs.
Related Issues (20)
- 是否可以在登录的时候设置StrictHostKeyChecking属性? HOT 8
- How to obtain SshError HOT 8
- Only captures stdout HOT 2
- add more encryption algorithms HOT 3
- Bump ssh-key crate version HOT 4
- `tracing` dependency is not new enough
- Ssh-rs panic on a thread when using in multi threading HOT 4
- Error when connecting to older ExtremeXOS switch HOT 1
- 能否支持一边读取命令执行结果一遍输出,而不是等到整个命令完全执行完毕再输出所有的结果? HOT 1
- ssh -rs crashed on Zero lenght version information HOT 4
- Use Rust std TCP set_read_TimeOut instead of a custum one ? HOT 3
- add connect_with_timeout to set connection timeout HOT 4
- Getting command exit status HOT 3
- Scp: quoting errors with spaces in dest filename HOT 5
- Scp: track progress for larger transfers HOT 2
- Scp: path-related bugs on windows HOT 1
- OpenSSH client drop-in replacement
- [email protected] request ignored HOT 1
- "Auth error" against freebsd HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ssh-rs.