pub enum NntpCommand {
AuthUser,
AuthPass,
Stateful,
NonRoutable,
Stateless,
ArticleByMessageId,
}Expand description
NNTP command classification for routing and handling strategy
This enum determines how commands are processed by the proxy based on their semantics and state requirements per RFC 3977.
§Classification Categories
-
ArticleByMessageId: High-throughput binary retrieval (can be multiplexed)
- Commands: ARTICLE/BODY/HEAD/STAT with message-ID argument
- Per RFC 3977 §6.2
- 70%+ of NZB download traffic
-
Stateful: Requires session state (GROUP context, article numbers)
- Commands: GROUP, ARTICLE/BODY/HEAD/STAT by number, NEXT, LAST, XOVER, etc.
- Per RFC 3977 §6.1
- Requires dedicated backend connection with maintained state
-
NonRoutable: Cannot be safely proxied (POST, IHAVE, etc.)
- Commands: POST, IHAVE, NEWGROUPS, NEWNEWS
- Per RFC 3977 §6.3
- Typically rejected or require special handling
-
Stateless: Can be proxied without state
- Commands: LIST, DATE, CAPABILITIES, HELP, QUIT, etc.
- Per RFC 3977 §7
- Safe to execute on any backend connection
-
AuthUser/AuthPass: Authentication (intercepted by proxy)
- Commands: AUTHINFO USER, AUTHINFO PASS
- Per RFC 4643 §2.3
- Handled by proxy authentication layer
Variants§
AuthUser
Authentication: AUTHINFO USER RFC 4643 §2.3.1
AuthPass
Authentication: AUTHINFO PASS RFC 4643 §2.3.2
Stateful
Commands requiring GROUP context: article-by-number, NEXT, LAST, XOVER, etc. RFC 3977 §6.1
NonRoutable
Commands that cannot work with multiplexing: POST, IHAVE, NEWGROUPS, NEWNEWS RFC 3977 §6.3, RFC 3977 §7.3-7.4
Stateless
Safe to proxy without state: LIST, DATE, CAPABILITIES, HELP, QUIT, etc. RFC 3977 §7
ArticleByMessageId
Article retrieval by message-ID: ARTICLE/BODY/HEAD/STAT
Implementations§
Source§impl NntpCommand
impl NntpCommand
Sourcepub const fn is_stateful(&self) -> bool
pub const fn is_stateful(&self) -> bool
Check if this command requires stateful session (for hybrid routing mode)
Returns true if the command requires a dedicated backend connection with maintained state (e.g., GROUP, XOVER, article-by-number).
Sourcepub fn classify(command: &str) -> Self
pub fn classify(command: &str) -> Self
Classify an NNTP command for routing/handling strategy
Analyzes the command string and returns the appropriate classification for proxy routing decisions.
§Performance Characteristics (40Gbit optimization)
- Hot path (70%+ traffic): 4-6ns - ARTICLE/BODY/HEAD/STAT by message-ID
- Zero allocations: Direct byte comparisons only
- Branch predictor friendly: Most common commands checked first
§Traffic Distribution (typical NZB download workload)
- 70%: ARTICLE/BODY/HEAD/STAT by message-ID →
ArticleByMessageId - 10%: GROUP →
Stateful - 5%: XOVER/OVER →
Stateful - 5%: LIST/DATE/CAPABILITIES →
Stateless - 5%: AUTHINFO →
AuthUser/AuthPass - <5%: Everything else
§Algorithm
- Ultra-fast path: Check for article-by-message-ID in one pass (70%+ hit rate)
- Per RFC 3977 §6.2
- Parse command: Split on first space per RFC 3977 §3.1
- Frequency-ordered matching: Check common commands before rare ones
§Case Insensitivity
Per RFC 3977 §3.1, commands are case-insensitive. We match against pre-computed literal variations (UPPER/lower/Title) for maximum performance.