A high-performance, type-safe implementation of LocalSend protocol (v2) in Rust. This project provides both a library and a feature-rich CLI/TUI for secure, local network file and text transfers.
- Protocol Compatibility: Full interoperability with official LocalSend clients (Android, iOS, Windows, macOS, Linux).
- Automatic Discovery: Multicast UDP discovery to find devices on your network instantly.
- Direct Send: Transfer files or text directly to an IP address for speed and reliability.
- HTTPS Security: TLS encryption for all transfers using protocol-compliant certificate fingerprinting.
- Text Messages: Support for sending and receiving instant text messages.
- CLI & TUI: Intuitive command-line interface with optional terminal-based UI.
- Streaming Transfers: Memory-efficient streaming for large files (no OOM on multi-gigabyte transfers).
- Async I/O: Non-blocking file operations for high concurrency.
- Type Safety: Strong typing throughout (
Protocol,SessionId,FileId,Token,Port) prevents bugs at compile time. - State Management: Type-safe state machine for transfer lifecycle.
- Well-Tested: 32+ unit tests covering core functionality.
Install CLI version:
cargo install localsend-rsInstall with interactive TUI:
cargo install localsend-rs --features tuiThen run with:
localsend-rs --help # CLI mode
localsend-rs tui # Launch TUI (if installed with --features tui)Ensure you have Rust and Cargo installed. Clone the repository and build from source:
git clone https://github.com/CrossCopy/localsend-rs.git
cd localsend-rs
# CLI + HTTPS (default)
cargo build --release
# With TUI support
cargo build --release --features tui
# All features (CLI + HTTPS + TUI)
cargo build --release --features allScan the local network for available LocalSend instances:
cargo run --features https -- discoverStart the receiver server (HTTPS is the default, matching the official app):
# Start receiving on default port (53317), HTTPS by default
cargo run --features https -- receive
# Use plain HTTP for interop/testing with HTTP-only peers
cargo run --features https -- receive --no-httpsSend a file to a device by its alias or IP:
# Send by alias
cargo run --features https -- send "My Phone" ./photos/vacation.jpg
# Send by IP address (bypasses discovery); host:port for a non-default port
cargo run --features https -- send 192.168.1.50 ./documents/report.pdf
cargo run --features https -- send 192.168.1.50:53318 ./documents/report.pdfYou can send plain text instead of files by providing a string that isn't a file path:
cargo run --features https -- send "ROG16" "Hello from Rust CLI!"For an interactive terminal-based UI:
cargo run --features all -- tuiFind devices on the local network.
--timeout <SECS>: Search duration (default: 10s).--json: Output discovered devices in JSON format.
Start a LocalSend server to accept incoming transfers.
--port <PORT>: Custom port (default: 53317).--no-https: Use plain HTTP instead of the default HTTPS.--alias <NAME>: Custom device name shown to others.--directory <PATH>: Save directory for received files (default:./downloads).
Send data to another device.
<TARGET>: Device alias, hostname, or IP address.<FILES...>: One or more file paths or text strings.--pin <PIN>: Optional PIN for protected transfers.
Launch the interactive terminal-based UI for file transfers.
--port <PORT>: Custom port (default: 53317).--no-https: Use plain HTTP instead of the default HTTPS.--alias <NAME>: Custom device name shown to others.--pin <PIN>: Require this PIN from senders before a transfer is offered.--auto-accept: Accept every incoming transfer without prompting.
# With all features enabled (HTTPS by default)
cargo run --features all -- tuiThe TUI supports:
- Inbox β arrow keys select a received item,
Enterreveals it in the OS file manager; text messages show aπ¬preview inline. - Incoming transfer dialog β
β/βmove,Spacetoggles a file,atoggles all,Enteraccepts the selected subset,yaccepts all,n/Escdeclines. - Settings β
Spacetoggles auto-accept live (applies to the next request). - Sending to a PIN-protected peer β a
401prompts for the PIN and retries.
The codebase is organized into clean, domain-driven modules:
src/
βββ core/ # Core domain logic
β βββ builders.rs # Builder patterns (DeviceInfoBuilder)
β βββ device.rs # Device operations
β βββ file.rs # File operations
β βββ session.rs # Session management
β βββ transfer.rs # Transfer state machine
βββ crypto/ # Cryptography (modularized)
β βββ fingerprint.rs # Device fingerprinting
β βββ hash.rs # SHA-256 hashing
β βββ tls.rs # TLS certificate generation
βββ storage/ # Storage abstraction
β βββ traits.rs # FileSystem trait
β βββ tokio_fs.rs # Default implementation
βββ discovery/ # Multicast UDP & HTTP discovery
βββ server/ # Axum HTTP/HTTPS server
βββ client/ # Request-based client
βββ protocol/ # Protocol types & validation
β βββ types.rs # Strong types (SessionId, FileId, etc.)
β βββ validation.rs # Protocol validation
βββ cli/ # Command-line interface
βββ tui/ # Terminal UI
βββ error.rs # Structured error handling
βββ prelude.rs # Convenience exports
- Newtype Pattern: Strong typing for protocol identifiers (
SessionId,FileId,Token,Port) - State Machine: Type-safe transfer lifecycle management
- Builder Pattern: Fluent API for constructing
DeviceInfo - Strategy Pattern: Pluggable
FileSystemimplementations for testing - Storage Abstraction:
FileSystemtrait enables mocking and alternative backends
| Feature | Default | Description |
|---|---|---|
cli |
β | Command-line interface (clap-based) |
https |
β | TLS/SSL support for secure transfers |
tui |
β | Interactive terminal UI (ratatui-based) |
all |
β | Enable all features (cli + https + tui) |
# Default (cli + https)
cargo build
# CLI + HTTPS + TUI
cargo build --features all
# Development with all features
cargo build --release --features allThis project is under active development with focus on performance and type safety.
- Discovery (Multicast UDP)
- Receiving (HTTPS/HTTP) with streaming
- Sending Files with streaming uploads
- Sending Text
- TUI (Terminal UI)
- Type-safe protocol types
- State machine for transfer lifecycle
- Builder patterns for ergonomic API
- Storage abstraction for testability
- Streaming download support
- Integration test suite
- Progress callbacks for transfers
- Resume interrupted transfers
- Direct Download (v3 feature)
- Connection pooling
- Parallel chunk uploads
- Checksum validation during streaming
- Streaming Uploads: O(8KB buffer) instead of O(file_size) - can transfer multi-GB files with <100MB RAM
- Async I/O: Non-blocking operations enable high concurrency (100+ simultaneous transfers)
- Lock Optimization:
tokio::sync::RwLockfor server, non-blockingtry_read()for TUI
- Compile-time Guarantees: Newtypes prevent mixing up session IDs, file IDs, tokens, etc.
- Protocol Validation: Version and device info validated at API boundaries
- Error Context: Structured errors with relevant context for debugging
# Run all tests
cargo test
# Run tests with specific features
cargo test --features all
# Run clippy for code quality
cargo clippy --all-features
# Check formatting
cargo fmt --checkcargo testβ unit + conformance + in-process interop suites (no Docker needed)../e2e/run.shβ containerized senderβreceiver e2e over the compose network (requires Docker).
This is a CrossCopy project - a high-performance Rust implementation of the LocalSend protocol for fast, secure local network file transfers.
MIT License - see LICENSE for details.
