trojan-rs
A high-performance Rust implementation of the Trojan protocol.
Features
- High Performance - Built with async Rust and Tokio for maximum throughput
- TLS 1.3 Support - Modern encryption with configurable TLS versions
- WebSocket Transport - Optional WebSocket encapsulation for CDN compatibility
- Multiple Auth Backends - Memory, SQLite, PostgreSQL, and MySQL support
- User Management - Full CLI for managing users with traffic limits
- Prometheus Metrics - Built-in metrics exporter for monitoring
- Rate Limiting - Per-IP connection rate limiting
- Fallback Server - Configurable fallback for non-Trojan traffic
- Self-Upgrade - Auto-update from GitHub releases (optional feature)
- Cross-Platform - Linux, macOS, and Windows support
Installation
Pre-built Binaries
Download from GitHub Releases.
Cargo
From Source
Usage
Server
# Run with config file
# Run with CLI options
User Management (SQL Backend)
# Initialize database
# Add user
# List users
# Remove user
Configuration
Create a config.toml file:
[]
= "0.0.0.0:443"
= "127.0.0.1:80"
= 600
= 60
[]
= "/etc/trojan/cert.pem"
= "/etc/trojan/key.pem"
= ["http/1.1"]
[]
= ["password1", "password2"]
[]
= "127.0.0.1:9100"
[]
= "info"
JSON and YAML formats are also supported.
Supported Platforms
| Platform | Architecture |
|---|---|
| Linux | x86_64, aarch64, armv7, i686 |
| Linux (musl) | x86_64, aarch64, armv7, i686 |
| macOS | x86_64, aarch64 (Apple Silicon) |
| Windows | x86_64 |
Crates
| Crate | Description |
|---|---|
trojan-core |
Core types and utilities |
trojan-proto |
Protocol encoding/decoding |
trojan-auth |
Authentication backends |
trojan-config |
Configuration parsing |
trojan-metrics |
Prometheus metrics |
trojan-analytics |
Connection tracking |
trojan-server |
Server implementation |
License
GPL-3.0-only