9 releases

0.1.8 Apr 24, 2022
0.1.7 Mar 30, 2022
0.1.6 Dec 29, 2021

#2168 in Asynchronous

Download history 99/week @ 2024-09-24 57/week @ 2024-10-01 32/week @ 2024-10-08 36/week @ 2024-10-15 36/week @ 2024-10-22 33/week @ 2024-10-29 42/week @ 2024-11-05 25/week @ 2024-11-12 29/week @ 2024-11-19 38/week @ 2024-11-26 38/week @ 2024-12-03 78/week @ 2024-12-10 128/week @ 2024-12-17 93/week @ 2024-12-24 11/week @ 2024-12-31 33/week @ 2025-01-07

286 downloads per month
Used in legba

MIT license

22KB
424 lines

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

Dependencies

~8–18MB
~216K SLoC