nntp_proxy/lib.rs
1//! # NNTP Proxy Library
2//!
3//! A high-performance NNTP proxy server implementation with two operating modes:
4//! 1:1 mode (one backend per client) and per-command routing mode.
5//!
6//! ## Architecture
7//!
8//! The proxy is organized into several modules for clean separation of concerns:
9//!
10//! - **auth**: Authentication handling for both client and backend connections
11//! - **command**: NNTP command parsing and classification
12//! - **config**: Configuration loading and management
13//! - **pool**: Connection and buffer pooling for high performance
14//! - **protocol**: NNTP protocol constants and response parsing
15//! - **proxy**: Main proxy orchestration (`NntpProxy` struct)
16//! - **router**: Backend selection and load balancing
17//! - **types**: Core type definitions (`ClientId`, `RequestId`, `BackendId`)
18//!
19//! ## Design Philosophy
20//!
21//! This proxy operates in **stateless mode**, rejecting commands that require
22//! maintaining session state (like GROUP, NEXT, LAST). This design enables:
23//!
24//! - Simpler architecture with clear separation of concerns
25//! - Per-command routing mode where each command can use a different backend
26//! - Easy testing and maintenance of individual components
27//!
28//! ## Operating Modes
29//!
30//! - **1:1 mode**: Traditional mode where each client gets a dedicated backend connection
31//! - **Per-command routing mode**: Each command is routed to a backend (round-robin),
32//! but commands are still processed serially (NNTP is synchronous)
33
34// Module declarations
35pub mod args;
36pub mod auth;
37pub mod client;
38pub mod connection_error;
39pub mod formatting;
40pub mod logging;
41pub mod metrics;
42pub mod network;
43pub mod protocol;
44mod proxy;
45pub mod stream;
46pub mod tui;
47
48// Public modules for integration tests
49pub mod cache;
50pub mod command;
51pub mod config;
52pub mod constants;
53pub mod pool;
54pub mod router;
55pub mod runtime;
56pub mod session;
57pub mod tls;
58pub mod types;
59
60// Public exports
61pub use args::{CacheArgs, CommonArgs};
62pub use config::{
63 Cache, Config, ConfigSource, RoutingMode, Server, create_default_config, has_server_env_vars,
64 load_config, load_config_from_env, load_config_with_fallback,
65};
66pub use proxy::{NntpProxy, NntpProxyBuilder, is_client_disconnect_error};
67pub use runtime::{RuntimeConfig, shutdown_signal};
68
69// Re-export streaming utilities for standalone client use
70pub mod streaming {
71 //! Streaming utilities for reading NNTP multiline responses
72 //!
73 //! These are useful when building standalone NNTP clients that need to
74 //! fetch articles directly from servers.
75 pub use crate::session::streaming::{
76 stream_and_capture_multiline_response, stream_multiline_response,
77 };
78}
79
80// Re-export backend command utilities for standalone client use
81pub mod backend {
82 //! Backend communication utilities for NNTP client operations
83 //!
84 //! Use these when building standalone NNTP clients.
85 pub use crate::session::backend::{CommandResponse, send_command};
86}