nntp_proxy/protocol/
mod.rs1use anyhow::Result;
6use std::net::SocketAddr;
7use tokio::io::AsyncWriteExt;
8use tokio::net::TcpStream;
9use tracing::debug;
10
11mod commands;
12mod response;
13mod responses;
14
15pub use response::ResponseParser;
16
17#[allow(unused_imports)]
19pub use response::{NntpResponse, ResponseCode};
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_REQUIRED, BACKEND_ERROR, BACKEND_UNAVAILABLE, COMMAND_NOT_SUPPORTED,
30 COMMAND_NOT_SUPPORTED_STATELESS, CONNECTION_CLOSING, CRLF, GOODBYE, MIN_RESPONSE_LENGTH,
31 MULTILINE_TERMINATOR, PROXY_GREETING_PCR, TERMINATOR_TAIL_SIZE, error_response, greeting,
32 greeting_readonly, ok_response, response,
33};
34
35pub async fn send_proxy_greeting(
39 client_stream: &mut TcpStream,
40 client_addr: SocketAddr,
41) -> Result<()> {
42 let proxy_greeting = b"200 NNTP Proxy Ready\r\n";
43 client_stream.write_all(proxy_greeting).await?;
44 debug!("Sent proxy greeting to client {}", client_addr);
45 Ok(())
46}