serve-net 0.7.1

The network service engine for Rust: listeners over net-io, ingress from direct clients, reverse proxies (PROXY protocol or trusted forwarded headers), Unix sockets, and FastCGI, a per-connection engine with a slot for any sans-IO protocol engine, admission, drain, and restarts without dropped connections.
Documentation

Quick start

[dependencies]
serve-net = "0.7"
fn main() -> Result<(), serve_net::ServeError> {
    // A web server with every default limit and defence applied.
    let server = serve_net::http("127.0.0.1:8080", |req, reply| {
        reply.text(200, &format!("hello from {}", req.path()));
    })?;
    server.wait(); // runs until a drain is requested
    Ok(())
}

Behind Apache or nginx on the same host, with the real client taken from X-Forwarded-For only when the connection comes from the proxy:

let server = serve_net::http_behind_proxy("127.0.0.1:8080", "127.0.0.1, ::1", |req, reply| {
    reply.text(200, &format!("you are {:?}", req.client().addr()));
})?;

Several listeners, profiles, limits, a connection gate, a control line, and custom protocols go through Server::builder().

Scope

  • Listeners over net-io: TCP and Unix sockets, inherited from systemd, passed by mod_fcgid on descriptor 0, or handed over by a supervisor for restarts without a closed port.
  • Ingress: direct (plain or TLS through net-io's seam), behind a reverse proxy (PROXY protocol v1 and v2, or trusted Forwarded / X-Forwarded-For with a right-to-left walk and a hop limit), over a Unix socket, or as a FastCGI responder. Every HTTP ingress gives the service the same request and the same client facts.
  • Per connection: head and request deadlines, minimum transfer rates, keep-alive with request and age limits, pipelining in order, generic refusals that never name the reason, the switch to WebSocket after an upgrade (h2c is never honoured).
  • Admission: soft connection caps answered with 503 and a jittered Retry-After, an in-flight cap per worker and per profile after the head is complete, priority lanes with reserved capacity, and a process-wide control line (shed, lockdown, drain, stop).
  • Hooks: admission, dispatch (offload slow work), revocation checkpoints, observation, readiness (systemd sd_notify in safe code), plus net-io's gate and event sink.
  • Start-up safety: every configuration error reported at once; a proxy or FastCGI listener on a public address, or a trust list that is too broad, is refused unless the override names its reason.

It is not a web framework (no routing, middleware, or templates), not a transport (net-io is), not a protocol parser (the engines are), and not a TLS implementation (tls-net is). There is no CGI mode: services run as persistent processes, and FastCGI covers shared hosting.

See dev/PLAN.md for the full scope, what is left to other crates, and the decision log.

Contributing

See dev/DIRECTIVES.md for engineering standards and the definition of done. Before a PR: cargo fmt --all, cargo clippy --all-targets --all-features -- -D warnings, and cargo test --all-features must be clean.