mini-telnet

Crates.iomini-telnet
lib.rsmini-telnet
version0.1.8
sourcesrc
created_at2021-12-01 07:16:52.971361
updated_at2022-04-24 05:42:06.027902
descriptionAsynchronous minimal telnet library
homepage
repositoryhttps://github.com/kolapapa/mini-telnet
max_upload_size
id490150
size39,023
Golden Cicada (kolapapa)

documentation

README

mini-telnet

Crates.io MIT licensed API docs

A mini async telnet client.

Usage

Add to Cargo.toml:

mini-telnet = "0.1.6"

Example

use std::time::Duration;

use mini_telnet::Telnet;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut telnet = Telnet::builder()
        .prompt("ubuntu@ubuntu:~$ ")
        .login_prompt("login: ", "Password: ")
        .connect_timeout(Duration::from_secs(10))
        .timeout(Duration::from_secs(5))
        .connect("192.168.100.2:23")
        .await?;
    telnet.login("ubuntu", "ubuntu").await?;

    assert_eq!(
        telnet.normal_execute("echo 'haha'").await?,
        "echo 'haha'\nhaha\n",
    );

    assert_eq!(telnet.execute("echo 'haha'").await?, "haha\n");
    Ok(())
}

Part of the logic referenced from: telnet-chat

Commit count: 32

cargo fmt