nntp_proxy/protocol/
mod.rs1use anyhow::Result;
6use tokio::io::AsyncWriteExt;
7use tokio::net::TcpStream;
8use tracing::debug;
9
10mod article;
11mod commands;
12mod response;
13mod responses;
14
15pub use article::{Article, HeaderIter, Headers, ParseError, yenc};
17
18pub use response::{NntpResponse, StatusCode};
20
21pub use commands::{
23 DATE, QUIT, article_by_msgid, authinfo_pass, authinfo_user, body_by_msgid, head_by_msgid,
24 stat_by_msgid,
25};
26
27pub use responses::{
29 AUTH_ACCEPTED, AUTH_FAILED, AUTH_REQUIRED, AUTH_REQUIRED_FOR_COMMAND, BACKEND_ERROR,
30 BACKEND_UNAVAILABLE, COMMAND_NOT_SUPPORTED, COMMAND_NOT_SUPPORTED_STATELESS,
31 CONNECTION_CLOSING, CRLF, GOODBYE, MIN_RESPONSE_LENGTH, MULTILINE_TERMINATOR, NO_SUCH_ARTICLE,
32 PROXY_GREETING_PCR, TERMINATOR_TAIL_SIZE, error_response, greeting, greeting_readonly,
33 ok_response, response,
34};
35
36pub async fn send_proxy_greeting(
42 client_stream: &mut TcpStream,
43 client_addr: impl std::fmt::Display,
44) -> Result<()> {
45 let proxy_greeting = b"200 NNTP Proxy Ready\r\n";
46 client_stream.write_all(proxy_greeting).await?;
47 client_stream.flush().await?;
48 debug!("Sent and flushed proxy greeting to client {}", client_addr);
49 Ok(())
50}