#tokio #telnet

mini-telnet

Asynchronous minimal telnet library

7 releases

Uses new Rust 2021

0.1.6 Dec 29, 2021
0.1.5 Dec 27, 2021

#256 in Asynchronous

Download history 57/week @ 2021-11-26 28/week @ 2021-12-03 26/week @ 2021-12-10 2/week @ 2021-12-17 32/week @ 2021-12-24 9/week @ 2021-12-31 8/week @ 2022-01-07 3/week @ 2022-01-14

53 downloads per month

MIT license

19KB
367 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

~7MB
~112K SLoC

b^a