Ratel Rust Client
A Rust implementation of the Ratel client library, rewritten from Go to Rust with PTY interface support.
Features
- TCP and WebSocket connections support
- Interactive shell interface
- PTY (pseudo-terminal) support for terminal I/O
- Async/await with Tokio
- User authentication
- Random name generation
Quick Start
Running Example
Example:
Usage
As a Library
Add this to your Cargo.toml:
[]
= { = "/path/to/ratel-rust" }
Basic usage:
use RatelClient;
async
Running the Example
Project Structure
src/lib.rs- Main library entry pointsrc/model.rs- Data models (AuthInfo, Packet, etc.)src/network.rs- Network connections (TCP and WebSocket)src/shell.rs- Shell logic and listenersrc/util.rs- Utility functions (random name generation, etc.)src/pty.rs- PTY interface for terminal I/O
Network Types
The client automatically detects the network type based on the port:
- Ports ending with
9998→ WebSocket - All other ports → TCP
Authentication
The client uses an AuthInfo structure containing:
id: Unique user ID (auto-generated timestamp)name: Username (auto-generated if not provided)score: User score (default: 100)
Documentation
- PtyManager Guide - Complete reference for PTY I/O management
Development
Building
Running Tests
Checking Code
Dependencies
tokio- Async runtimetokio-tungstenite- WebSocket supportserde- Serializationanyhow- Error handlingcrossterm- Terminal handlingpty-process- PTY support
License
This project is a Rust port of the original Go Ratel client.