xtool
A collection of amazing command-line tools, featuring TFTP server/client, HTTP static file server, serial port tools, file transfer service, and disk image utilities.
Features
- TFTP Server: RFC-compliant TFTP server with support for read/write operations
- TFTP Client: Command-line client for downloading and uploading files
- HTTP Server: Static file server with directory listing
- Serial Tools: Serial port monitor, list, and network forwarding
- File Transfer: Upload/download files via token-based service with encryption support
- Disk Utilities: Create and manipulate disk images (GPT, ext4, FAT32)
Installation
Or install from crates.io:
Usage
TFTP Server
Start a TFTP server:
# Basic usage - serve files from /var/tftp on port 69
# Specify IP and port
# Read-only mode
# Single port mode (useful behind NAT)
TFTP Client
Download a file:
# Download file from server
# Download to specific location
# Specify port and options
Upload a file:
# Upload file to server
# Upload with different remote name
# Specify options
HTTP Server
Start a static file HTTP server:
# Basic usage - serve current directory on port 80
# Specify port and directory
Features:
- Directory listing with HTML interface
- Automatic MIME type detection
- Serves
index.htmlfor directory requests
Serial Console
List available serial ports:
Monitor a serial port (interactive shell):
# Monitor COM1 with default baud rate (115200)
# Monitor with specific baud rate
# Use configuration file defaults (if port is set in .xtool.toml)
# Interactive port selection if no port specified
Key bindings:
Ctrl + ]: Exit monitor mode
Serial network forwarding (forward network to serial):
# Start server - forward TCP connections to serial port
# Connect client - connect to serial server remotely
File Transfer
Upload a file and get a token:
# Upload a file
# Upload with download limit
# Upload directory (auto-compressed)
# Upload with encryption
# Send a text message (no file)
Download a file by token:
# Download to current directory
# Specify output path
# Decrypt downloaded file
Specify custom server:
Disk Image Utilities
Create a blank disk image:
# Create 64MB disk image
# Create with overwrite
Create GPT partition table:
# Create GPT from parameter.txt
# Skip confirmation
Format filesystem:
# Format partition as ext4
# Format with label
List files in disk image:
# List root directory
# List specific directory
Copy files (host ↔ image):
# Copy from host to image
# Copy from image to host
# Recursive copy
# Force overwrite
Move/rename files:
Remove files:
# Remove a file
# Remove directory recursively
# Force remove (ignore errors)
Create directory:
# Create directory
# Create parent directories
Display file content:
# Cat a file
# Read first N bytes
# Read from offset
Show disk info:
# Display disk and partition info
# JSON output
Configuration File
Generate a configuration file (.xtool.toml):
# Generate config in current directory
# Force overwrite existing config
The configuration file supports settings for:
- TFTP server (ip, port, read_only, single_port)
- TFTP client (server, port, block_size, timeout)
- Serial (uart, baud, net_port, net_bind)
Options
TFTP Server Options:
-i, --ip <IP>: IP address to bind (default: 0.0.0.0)-p, --port <PORT>: Port to listen on (default: 69)-r, --read-only: Enable read-only mode (disable writes)-s, --single-port: Use single port mode
TFTP Client Options:
-p, --port <PORT>: Server port (default: 69)-b, --block-size <SIZE>: Block size in bytes (default: 512, max: 65464)-t, --timeout <SECONDS>: Timeout in seconds (default: 5)
HTTP Server Options:
-p, --port <PORT>: Port to listen on (default: 80)-d, --path <PATH>: Root directory to serve (default: current directory)
Serial Options:
-b, --baud <RATE>: Baud rate (default: 115200)
Disk Options:
--disk <PATH>: Target disk image path (required for all disk commands)--part <ID|NAME>: Select partition by index or name
Examples
Running Tests
# Run all tests
# Run only integration tests
# Run with output
Example Session
TFTP:
Terminal 1 (Server):
Terminal 2 (Client):
HTTP Server:
Disk Image Operations:
# Create and format a disk image
# Copy files to image
License
Apache-2.0