A mini async telnet client.

Overview

mini-telnet

A mini async telnet client.

Usage

Add to Cargo.toml:

mini-telnet = "0.1.2"

Example

/tmp/temp", timeout).await?; let output = telnet.execute("cat /tmp/temp", timeout).await?; assert_eq!(output, "test\n"); Ok(()) } ">
use std::time::Duration;

use mini_telnet::Telnet;

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

    println!("Telnet login Success.");

    telnet.execute("echo 'test' > /tmp/temp", timeout).await?;
    let output = telnet.execute("cat /tmp/temp", timeout).await?;
    assert_eq!(output, "test\n");
    Ok(())
}

Part of the logic referenced from: telnet-chat

You might also like...
A STOMP client in Rust. Compatible with RabbitMQ, ActiveMQ.

stomp-rs stomp-rs provides a full STOMP 1.2 client implementation for the Rust programming language. This allows programs written in Rust to interact

Rust client for NATS, the cloud native messaging system.

A Rust client for the NATS messaging system. Status Motivation Rust may be the most interesting new language the NATS ecosystem has seen. We believe t

rqbit - bittorrent client in Rust

rqbit - bittorrent client in Rust

Filen.io is a cloud storage provider with an open-source desktop client.

Library to call Filen.io API from Rust Filen.io is a cloud storage provider with an open-source desktop client. My goal is to write a library which ca

Simple project to test grpc between ruby (client) and rust (server)

grpc-example Simple project to test grpc between ruby (client) and rust (server). Usage To simplify a lot this project uses docker and docker compose

A rust client and structures to interact with the Clever-Cloud API.

Clever-Cloud Software Development Kit - Rust edition This crate provides structures and client to interact with the Clever-Cloud API. Status This crat

Third party Google DNS client for rust.

google-dns-rs Documentation Install Add the following line to your Cargo.toml file: google-dns-rs = "0.3.0" Usage use google_dns_rs::api::{Dns, DoH, R

The Safe Network Core. API message definitions, routing and nodes, client core api.

safe_network The Safe Network Core. API message definitions, routing and nodes, client core api. License This Safe Network repository is licensed unde

A tcp proxy server/client which exchange the data in temp files

ftcp A tcp proxy server/client which exchange the data in temp files 通过在临时文件中交换数据来进行TCP代理的一个服务端/客户端 学校内网中有针对教学楼的防火墙导致教室电脑难以上网( 但学校内建有公共ftp服务器,因此就有了这个借

Comments
  • Fix: Fixed to wait for multiple prompts

    Fix: Fixed to wait for multiple prompts

    Modified the prompt property of the Telnet structure to Vec to listen for multiple prompts during the connection. This is because the prompt changes when several commands are executed. I would appreciate it if you could check the modified part of the code.

    opened by Yos-K 7
  • Extraneous newlines in telnet server response

    Extraneous newlines in telnet server response

    Thanks for writing and releasing this crate. I'm using it to collect diagnostic data from my router and seem to be getting extra newlines in the response from the telnet server.

    When I telnet to my router using PuTTY and issue xdslctl info I get:

    xdslctl: ADSL driver and PHY status
    Status: Showtime
    Last Retrain Reason:    1
    Last initialization procedure status:   0
    Max:    Upstream rate = 12578 Kbps, Downstream rate = 60380 Kbps
    Bearer: 0, Upstream rate = 12835 Kbps, Downstream rate = 59803 Kbps
    Bearer: 1, Upstream rate = 0 Kbps, Downstream rate = 0 Kbps
    

    but when I use mini-telnet and let response = telnet.execute("xdslctl info").await? and then println!("{}", response), I get:

    xdslctl: ADSL driver and PHY status
    
    Status: Showtime
    
    Last Retrain Reason:    1
    
    Last initialization procedure status:   0
    
    Max:    Upstream rate = 12578 Kbps, Downstream rate = 60276 Kbps
    
    Bearer: 0, Upstream rate = 12835 Kbps, Downstream rate = 59803 Kbps
    
    Bearer: 1, Upstream rate = 0 Kbps, Downstream rate = 0 Kbps
    

    Could it be https://github.com/kolapapa/mini-telnet/blob/250f39d6bbae9ab2dc0cbe3b89639a9574ac0697/src/lib.rs#L255 that's introducing the extra newlines?

    opened by drguildo 1
Releases(v0.1.8)
Owner
kolapapa
kolapapa
Simple SSH, TELNET connection manager written in rust

gcoma gcoma or Geri's Connection Manager is a small project, that I started to learn rust. The goal of this project is to create a MTPuTTY like cli ap

Bak Gergely János 2 Sep 30, 2022
A mini-CI as a Zellij plugin

About This Zellij plugin is a "mini-ci". It allows you to specify commands that will run in parallel, keeping track of completed commands and their ex

Aram Drevekenin 10 Jun 22, 2023
Acts as an IRC server and a nostr client. Connect with your IRC client using your nostr private key as the password.

nostr-irc Acts as an IRC server and a nostr client. Connect with your IRC client using your nostr private key as the password. Experimental code, use

null 11 Dec 26, 2022
A minimalistic encryption protocol for rust async streams/packets, based on noise protocol and snow.

Snowstorm A minimalistic encryption protocol for rust async streams / packets, based on noise protocol and snow. Quickstart Snowstorm allows you to se

Black Binary 19 Nov 22, 2022
Redis backed session store for async-session using fred.rs.

async-fred-session Redis backed session store for async-session using fred.rs. This work is mostly based on async-redis-session. use async_fred_sessio

void* 4 Feb 28, 2023
An async, user-friendly Let's Encrypt/ACMEv2 library written in Rust

lers An async, user-friendly Let's Encrypt/ACMEv2 library written in Rust. The API and implementation were inspired by acme2, acme-micro, and lego. Fe

Alexander Krantz 20 Apr 3, 2023
Async-friendly WebTransport implementation in Rust

WTransport WebTransport protocol, pure-rust, async-friendly. Introduction WebTransport is a new protocol being developed to enable low-latency, bidire

Biagio Festa 19 Jun 15, 2023
FTP client for Rust

rust-ftp FTP client for Rust Documentation rust-ftp Installation Usage License Contribution Development environment Installation FTPS support is achie

Matt McCoy 155 Nov 12, 2022
NNTP client for Rust

rust-nntp NNTP Client for Rust Usage extern crate nntp; use nntp::{Article, NNTPStream}; fn main() { let mut nntp_stream = match NNTPStream::connec

Matt McCoy 13 Jan 22, 2022
POP3 client for Rust

rust-pop3 POP3 Client for Rust This client has SSL support. SSL is configured using an SSLContext that is passed into the connect method of a POP3Stre

Matt McCoy 26 Dec 19, 2022