#tokio #telnet

mini-telnet

Asynchronous minimal telnet library

9 releases

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

#1242 in Asynchronous

Download history 59/week @ 2023-10-19 101/week @ 2023-10-26 356/week @ 2023-11-02 132/week @ 2023-11-09 78/week @ 2023-11-16 110/week @ 2023-11-23 86/week @ 2023-11-30 58/week @ 2023-12-07 131/week @ 2023-12-14 75/week @ 2023-12-21 44/week @ 2023-12-28 103/week @ 2024-01-04 163/week @ 2024-01-11 120/week @ 2024-01-18 142/week @ 2024-01-25 123/week @ 2024-02-01

554 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–20MB
~233K SLoC