trojan-auth
Authentication backends for trojan-rs with support for in-memory passwords and SQL databases.
Overview
This crate provides pluggable authentication for the Trojan protocol:
- Memory backend — Fast in-memory hash set, suitable for static password lists
- SQL backend — PostgreSQL, MySQL, and SQLite via sqlx, with traffic accounting and user management CLI
- Reloadable auth — Hot-reload passwords on SIGHUP without restarting the server
Usage
use ;
// Create backend from plaintext passwords
let auth = from_passwords;
// Verify a connection
let hash = sha224_hex;
let result = auth.verify.await?;
println!;
SQL Backend
# Initialize database schema
# Add a user with traffic limits
# List all users
Features
| Feature | Description |
|---|---|
sql-sqlite |
SQLite authentication backend |
sql-postgres |
PostgreSQL authentication backend |
sql-mysql |
MySQL authentication backend |
cli |
User management CLI subcommand |
License
GPL-3.0-only