nntp-proxy 0.1.0

High-performance NNTP proxy server with connection pooling and authentication
Documentation

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

  1. Clone the repository:
git clone <repository-url>
cd nntp-proxy
  1. Enter the development environment:
# If using direnv
direnv allow

# Or manually with nix
nix develop
  1. Build and run:
cargo build
cargo run

Configuration

The proxy uses a TOML configuration file (config.toml by default):

[[servers]]
host = "news.example.com"
port = 119
name = "Example News Server 1"
# Optional authentication
username = "your_username"
password = "your_password"
# Connection limit (defaults to 10 if not specified)
max_connections = 20

[[servers]]
host = "nntp.example.org"
port = 119
name = "Example News Server 2"
max_connections = 10

[[servers]]
host = "localhost"
port = 1119
name = "Local Test Server"
max_connections = 5

Configuration Fields

  • host - Backend server hostname
  • port - Backend server port (default: 119)
  • name - Friendly name for the server
  • username - Optional authentication username
  • password - Optional authentication password
  • max_connections - Maximum concurrent connections to this server (default: 10)

Usage

# Run with default settings (port 8119, config.toml)
cargo run

# Specify custom port and config
cargo run -- --port 8120 --config my-config.toml

# Show help
cargo run -- --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
telnet localhost 8119

# The connection will be forwarded to one of the configured backend servers
# in round-robin fashion

How it Works

  1. Client Connection: A client connects to the proxy on the configured port
  2. Server Selection: The proxy selects the next backend server using round-robin
  3. Backend Connection: The proxy establishes a connection to the selected backend
  4. Bidirectional Proxy: Data is forwarded in both directions between client and backend
  5. 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
cargo build --release

# The binary will be in target/release/nntp-proxy

License

MIT License - see LICENSE file for details.