fix(app): add read, write and idle timeouts to the HTTP servers

- the API + admin UI server and the public web server get ReadTimeout 30s,
  WriteTimeout 60s and IdleTimeout 120s next to ReadHeaderTimeout
- the archive import extends its own read and write deadlines to 30
  minutes with http.ResponseController, so a big mbox is not cut
- tests: a stalled body and an idle connection are cut on both servers,
  an import longer than the default timeouts succeeds, fields are pinned
- README: document the limits and timeouts
This commit is contained in:
tgiachi 2026-11-10 11:54:50 +01:00
commit 38552f8025

View file

@ -253,6 +253,12 @@ lists.example.org lmtp:inet:127.0.0.1:2424
full queue answers `452` (the sender retries later), a message over 10 MiB `552`. Messages nobody moderated for 30 days
are dropped. Listings (API, CLI, UI) show a summary and never read the bodies. The held view shows the From header
readers would see next to the real sender and flags a difference.
- **Hostile messages and slow clients.** The archive reads at most 10 levels of nested multipart and 100 parts per
message, then uses what it found (the post is still delivered). A `Date` header more than 24 hours ahead is replaced
by the arrival time, and one before 1990 is ignored, so a message cannot pin itself to the top of the archive. The
HTTP servers (API + admin UI, and the public web) cut a request that takes more than 30 s to read, a response that
takes more than 60 s to write, and a connection idle for 120 s; the archive import is the exception and may stream
for up to 30 minutes.
- **API token.** `parsimony serve` refuses a token shorter than 24 characters or containing whitespace
(`openssl rand -hex 24` makes a good one). After 10 wrong or missing tokens within 5 minutes an address is
locked out for 5 minutes (HTTP 429, valid token included). The address is the TCP peer: behind a reverse proxy