Skip to main content

osproxy_transport/
lib.rs

1//! Transport layer: bytes on and off the wire.
2//!
3//! Owns protocol framing and, in a later slice, TLS termination behind the
4//! `CryptoProvider` seam (`docs/07`) and pooled upstream connections (`docs/04`
5//! ยง7). It knows nothing about routing decisions or tenancy semantics.
6//!
7//! M1 implements the HTTP/1.1 cleartext **ingress**: [`serve`] accepts
8//! connections, parses each request into an owned [`IngressRequest`] (with its
9//! [`EndpointKind`](osproxy_core::EndpointKind) classified by [`classify()`]),
10//! invokes an [`IngressHandler`], and writes the [`IngressResponse`]. The handler,
11//! implemented by the binary, is where the request meets the engine pipeline.
12#![deny(missing_docs)]
13
14// Exactly one crypto provider is compiled in, chosen at build time (ADR-009).
15// `non-fips` is the default; a FIPS release builds `--no-default-features
16// --features fips`. Catch a mis-invocation at compile time rather than silently
17// linking both (or neither) crypto module.
18#[cfg(all(feature = "fips", feature = "non-fips"))]
19compile_error!(
20    "features `fips` and `non-fips` are mutually exclusive; a FIPS artifact must \
21     not link a non-validated crypto module; build with `--no-default-features \
22     --features fips`"
23);
24#[cfg(not(any(feature = "fips", feature = "non-fips")))]
25compile_error!("enable exactly one crypto provider feature: `fips` or `non-fips`");
26
27mod admission;
28mod classify;
29mod grpc;
30mod handler;
31mod http_io;
32mod request;
33mod server;
34mod tls;
35
36pub use admission::IngressLimits;
37pub use classify::{classify, Classified};
38pub use grpc::{serve_grpc, serve_grpc_tls};
39pub use handler::IngressHandler;
40/// The streamed request body type for [`IngressHandler::handle_forward`],
41/// re-exported so handlers can name it without depending on `hyper` directly.
42pub use hyper::body::Incoming;
43pub use request::{
44    buffered_response, IngressRequest, IngressResponse, ResponseBody, StreamingResponse,
45};
46pub use server::{
47    serve, serve_tls, serve_tls_with_limits, serve_tls_with_shutdown, serve_with_limits,
48    serve_with_shutdown, DRAIN_DEADLINE,
49};
50pub use tls::{CryptoProvider, TlsError, FIPS_APPROVED_SUITES};
51
52#[cfg(feature = "fips")]
53pub use tls::AwsLcFipsProvider;
54#[cfg(feature = "non-fips")]
55pub use tls::RingProvider;
56
57/// The crypto provider the active build selected: `RingProvider` under
58/// `non-fips`, `AwsLcFipsProvider` under `fips`. Server/wiring code names this
59/// alias so it never hard-codes a concrete provider or branches on the feature.
60#[cfg(feature = "non-fips")]
61pub type DefaultCryptoProvider = tls::RingProvider;
62/// The crypto provider the active build selected (see the `non-fips` variant).
63#[cfg(feature = "fips")]
64pub type DefaultCryptoProvider = tls::AwsLcFipsProvider;