NNTP Proxy
A high-performance round-robin NNTP proxy server written in Rust.
Features
- 🔄 Round-robin load balancing - Distributes connections evenly across backend servers
- ⚡ Async/await - Built on Tokio for high concurrency
- 📝 TOML Configuration - Simple and readable configuration format
- 🔍 Structured logging - Detailed logging with tracing
- 🛠️ Nix development environment - Reproducible development setup
- 📊 Connection tracking - Logs client connections and backend routing
Quick Start
Prerequisites
- Nix with flakes enabled
- direnv (optional but recommended)
Development Setup
- Clone the repository:
- Enter the development environment:
# If using direnv
# Or manually with nix
- Build and run:
Configuration
The proxy uses a TOML configuration file (config.toml by default):
[[]]
= "news.example.com"
= 119
= "Example News Server 1"
# Optional authentication
= "your_username"
= "your_password"
# Connection limit (defaults to 10 if not specified)
= 20
[[]]
= "nntp.example.org"
= 119
= "Example News Server 2"
= 10
[[]]
= "localhost"
= 1119
= "Local Test Server"
= 5
Configuration Fields
host- Backend server hostnameport- Backend server port (default: 119)name- Friendly name for the serverusername- Optional authentication usernamepassword- Optional authentication passwordmax_connections- Maximum concurrent connections to this server (default: 10)
Usage
# Run with default settings (port 8119, config.toml)
# Specify custom port and config
# Show help
Command Line Options
-p, --port <PORT>- Port to listen on (default: 8119)-c, --config <CONFIG>- Configuration file path (default: config.toml)-h, --help- Print help information-V, --version- Print version information
Testing
To test the proxy, you can use telnet to connect:
# Connect to the proxy
# The connection will be forwarded to one of the configured backend servers
# in round-robin fashion
How it Works
- Client Connection: A client connects to the proxy on the configured port
- Server Selection: The proxy selects the next backend server using round-robin
- Backend Connection: The proxy establishes a connection to the selected backend
- Bidirectional Proxy: Data is forwarded in both directions between client and backend
- Connection Cleanup: When either side closes, both connections are cleaned up
Architecture
The proxy is built with:
- Tokio: Async runtime for handling many concurrent connections
- Tracing: Structured logging for observability
- Clap: Command-line argument parsing
- Serde + TOML: Configuration file handling
- Anyhow: Error handling
Building for Production
# Build optimized release version
# The binary will be in target/release/nntp-proxy
License
MIT License - see LICENSE file for details.