Protocol-specific request parsing, relay, and deny logic. Generic over the stream type to support both plaintext and TLS connections.
| 64 | /// |
| 65 | /// Generic over the stream type to support both plaintext and TLS connections. |
| 66 | pub trait L7Provider: Send + Sync { |
| 67 | /// Parse one request from the client stream. |
| 68 | /// |
| 69 | /// Returns `Ok(Some(request))` if a request was parsed, |
| 70 | /// `Ok(None)` if the client closed the connection cleanly, |
| 71 | /// `Err` on parse error or protocol violation. |
| 72 | fn parse_request<C: AsyncRead + AsyncWrite + Unpin + Send>( |
| 73 | &self, |
| 74 | client: &mut C, |
| 75 | ) -> impl Future<Output = Result<Option<L7Request>>> + Send; |
| 76 | |
| 77 | /// Forward an allowed request to upstream and relay the response back. |
| 78 | /// |
| 79 | /// Returns a [`RelayOutcome`] indicating whether the connection is |
| 80 | /// reusable (keep-alive), consumed, or has been upgraded (101 Switching |
| 81 | /// Protocols) and must be relayed as raw bidirectional TCP. |
| 82 | fn relay<C, U>( |
| 83 | &self, |
| 84 | req: &L7Request, |
| 85 | client: &mut C, |
| 86 | upstream: &mut U, |
| 87 | ) -> impl Future<Output = Result<RelayOutcome>> + Send |
| 88 | where |
| 89 | C: AsyncRead + AsyncWrite + Unpin + Send, |
| 90 | U: AsyncRead + AsyncWrite + Unpin + Send; |
| 91 | |
| 92 | /// Send a protocol-appropriate deny response to the client. |
| 93 | fn deny<C: AsyncRead + AsyncWrite + Unpin + Send>( |
| 94 | &self, |
| 95 | req: &L7Request, |
| 96 | policy_name: &str, |
| 97 | reason: &str, |
| 98 | client: &mut C, |
| 99 | ) -> impl Future<Output = Result<()>> + Send; |
| 100 | } |
nothing calls this directly
no outgoing calls
no test coverage detected