| Crates.io | flatline |
| lib.rs | flatline |
| version | 0.0.11 |
| created_at | 2024-03-02 16:30:17.915146+00 |
| updated_at | 2024-09-19 14:58:57.939506+00 |
| description | ssh-2.0 client library |
| homepage | |
| repository | https://github.com/Zhou-Pixel/flatline.git |
| max_upload_size | |
| id | 1159820 |
| size | 442,448 |
curve25519-sha256@libssh.orgcurve25519-sha256ecdh-sha2-nistp256ecdh-sha2-nistp384ecdh-sha2-nistp521diffie-hellman-group14-sha256diffie-hellman-group16-sha512diffie-hellman-group16-sha256diffie-hellman-group14-sha1diffie-hellman-group18-sha512diffie-hellman-group-exchange-sha256diffie-hellman-group-exchange-sha1diffie-hellman-group15-sha512diffie-hellman-group17-sha512diffie-hellman-group1-sha1ssh-ed25519rsa-sha2-256rsa-sha2-512ssh-rsassh-dssecdsa-sha2-nistp521ecdsa-sha2-nistp256ecdsa-sha2-nistp384chacha20-poly1305@openssh.comaes256-gcm@openssh.comaes128-gcm@openssh.comaes256-ctraes128-cbcaes192-cbcaes256-cbcaes128-ctraes192-ctrrijndael-cbc@lysator.liu.se3des-cbchmac-sha1hmac-sha1-etm@openssh.comhmac-sha1-96hmac-sha1-96-etm@openssh.comhmac-md5hmac-md5-etm@openssh.comhmac-md5-96hmac-md5-96-etm@openssh.comhmac-sha2-512hmac-sha2-512-etm@openssh.comhmac-sha2-256hmac-sha2-256-etm@openssh.comzlibzlib@openssh.com#[tokio::main]
async fn main() {
use flatline::session::Session;
use flatline::handshake::Config;
use tokio::net::TcpStream;
use flatline::session::Userauth;
use flatline::channel::ExitStatus;
let socket = TcpStream::connect("192.168.8.190:22").await.unwrap();
let config = Config::deafult_with_behavior();
let session = Session::handshake(config, socket).await.unwrap();
let status = session.userauth_password("zhou", "123456").await.unwrap();
assert!(matches!(status, Userauth::Success));
let mut channel = session.channel_open_default().await.unwrap();
channel.exec("echo \"hello\"").await.unwrap();
loop {
let msg = channel.recv().await.unwrap();
match msg {
flatline::channel::Message::Close => break,
flatline::channel::Message::Eof => break,
flatline::channel::Message::Stdout(data) => assert_eq!(data, b"hello\n"),
flatline::channel::Message::Stderr(_) => unreachable!(),
flatline::channel::Message::Exit(status) => assert!(matches!(status, ExitStatus::Normal(0))),
}
}
}
[!WARNING] flatline is beta now and can contain breaking changes!