15 Commits

Author SHA1 Message Date
mnovak 67888aa791 [docs] Roadmap: T4 status and handover 2026-11-17 22:16:50 +01:00
mnovak 6956f23cb2 [tests] Caddy mode: a minute for Caddy to start on a busy machine 2026-11-17 21:42:52 +01:00
mnovak 2aa8d66127 [control] The admin host is accepted with any port (Docker or a router may publish 443 elsewhere); smoke scripts: Windows-readable paths, curl without Schannel's revocation check, logs on failure 2026-11-17 21:35:34 +01:00
mnovak 695ed178a5 [control] Clippy clean for the T4 code; CLAUDE.md: the deploy folders and the Linux test command in Docker; the Docker smoke turns off Git Bash's path rewriting and removes its volume 2026-11-17 21:18:19 +01:00
mnovak defd722cc2 [docs] Previews (the API for Fabrica, names, the token from the team vault), Ianitor anywhere (Linux, Docker, Windows Server in Caddy mode, NixOS), team sign-in in api.md, the Custos ticket's T4 part; release 0.2.0: the pipeline builds and tests the Linux tarball, the Windows zip and the image; the NixOS previews option; Docker and Linux smoke scripts 2026-11-17 20:59:42 +01:00
mnovak d5d522fe4b [deploy] Fixes from the Windows smoke: the admin host has no health path (every API path needs a sign-in), -NoService keeps the person who ran it in the folder's ACL, paths may have backslashes; Pebble 2.6.0 in the CI image (the ACME test's version) 2026-11-17 20:55:41 +01:00
mnovak 49c05e2523 [deploy] Anywhere: the Docker image and compose file (edge and control), the Linux installer and systemd units, the Windows Server installer (Caddy mode, three services), the preview client for Fabrica, and the Windows smoke script 2026-11-17 20:42:04 +01:00
mnovak 09f6b12676 [tests] Linux-only tests follow the Caddy admin address type and the [previews] config field 2026-11-17 20:42:01 +01:00
mnovak 4e3c721ef5 [web] Previews and the team: a Previews screen (see: 1 click, close: 2), sign-in from a setup or invite link, Settings → Team (invite: 3 clicks), previews-only API tokens; click-counted tests 2026-11-17 20:41:53 +01:00
mnovak dced199132 [control] Team sign-in without Authelia: a one-time setup link for the first admin, invite links, per-browser sessions in an HttpOnly cookie, admin and member roles, Tessera roots with their match code; the admin host kept by control ([ui] admin_tls) 2026-11-17 20:28:12 +01:00
mnovak 51a95e4f75 [control] Caddy mode, tests: a previews-only token opens a branch preview that answers through Caddy (admin on loopback TCP, Domi certificate, no edge) and is gone after close; runs on Windows 2026-11-17 14:03:52 +01:00
mnovak 5e273241e4 [tests] Diff: the differential suite runs on Windows too (Windows Caddy, drive paths), with two branch previews in the fixtures; edge leaves a websocket 101 as the upstream sent it, as Caddy does 2026-11-17 13:59:18 +01:00
mnovak acf69a8ed2 [control] Windows Caddy mode: Caddy's admin API on loopback TCP where there is no Unix socket, applies go through Caddy without an edge, control and the Caddy guard as Windows services, a log file 2026-11-17 13:59:12 +01:00
mnovak fc9e16f1b2 [control] Previews: POST/GET/DELETE /api/v1/previews, tokens scoped to previews only, the upstream allow list, expiry; Windows drive paths in compile options (tests first) 2026-11-17 13:46:33 +01:00
mnovak 83270e0746 [core] Previews: branch and project names to one safe host label, and the [preview] table of a host file (tests first) 2026-11-17 13:29:35 +01:00
205 changed files with 6429 additions and 14733 deletions
+9
View File
@@ -0,0 +1,9 @@
target
**/node_modules
**/dist
.git
.fabrica
bench
*.log
result
result-*
-39
View File
@@ -1,39 +0,0 @@
# Ianitor Domi: the five test layers (ROADMAP §5) on a push to main, or by hand. Layer 1 (the differential
# suite against Caddy) runs inside the workspace tests; layer 2 is scripts/conformance.sh (h2spec, testssl.sh);
# layer 3 tests/fuzz/run.sh (cargo-fuzz, 2 minutes a target; any crash fails); layer 4 the NixOS VM tests;
# layer 5 scripts/bench.sh (load and a 5-minute soak against Caddy; results kept as artifacts).
# Runner: label `nixos`, on a host with /dev/kvm and Nix's `kvm` system feature (the VM tests; on Hyper-V,
# nested virtualisation on), outbound HTTPS (crates.io, cache.nixos.org) and about 20 GB free. Every tool comes
# from the flake's `ci` shell, so the runner needs only Nix with flakes.
name: layers
on:
push: [main]
manual: true
runner: nixos
env:
CARGO_TERM_COLOR: "never"
CARGO_BUILD_JOBS: "8"
steps:
- id: workspace-tests
run: nix --extra-experimental-features "nix-command flakes" develop .#ci -c cargo test --workspace --no-fail-fast
- id: conformance
needs: [workspace-tests]
run: nix --extra-experimental-features "nix-command flakes" develop .#ci -c scripts/conformance.sh
artifacts: ["bench/conformance/*"]
- id: fuzz
needs: [workspace-tests]
run: nix --extra-experimental-features "nix-command flakes" develop .#ci -c tests/fuzz/run.sh 120
- id: vm-apply-reverts
nix: .#checks.x86_64-linux.vm-apply-reverts
- id: vm-engine-switch
nix: .#checks.x86_64-linux.vm-engine-switch
- id: vm-intermediate-renewal
nix: .#checks.x86_64-linux.vm-intermediate-renewal
- id: vm-control-loopback
nix: .#checks.x86_64-linux.vm-control-loopback
- id: vm-sockets
nix: .#checks.x86_64-linux.vm-sockets
- id: load
needs: [conformance, fuzz]
run: nix --extra-experimental-features "nix-command flakes" develop .#ci -c scripts/bench.sh fabrica-runner
artifacts: ["bench/results/**"]
+32 -15
View File
@@ -1,15 +1,13 @@
# Ianitor Domi: the Gitea release of a v* tag (docs/release.md). Ianitor ships no binary (the server builds it with
# Nix and the deploy pipeline switches it in), so a release is its notes and screenshots of the web UI, published under
# a SHA256SUMS signed by domi-release through Custos; release-notes.md is also the release's text on Gitea.
# The Windows runner (the Fabrica app on Mark's PC) runs it: `fabrica`, node and pnpm are on every step's PATH.
# Ianitor Domi: the Gitea release of a v* tag (docs/release.md). Since 0.2.0 (T4) a release carries the programs:
# the Linux tarball and its one-line installer (systemd), the Windows Server zip (Caddy mode), next to the notes and
# screenshots of the web UI, all under a SHA256SUMS signed by domi-release through Custos. The Docker image is built
# from the same Dockerfile; it is not pushed to a registry yet (docs/deploy/anywhere.md).
# The Windows runner (the Fabrica app on Mark's PC) runs it: `fabrica`, node, pnpm, cargo and Docker Desktop are on
# every step's PATH; the Linux parts build inside Docker (deploy/docker/Dockerfile), never on the host.
# No Gitea webhook to the hub yet: a pushed tag is started on demand (the hub's POST /api/runs, ref v<version>).
# `notes` is Fabrica's release notes since the previous v* tag (Fabrica docs/12_release_kit.md); `shots` takes the
# same files as `fabrica aula shots` (core docs/FORMATS.md, "Fabrica: the Aula page") from the built web UI against
# the demo control plane with invented data, in headless Edge. No landing page while app.yaml has no `aula: true`.
# `pin` publishes the Nix build's NAR hashes (.fabrica/nix/pin.json, written by scripts/nix-pin.sh on Linux at a
# clean commit and committed before the tag) as ianitor-nix.json, and refuses a pin made from other code than the
# tag's (its recorded source tree must be the tag's); that check is the gate, since pipelines cannot depend on one
# another. The `verify-nix` pipeline rebuilds the tag on the NixOS runner and compares (docs/verify.md).
name: release
on:
tag: "v*"
@@ -26,6 +24,27 @@ steps:
- id: test
needs: [install]
run: pnpm --filter web test
# The whole Rust workspace on Linux (the differential suite against Caddy, Pebble ACME, the edge suites), in the CI
# image; two jobs, so Docker Desktop's memory holds.
- id: linux-tests
needs: [version]
run: docker build --load -f deploy/docker/Dockerfile --target ci -t ianitor-ci:${{ version }} . && docker run --rm --memory 6g ianitor-ci:${{ version }} cargo test --workspace --locked -j 2
# Windows: the Caddy-mode tests and the differential suite with Windows paths (Pingora against Windows Caddy;
# IANITOR_CADDY_BIN names caddy.exe on the runner).
- id: windows-tests
needs: [version]
run: cargo test --workspace --locked
- id: windows
needs: [check, test, windows-tests]
run: cargo build --release --locked -p ianitor-control --no-default-features && pnpm --filter web build && node scripts/package-windows.mjs
artifacts: ["target/dist/ianitor-*-windows-x86_64.zip"]
- id: linux
needs: [linux-tests]
run: docker build -f deploy/docker/Dockerfile --target dist --output type=local,dest=target/dist .
artifacts: ["target/dist/ianitor-*-linux-x86_64.tar.gz", "target/dist/install.sh"]
- id: image
needs: [linux-tests]
run: docker build --load -f deploy/docker/Dockerfile -t ianitor:${{ version }} .
- id: notes
run: fabrica notes
artifacts: ["target/notes/release-notes.md", "target/notes/release-notes.json"]
@@ -33,21 +52,19 @@ steps:
needs: [check, test]
run: node apps/web/scripts/shots.mjs
artifacts: ["target/aula/aula-*.png", "target/aula/aula.json"]
- id: pin
needs: [version]
run: node scripts/release-pin.mjs ${{ version }} ${{ tag }} ${{ commit }}
artifacts: ["target/nix/ianitor-nix.json"]
- id: approve
needs: [version, notes, shots, pin]
approve: "Publish Ianitor ${{ tag }}: its notes and screenshots?"
needs: [version, notes, shots, windows, linux, image]
approve: "Publish Ianitor ${{ tag }}: the Linux tarball, the Windows Server zip, notes and screenshots?"
- id: publish
needs: [approve]
publish:
gitea-release: true
files:
- "**/ianitor-*-linux-x86_64.tar.gz"
- "**/install.sh"
- "**/ianitor-*-windows-x86_64.zip"
- "**/release-notes.md"
- "**/release-notes.json"
- "**/aula-*.png"
- "**/aula.json"
- "**/ianitor-nix.json"
sums: domi-release
-18
View File
@@ -1,18 +0,0 @@
# Ianitor Domi: the verifiable build (docs/verify.md). On a v* tag the NixOS runner builds .#ianitor and
# .#ianitor-web from the tag (the run record keeps each output's store path and NAR hash), rebuilds each output
# derivation once more, and compares with the pin the release publishes (.fabrica/nix/pin.json at the tag: the
# source tree, nixpkgs and every hash); any difference fails the run. Runner: label `nixos`, Nix with flakes,
# node and jq from the `ci` shell; no KVM needed.
name: verify-nix
on:
tag: "v*"
manual: true
runner: nixos
steps:
- id: ianitor
nix: .#ianitor
- id: web
nix: .#ianitor-web
- id: pin
needs: [ianitor, web]
run: nix --extra-experimental-features "nix-command flakes" develop .#ci -c scripts/nix-pin.sh --check
+17
View File
@@ -0,0 +1,17 @@
Ianitor Domi now runs for any small team, not only on a NixOS server, and gives Fabrica a preview address for
every branch.
- **Install anywhere.** A one-line installer for Linux with systemd, a Docker image with a compose file, and
Windows Server, where Ianitor runs with Caddy as its engine (same screens, same route files; Pingora's Windows
support is still preliminary). The NixOS module stays.
- **Branch previews.** Fabrica asks for `<branch>--<project>.<your preview domain>` and gets it, with a certificate
from the Domi CA or Let's Encrypt; it closes when the branch is merged or its time runs out. Any branch name works:
unusual characters, dots and long names all become a safe address, and two branches never share one.
- **A token that can only do previews.** Fabrica's token opens and closes previews and nothing else, and previews
may only point where you allow, never at Ianitor's own admin ports.
- **Your team, without Authelia.** The installer prints a sign-in link for the first admin; admins invite the rest
with a link. Members change hosts and previews; admins also manage people, tokens, the engine and certificates.
Authelia still works where you have it.
- **Previews screen.** See every open preview in one click, close one in two.
- **Routes on any git host.** Push the routes repository to Gitea, GitHub or GitLab.
- **Tested on Windows too.** The comparison of Pingora and Caddy now also runs on Windows, with Windows paths.
+7 -12
View File
@@ -14,28 +14,23 @@ tests/diff same requests against Ianitor and Caddy, responses compared.
tests/support shared test fixtures (test CA, upstreams, mock Authelia, clients); test-only.
tests/fuzz cargo-fuzz targets.
deploy/nixos NixOS module + VM tests.
scripts version check, release pin, test layers 2 and 5 (conformance, bench), the Nix pin. Releases: docs/release.md.
bench layer 5 results as data (CSV/JSON), layer 2 outputs.
deploy/docker the image (edge + control), compose file, the Linux CI image (target ci). deploy/linux: installer,
systemd units. deploy/windows: Windows Server installer (Caddy mode). docs/deploy/anywhere.md.
scripts the release's version check. Releases (notes, screenshots): docs/release.md.
## Commands
cargo test --workspace # quote test counts per crate; an exit code alone is not green
docker build --load -f deploy/docker/Dockerfile --target ci -t ianitor-ci . && docker run --rm --memory 6g ianitor-ci cargo test --workspace --locked -j 2 # Linux, all suites
cargo run -p ianitor-control -- --dev
pnpm --filter web dev # 127.0.0.1 only, never --host
node apps/web/scripts/shots.mjs # the release's screenshots (demo data, headless Edge) -> target/aula (docs/release.md)
node scripts/check-version.mjs X.Y.Z # Cargo.toml and both package.json carry the version
scripts/conformance.sh # layer 2: h2spec + testssl.sh, Ianitor vs Caddy (nix develop .#ci)
tests/fuzz/run.sh 60 # layer 3: cargo-fuzz, 60 s a target; crashes become regressions
scripts/bench.sh <label> # layer 5: load and soak vs Caddy -> bench/results
scripts/nix-pin.sh # reproducible build check; writes .fabrica/nix/pin.json before a tag
nix build .#ianitor
nix flake check # includes NixOS VM tests (Linux + KVM)
On Windows, build and test in WSL2 Ubuntu (distro `Ubuntu`, 26.04, root; ROADMAP §8.3: Pingora's Windows support is
best effort; edge, diff and ACME tests are Linux-only). Rust from rustup in $HOME (stable; nightly for cargo-fuzz), a
Linux target dir, and caddy, pebble and pebble-challtestsrv on PATH: with Nix, `nix profile add nixpkgs#caddy
nixpkgs#pebble`; without it (as now), `apt install pebble testssl.sh golang-go` and
`go install github.com/caddyserver/caddy/v2/cmd/caddy@v2.11.7` (apt's Caddy 2.6 is too old for the diff suite):
wsl -d Ubuntu -- bash -lc 'cd /mnt/f/Akce/Ianitor && PATH=$HOME/.cargo/bin:$HOME/go/bin:$PATH CARGO_TARGET_DIR=$HOME/ianitor-target cargo test --workspace'
On Windows, build and test in WSL2 Debian (ROADMAP §8.3: Pingora's Windows support is best effort; edge, diff and
ACME tests are Linux-only). Use a Linux target dir, and put caddy, pebble and pebble-challtestsrv on PATH (`nix profile add nixpkgs#caddy nixpkgs#pebble`):
wsl -d Debian -- bash -lc 'cd /mnt/f/Akce/Ianitor && CARGO_TARGET_DIR=$HOME/ianitor-target cargo test --workspace'
One-time per clone: git config core.hooksPath .githooks (self-test: bash .githooks/test-pre-commit.sh)
## Rules
Generated
+25 -18
View File
@@ -1304,7 +1304,7 @@ dependencies = [
[[package]]
name = "ianitor-control"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"axum",
"base64 0.22.1",
@@ -1326,12 +1326,14 @@ dependencies = [
"tokio",
"tokio-rustls",
"toml",
"url",
"utoipa",
"windows-service",
]
[[package]]
name = "ianitor-core"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"base64 0.22.1",
"domi-pki",
@@ -1348,12 +1350,8 @@ dependencies = [
[[package]]
name = "ianitor-diff"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"bytes",
"http-body-util",
"hyper",
"hyper-util",
"ianitor-control",
"ianitor-core",
"ianitor-edge",
@@ -1362,11 +1360,12 @@ dependencies = [
"rustls",
"serde_json",
"tokio",
"toml",
]
[[package]]
name = "ianitor-edge"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"arc-swap",
"async-trait",
@@ -1392,18 +1391,9 @@ dependencies = [
"x509-parser 0.18.1",
]
[[package]]
name = "ianitor-fuzz"
version = "0.1.0"
dependencies = [
"ianitor-core",
"ianitor-edge",
"serde_json",
]
[[package]]
name = "ianitor-testkit"
version = "0.1.0"
version = "0.2.0"
dependencies = [
"bytes",
"futures-util",
@@ -3565,6 +3555,12 @@ dependencies = [
"rustls-pki-types",
]
[[package]]
name = "widestring"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471"
[[package]]
name = "winapi-util"
version = "0.1.11"
@@ -3580,6 +3576,17 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
name = "windows-service"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "857224b3b211c6f3616921f081ee54721ee3ad2ace2fac6a6337e032f7b4dcf2"
dependencies = [
"bitflags",
"widestring",
"windows-sys 0.61.2",
]
[[package]]
name = "windows-sys"
version = "0.52.0"
+2 -11
View File
@@ -1,18 +1,9 @@
[workspace]
resolver = "3"
members = [
"crates/core",
"crates/edge",
"crates/control",
"tests/diff",
"tests/fuzz",
"tests/support",
]
# cargo-fuzz's own workspace (libFuzzer flags): tests/fuzz/fuzz.
exclude = ["tests/fuzz/fuzz"]
members = ["crates/core", "crates/edge", "crates/control", "tests/diff", "tests/support"]
[workspace.package]
version = "0.1.0"
version = "0.2.0"
edition = "2024"
rust-version = "1.89"
license = "MPL-2.0"
-95
View File
@@ -1,95 +0,0 @@
# Ianitor Domi
[![Built, tested and signed by Fabrica Domi](docs/fabrica-badge.svg)](docs/verify.md)
*Ianitor* is Latin for the doorkeeper: it decides who comes through the door (routing, TLS) and checks
credentials (certificates). Ianitor Domi is a reverse proxy for a home server, built on Cloudflare's
[Pingora](https://github.com/cloudflare/pingora), with a small certificate authority for your own devices, a web
UI, an API, and a NixOS module. MPL-2.0.
- **Routes in git.** One TOML file per host in a repository (`hosts/wiki.example.toml`), schema-checked. Every
change is a commit, applied live without `nixos-rebuild`, watched for 60 seconds, and reverted by itself if the
host stops answering. Undo is one click; any older state can be restored.
- **Two processes.** `ianitor-edge` serves traffic and decides nothing; `ianitor-control` (API and UI, loopback
and Unix sockets only) edits the routes and tells edge what to serve. Traffic keeps flowing when control stops.
- **TLS your way.** Let's Encrypt for public names; for everything internal, the Domi CA: the root stays offline,
the intermediate on the server is renewed yearly, device certificates enable mTLS for a host.
- **What a home server needs, and no more.** Forward-auth to Authelia (existing protected services keep working),
header rules whose values can be systemd credentials (never written anywhere), websockets, health checks,
share links (an expiring, optionally password-protected link to one path), a truncated, opt-in visit log.
- **Caddy as the fallback.** The same route model compiles to Caddy JSON too, and one click switches engines at
runtime. Differential tests send the same requests to both on every build, so the fallback stays honest.
It is one person's project for one home network, published because the approach may be useful to others. It is
not a general-purpose proxy: no HTTP/3, no load-balancing policies beyond round robin over healthy upstreams, no
plugin system. Status, decisions and what is not done: [docs/ROADMAP.md](docs/ROADMAP.md).
## Why Pingora
Pingora is a library, not a server: Ianitor owns the request path (host lookup, forward-auth, share links,
header rules, upstream choice) in plain Rust, and gets HTTP/1, HTTP/2, websockets, TLS (rustls) and connection
pooling from code that serves a large share of the web at Cloudflare. A memory-safe data plane with no config
language between the routes and the code was the point; speed was not, and the numbers below say so.
Caddy is excellent, and Ianitor keeps it as the fallback engine. What Ianitor adds on top is the workflow: routes
as reviewed commits with automatic rollback, a CA for the house, and a UI where every common action takes at most
three clicks.
## Benchmarks (honest ones)
Load and soak runs against Caddy 2 on the same machine, the same route and the same upstream
(`scripts/bench.sh`, ROADMAP §5 layer 5). Results are committed as data in [bench/](bench/), with the machine
described beside them; [bench/README.md](bench/README.md) summarises them, including where Caddy wins. Two caveats
apply to every number there: the load generator, the proxies and the upstream share one machine, and edge runs
Pingora with two worker threads (a home server's budget), so Caddy is also measured with `GOMAXPROCS=2`.
## Install (NixOS)
```nix
# flake.nix
inputs.ianitor.url = "git+https://gitea.marek-novak.cz/mnovak/Ianitor.git";
# configuration
imports = [ inputs.ianitor.nixosModules.ianitor ];
services.ianitor = {
enable = true;
edge.openFirewall = true;
shareLinkKeyFile = "/run/secrets/ianitor-share-link-key"; # never a store path; the module refuses one
};
```
Then `ianitor-control token create --name laptop --config /etc/ianitor/control.toml` for the API, or the web UI
behind Authelia ([docs/api.md](docs/api.md), "Sign-in"). Beside an existing Caddy, edge can sit behind it on a Unix
socket: [docs/deploy/beside-caddy.md](docs/deploy/beside-caddy.md). The CA: [docs/pki.md](docs/pki.md).
## Tests
Five layers (ROADMAP §5), all in the `layers` pipeline (`.fabrica/artifex/layers.yaml`):
| Layer | What | Run it |
| :-- | :-- | :-- |
| 1 Differential | the same request corpus against Ianitor and Caddy, answers compared | `cargo test -p ianitor-diff` |
| 2 Conformance | h2spec and testssl.sh against both engines | `scripts/conformance.sh` |
| 3 Fuzzing | route files, header rules, share tokens, share-link paths, the CA's PEM and CSR parsing | `tests/fuzz/run.sh` |
| 4 NixOS VM tests | rollback, engine switch, CA renewal, loopback-only control, the sockets | `nix flake check` (KVM) |
| 5 Load and soak | against Caddy, results kept as data | `scripts/bench.sh` |
`cargo test --workspace` runs the unit, integration and layer 1 tests; most of them need Linux (Pingora's Windows
support is best effort), Caddy and Pebble on PATH: `nix develop .#ci`.
## Releases and verification
A release is a signed manifest, not a binary: `SHA256SUMS` signed by `domi-release` (through Custos) over the
release notes, screenshots of the UI and `ianitor-nix.json`, the NAR hashes of the Nix build at the tagged commit.
Anyone can rebuild the pinned commit and compare the hashes: [docs/verify.md](docs/verify.md). What is checked
so far is narrower than "reproducible": the output derivations are rebuilt once and compared, with dependencies
from the binary cache, and that has not run yet; the first pin needs a machine with Nix.
## Support
The source is free. If Ianitor is useful to you, you can **adopt a red panda**: support the project, and a fifth of
everything it receives goes to the [Red Panda Network](https://redpandanetwork.org), remitted once a year with the
receipt published. How it works and where it stands: [docs/support.md](docs/support.md).
## Licence
[MPL-2.0](LICENSE). Pingora is Apache-2.0; Caddy, used only as a separate fallback process, Apache-2.0.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "web",
"version": "0.1.0",
"version": "0.2.0",
"private": true,
"license": "MPL-2.0",
"description": "Ianitor Domi web UI (Svelte 5, runes, TypeScript strict). A pure client of the control API.",
+43 -4
View File
@@ -15,6 +15,7 @@
import Certificates from "./views/Certificates.svelte";
import History from "./views/History.svelte";
import Hosts from "./views/Hosts.svelte";
import Previews from "./views/Previews.svelte";
import RenewByHand from "./views/RenewByHand.svelte";
import Settings from "./views/Settings.svelte";
import SignedIn from "./views/SignedIn.svelte";
@@ -24,6 +25,7 @@
const p = u.pathname.replace(/\/+$/, "") || "/";
const seg = p.split("/").filter(Boolean).map(decodeURIComponent);
if (p === "/signed-in") return { view: "signed-in" as const };
if (seg[0] === "previews") return { view: "previews" as const };
if (seg[0] === "history") return { view: "history" as const, host: u.searchParams.get("host") ?? undefined, pick: seg[1] };
if (seg[0] === "certificates") return { view: seg[1] === "renew-by-hand" ? ("renew" as const) : ("certs" as const), newDevice: seg[1] === "new" };
if (seg[0] === "settings") return { view: "settings" as const, tab: seg[1] ?? "general" };
@@ -32,18 +34,51 @@
const NAV: { href: string; label: string; icon: IconName; views: string[] }[] = [
{ href: "/", label: "Hosts", icon: "building", views: ["hosts"] },
{ href: "/previews", label: "Previews", icon: "link", views: ["previews"] },
{ href: "/history", label: "History", icon: "history", views: ["history"] },
{ href: "/certificates", label: "Certificates", icon: "shield", views: ["certs", "renew"] },
{ href: "/settings/general", label: "Settings", icon: "gear", views: ["settings"] },
];
const TITLES: Record<string, string> = { hosts: "Hosts", history: "History", certs: "Certificates", renew: "Certificates", settings: "Settings", "signed-in": "Signed in" };
const TITLES: Record<string, string> = { hosts: "Hosts", history: "History", previews: "Previews", certs: "Certificates", renew: "Certificates", settings: "Settings", "signed-in": "Signed in" };
$effect(() => {
document.title = `${TITLES[route.view] ?? "Hosts"} — Ianitor Domi`;
});
// A setup or invite link (`#signin=<code>`, crate::team): one click on the link signs in.
async function signInFromLink(): Promise<void> {
const m = /^#signin=([A-Za-z0-9_-]{8,100})$/.exec(location.hash);
if (!m) return;
history.replaceState(null, "", location.pathname + location.search);
try {
const r = await fetch("/api/v1/session", {
method: "POST",
headers: { "Content-Type": "application/json", "X-Ianitor-UI": "1" },
body: JSON.stringify({ code: m[1], device: navigator.platform || "Browser" }),
credentials: "same-origin",
});
if (!r.ok) {
const j = await r.json().catch(() => null);
app.linkProblem = j?.error?.message ?? "This sign-in link does not work.";
}
} catch {
app.linkProblem = "Ianitor did not answer the sign-in.";
}
}
async function signOutSession() {
try {
await fetch("/api/v1/session/end", { method: "POST", headers: { "X-Ianitor-UI": "1" }, credentials: "same-origin" });
} finally {
location.href = "/";
}
}
onMount(() => {
if (route.view === "signed-in") return;
if (location.hash.startsWith("#signin=")) {
void signInFromLink().then(() => refresh());
}
const stop = startPolling();
// Resume an apply this tab was watching before a reload or a sign-in (§3).
const id = remembered();
@@ -101,7 +136,8 @@
<a href={n.href} class="nav" aria-current={n.views.includes(route.view) ? "page" : undefined} onclick={(e) => go(e, n.href)}><Icon name={n.icon} />{n.label}</a>
{/each}
<div class="foot ia-muted">
<p>{viewer?.via === "authelia" ? `Signed in as ${viewer.name} through Authelia` : viewer ? `Using the API token "${viewer.name}"` : "Signed in through Authelia"}</p>
<p>{viewer?.via === "authelia" ? `Signed in as ${viewer.name} through Authelia` : viewer?.via === "session" ? `Signed in as ${viewer.name}` : viewer ? `Using the API token "${viewer.name}"` : "Not signed in"}</p>
{#if viewer?.via === "session"}<button type="button" class="domi-btn link" onclick={signOutSession}>Sign out</button>{/if}
<p>Control on 127.0.0.1 only</p>
{#if app.overview?.site?.auth_logout_url}<a class="domi-btn link" href={app.overview.site.auth_logout_url}>Sign out</a>{/if}
</div>
@@ -109,8 +145,11 @@
<header class="topbar"><span class="ia-wordmark">IANITOR DOMI</span>{#if app.phone}<EngineChip />{/if}</header>
<main id="main" tabindex="-1">
<TopBanners />
{#if app.linkProblem}<p class="domi-error" role="alert">{app.linkProblem}</p>{/if}
{#if route.view === "hosts"}
<Hosts route={{ newHost: route.newHost, edit: route.edit }} />
{:else if route.view === "previews"}
<Previews />
{:else if route.view === "history"}
{#key route.host}<History host={route.host} pick={route.pick} />{/key}
{:else if route.view === "certs"}
@@ -141,7 +180,7 @@
{#if app.signedOut}
<Dialog title="Your sign-in has ended" role="alertdialog" escape={false} closable={false} onclose={() => {}}>
<p>Sign in again; this page keeps what you typed.</p>
<p>Sign in again; this page keeps what you typed. Without Authelia, open your sign-in link again or ask an admin of your team for a new one.</p>
{#snippet footer()}
<Button onclick={signedInAgain}>I have signed in</Button>
<Button variant="primary" onclick={signIn} data-autofocus>Sign in</Button>
@@ -167,7 +206,7 @@
.topbar { display: flex; align-items: center; justify-content: space-between; background: var(--colonnade); border-bottom: 1px solid var(--hairline); padding: 10px 16px; }
.topbar .ia-wordmark { font-size: 12px; letter-spacing: 0.26em; }
main { padding: 18px 16px calc(90px + env(safe-area-inset-bottom)); gap: 14px; }
.bottombar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--colonnade); border-top: 1px solid var(--hairline); padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); z-index: 40; }
.bottombar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: var(--colonnade); border-top: 1px solid var(--hairline); padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); z-index: 40; }
.bottombar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--phone-bar-h); border-radius: var(--radius-sm); color: var(--text-2); font-weight: 600; font-size: var(--fs-tab-phone); text-decoration: none; }
.bottombar a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.bottombar a[aria-current="page"] :global(svg) { color: var(--accent); }
+137
View File
@@ -0,0 +1,137 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
<script lang="ts">
// T4: the team without Authelia. Invite: Settings → Team → Invite (3 clicks), then Copy link.
import { onMount } from "svelte";
import { Banner, Button, Segmented } from "@ianitor/ui";
import { del, get, post, put, sentence } from "../lib/api";
import { toast } from "../lib/app.svelte";
import { shortDate } from "../lib/format";
import type { TeamView } from "../lib/types";
let team = $state<TeamView | null>(null);
let problem = $state<string | null>(null);
let name = $state("");
let role = $state<"member" | "admin">("member");
let link = $state<string | null>(null);
let confirmRemove = $state<string | null>(null);
let root = $state("");
async function load() {
try {
team = await get<TeamView>("/team");
root = team.me?.tessera_root ?? "";
problem = null;
} catch (e) {
problem = sentence(e);
}
}
onMount(() => void load());
async function invite() {
try {
const r = await post<{ link_fragment: string }>("/team/invites", { name: name.trim(), role });
link = `${location.origin}/${r.link_fragment}`;
name = "";
await load();
} catch (e) {
problem = sentence(e);
}
}
async function copy() {
if (!link) return;
try {
await navigator.clipboard.writeText(link);
toast("Copied. Send it to them; it works once, for 7 days.");
} catch {
problem = "Your browser did not allow copying. Select the link and press Ctrl+C.";
}
}
async function remove(id: string) {
try {
await del(`/team/members/${encodeURIComponent(id)}`);
confirmRemove = null;
toast("Removed and signed out everywhere.");
await load();
} catch (e) {
problem = sentence(e);
}
}
async function saveRoot() {
try {
await put("/team/me/root", { tessera_root: root.trim() || null });
toast("Saved.");
await load();
} catch (e) {
problem = sentence(e);
}
}
const admin = $derived(team?.me ? team.me.role === "admin" : true);
</script>
{#if problem}<Banner tone="notice" live="status" ondismiss={() => (problem = null)}>{#snippet title()}{problem}{/snippet}</Banner>{/if}
{#if team?.authelia}
<p class="ia-hint">Authelia signs people in on this server. Team links work too.</p>
{/if}
<h2 class="ia-h3">People</h2>
<ul class="rows">
{#each team?.members ?? [] as m (m.id)}
<li>
<div class="grow"><strong>{m.name}</strong>{team?.me?.id === m.id ? " (you)" : ""}
<span class="ia-sub" style="display:block">{m.role} · since {shortDate(m.added_at)}{m.match_code ? ` · Domi identity ${m.match_code}` : ""}</span></div>
{#if admin && team?.me?.id !== m.id}
{#if confirmRemove === m.id}
<span>Remove {m.name}? They are signed out everywhere.</span>
<Button small onclick={() => (confirmRemove = null)}>Keep</Button>
<Button small variant="danger" onclick={() => remove(m.id)}>Remove</Button>
{:else}
<Button small variant="danger" onclick={() => (confirmRemove = m.id)}>Remove</Button>
{/if}
{/if}
</li>
{/each}
</ul>
{#if admin}
<div class="row">
<div class="domi-field">
<label class="domi-field-label" for="invite-name">Name</label>
<input id="invite-name" class="domi-input" bind:value={name} placeholder="Petra" />
</div>
<Segmented legend="Role" name="invite-role" bind:value={role} options={[{ value: "member", label: "Member" }, { value: "admin", label: "Admin" }]} />
<Button variant="outline" icon="plus" onclick={invite} disabled={!name.trim()}>Invite</Button>
</div>
<p class="ia-hint">Members change hosts and previews. Admins also manage people, API tokens, the engine and certificates.</p>
{#if link}
<div class="grid">
<input class="ia-secret" readonly value={link} aria-label="Invite link" onfocus={(e) => (e.currentTarget as HTMLInputElement).select()} />
<Button variant="primary" icon="copy" onclick={copy} data-autofocus>Copy link</Button>
</div>
{/if}
{/if}
{#if team?.me}
<h2 class="ia-h3">Your Domi identity</h2>
<div class="row">
<div class="domi-field grow">
<label class="domi-field-label" for="tessera-root">Tessera root (Custos → Domi identity)</label>
<input id="tessera-root" class="domi-input" bind:value={root} spellcheck="false" />
</div>
<Button onclick={saveRoot}>Save</Button>
</div>
<p class="ia-hint">Your teammates see its match code next to your name, the same digits Custos shows.</p>
{/if}
<style>
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-height: 44px; padding: 8px 0; border-top: 1px solid var(--hairline); }
.grow { flex: 1 1 200px; min-width: 0; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
@media (max-width: 719.98px) { .grid { grid-template-columns: 1fr; } }
</style>
+1 -1
View File
@@ -139,7 +139,7 @@ export async function call<T>(
await sleep(Math.min(60, env.error.retry_after_s ?? 1) * 1000);
continue;
}
if (res.status === 401 && env.error.code.startsWith("token.")) {
if (res.status === 401 && (env.error.code.startsWith("token.") || env.error.code.startsWith("session."))) {
// The UI holds no token: a token refusal means the sign-in did not reach control.
events.onSignedOut?.();
throw new SignedOut(env.error.message);
+2
View File
@@ -14,6 +14,8 @@ export interface Toast {
}
export const app = $state({
/** Why a `#signin=` link did not sign this browser in. */
linkProblem: null as string | null,
overview: null as Overview | null,
etag: null as string | null,
loadError: false,
+34
View File
@@ -212,6 +212,7 @@ export interface TokenRow {
last_used_at: string | null;
expires_at: string | null;
revoked_at?: string | null;
scope?: "full" | "previews";
}
export interface CreatedToken {
@@ -249,3 +250,36 @@ export interface Bundle {
filename: string;
qr_svg: string | null;
}
// T4: branch previews and the team (docs/previews.md, crate::team).
export interface PreviewView {
hostname: string;
url: string;
project: string;
branch: string;
upstream: string;
expires_at: string;
state: "applying" | "live" | "failed";
problem?: string | null;
}
export interface PreviewList {
items: PreviewView[];
domain: string | null;
}
export interface MemberView {
id: string;
name: string;
role: "admin" | "member";
added_at: string;
tessera_root: string | null;
match_code: string | null;
}
export interface TeamView {
me: MemberView | null;
members: MemberView[];
invites: { id: string; name: string | null; role: string; expires_at: string }[];
authelia: boolean;
}
+103
View File
@@ -0,0 +1,103 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at https://mozilla.org/MPL/2.0/. -->
<script lang="ts">
// T4: branch previews Fabrica opens. See them: 1 click (the nav). Close one: 2 clicks
// (Close → Close preview).
import { onMount } from "svelte";
import { Banner, Button, Status } from "@ianitor/ui";
import type { StatusKind } from "@ianitor/ui";
import { del, get, sentence } from "../lib/api";
import { app, toast } from "../lib/app.svelte";
import { whenInline } from "../lib/format";
import type { PreviewList, PreviewView } from "../lib/types";
let list = $state<PreviewList | null>(null);
let problem = $state<string | null>(null);
let confirm = $state<string | null>(null);
let closing = $state<string | null>(null);
async function load() {
try {
list = await get<PreviewList>("/previews");
problem = null;
} catch (e) {
problem = sentence(e);
}
}
async function close(p: PreviewView) {
closing = p.hostname;
try {
await del(`/previews/${encodeURIComponent(p.hostname)}`);
toast(`Closing the preview of ${p.branch}.`);
confirm = null;
await load();
} catch (e) {
problem = sentence(e);
} finally {
closing = null;
}
}
onMount(() => {
void load();
const t = setInterval(() => void load(), 5000);
const f = () => void load();
window.addEventListener("focus", f);
return () => {
clearInterval(t);
window.removeEventListener("focus", f);
};
});
function badge(p: PreviewView): [StatusKind, string] {
if (p.state === "live") return ["healthy", "live"];
if (p.state === "failed") return ["down", "failed"];
return ["running", "opening"];
}
</script>
<h1 class="ia-display">Previews</h1>
{#if problem}<Banner tone="notice" live="status" ondismiss={() => (problem = null)}>{#snippet title()}{problem}{/snippet}</Banner>{/if}
{#if list && !list.domain}
<div class="ia-frame">
<h2 class="ia-h3">Previews are off</h2>
<p class="ia-text2">Set a preview domain in control.toml (<code>[previews] domain</code>) and point a wildcard DNS record at this server. Then every branch Fabrica builds gets its own address here.</p>
</div>
{:else if list && list.items.length === 0}
<div class="ia-frame">
<h2 class="ia-h3">No previews open</h2>
<p class="ia-text2">When Fabrica builds a branch, its preview appears here as <code>&lt;branch&gt;--&lt;project&gt;.{list.domain}</code>. It closes on merge or when its time runs out.</p>
</div>
{:else if list}
<p class="ia-hint">Under {list.domain}. Fabrica opens them with a token that can only manage previews.</p>
<ul class="rows">
{#each list.items as p (p.hostname)}
{@const [kind, label] = badge(p)}
<li>
<Status {kind} word={label} />
<div class="grow">
<a class="host" href={p.url} target="_blank" rel="noreferrer">{p.hostname}</a>
<span class="ia-sub" style="display:block">{p.branch} · {p.project} · to {p.upstream} · closes {whenInline(p.expires_at, app.now)}</span>
{#if p.problem}<span class="domi-error">{p.problem}</span>{/if}
</div>
{#if confirm === p.hostname}
<span>Close the preview of {p.branch}? Its address stops working.</span>
<Button small onclick={() => (confirm = null)}>Keep it</Button>
<Button small variant="danger" pending={closing === p.hostname} onclick={() => close(p)} data-autofocus>Close preview</Button>
{:else}
<Button small variant="danger" onclick={() => (confirm = p.hostname)}>Close</Button>
{/if}
</li>
{/each}
</ul>
{/if}
<style>
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; min-height: 52px; padding: 10px 0; border-top: 1px solid var(--hairline); }
.grow { flex: 1 1 260px; min-width: 0; }
.host { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
</style>
+13 -6
View File
@@ -6,6 +6,7 @@
// accepted 4th), Share links and About.
import { onMount } from "svelte";
import { Banner, Button, Dialog, Segmented } from "@ianitor/ui";
import TeamTab from "../components/TeamTab.svelte";
import { ApiError, call, del, get, newKey, patch, post, sentence } from "../lib/api";
import { app, navigate, toast } from "../lib/app.svelte";
import { longDate, shortDate, whenInline } from "../lib/format";
@@ -14,6 +15,7 @@
let { tab }: { tab: string } = $props();
const TABS = [
{ id: "general", label: "General" },
{ id: "team", label: "Team" },
{ id: "api", label: "API" },
{ id: "share-links", label: "Share links" },
{ id: "about", label: "About" },
@@ -25,6 +27,7 @@
let links = $state<ShareLink[]>([]);
let problem = $state<string | null>(null);
let expiry = $state<"year" | "never">("year");
let scope = $state<"full" | "previews">("full");
let made = $state<CreatedToken | null>(null);
let tokenName = $state("");
let tokenCopied = $state(false);
@@ -69,8 +72,8 @@
async function newToken() {
creating = true;
try {
const name = `Token made ${shortDate(new Date().toISOString())}`;
const body = expiry === "never" ? { name, never_expires: true } : { name, expires_in_days: 365 };
const name = scope === "previews" ? `Fabrica previews ${shortDate(new Date().toISOString())}` : `Token made ${shortDate(new Date().toISOString())}`;
const body = expiry === "never" ? { name, never_expires: true, scope } : { name, expires_in_days: 365, scope };
made = await post<CreatedToken>("/tokens", body);
tokenName = made.name;
tokenCopied = false;
@@ -164,18 +167,22 @@
<div role="tabpanel" id="panel-{tab}" aria-labelledby="tab-{tab}" class="panel">
{#if tab === "general"}
<p class="ia-label">Routes repository</p>
<p>{settings?.repo ? `${settings.repo.name} on Gitea · ${settings.repo.last_push_at ? "pushed " + whenInline(settings.repo.last_push_at, app.now) : "not pushed yet"}` : "No place to push to is set up."}</p>
<p>{settings?.repo ? `${settings.repo.name} · ${settings.repo.last_push_at ? "pushed " + whenInline(settings.repo.last_push_at, app.now) : "not pushed yet"}` : "No place to push to is set up."}</p>
<p class="ia-label">Health watch after apply</p>
<p>{settings?.watch_seconds ?? app.overview?.site?.watch_seconds ?? 60} seconds</p>
<p class="ia-label">Signed in</p>
<p>{viewer ? (viewer.via === "authelia" ? `${viewer.name} through Authelia` : `API token "${viewer.name}"`) : "Through Authelia"}</p>
<p>{viewer ? (viewer.via === "authelia" ? `${viewer.name} through Authelia` : viewer.via === "session" ? viewer.name : `API token "${viewer.name}"`) : "Not signed in"}</p>
{#if app.overview?.site?.auth_logout_url}<p><a class="domi-btn link" href={app.overview.site.auth_logout_url}>Sign out</a></p>{/if}
{:else if tab === "team"}
<TeamTab />
{:else if tab === "api"}
<div class="row">
<h2 class="ia-h3">API tokens</h2>
<Button variant="outline" icon="plus" onclick={newToken} pending={creating}>New token</Button>
<Segmented legend="New tokens expire after" name="token-expiry" bind:value={expiry} options={[{ value: "year", label: "1 year" }, { value: "never", label: "Never" }]} />
<Segmented legend="New tokens may" name="token-scope" bind:value={scope} options={[{ value: "full", label: "Do everything" }, { value: "previews", label: "Previews only" }]} />
</div>
<p class="ia-hint">Fabrica needs a previews-only token: it can open and close branch previews and touch nothing else. Keep it in the Custos team vault.</p>
<p class="ia-hint">The API listens on 127.0.0.1 only. Ianitor keeps a hash of each token, never the token.</p>
{#if tokens.length === 0}
<div class="ia-frame"><h2 class="ia-h3">No API tokens</h2><p class="ia-text2">Scripts and other Domi apps use a token to talk to Ianitor.</p></div>
@@ -184,7 +191,7 @@
{#each tokens as t (t.id)}
<li>
<div class="grow">
<span class="tname" class:struck={!!revoked[t.id] || !!t.revoked_at}>{t.name}</span>
<span class="tname" class:struck={!!revoked[t.id] || !!t.revoked_at}>{t.name}</span>{#if t.scope === "previews"} <span class="ia-sub">previews only</span>{/if}
<span class="ia-sub" style="display:block">
{#if revoked[t.id]}Revoked {whenInline(revoked[t.id], app.now)}{:else}Made {shortDate(t.created_at)} · {t.last_used_at ? `last used ${whenInline(t.last_used_at, app.now)}` : "never used"} · {t.expires_at ? `expires ${shortDate(t.expires_at)}` : "never expires"}{/if}
</span>
@@ -233,7 +240,7 @@
{/if}
{/if}
{:else}
<p>Ianitor Domi 0.1.0</p>
<p>Ianitor Domi 0.2.0</p>
<p>MPL-2.0</p>
<p>Built, tested and signed by Fabrica Domi</p>
<p><a class="domi-btn link" href="https://gitea.marek-novak.cz/mnovak/Ianitor" rel="noreferrer">Source on Gitea</a></p>
+31
View File
@@ -170,6 +170,37 @@ describe("ROADMAP §4 flows, clicks counted", () => {
});
});
describe("T4 flows, clicks counted", () => {
it("See active previews = 1 click", async () => {
start();
const nav = (await screen.findAllByRole("navigation", { name: "Main" }, T))[0];
await click(within(nav).getByRole("link", { name: "Previews" }));
await screen.findByRole("link", { name: "fix-42--shop.preview.home.test" }, T);
expect(clicks).toBe(1);
});
it("Kill a preview = 2 clicks (Close → Close preview)", async () => {
start("/previews");
await click(await screen.findByRole("button", { name: "Close" }, T));
await click(await screen.findByRole("button", { name: "Close preview" }));
await waitFor(() => expect(called("DELETE", "/previews/fix-42--shop.preview.home.test")).toBe(true), T);
await screen.findByRole("heading", { name: "No previews open" }, T);
expect(clicks).toBe(2);
});
it("Invite a teammate: Settings → Team → Invite = 3 clicks, the link shown", async () => {
start();
const nav = (await screen.findAllByRole("navigation", { name: "Main" }, T))[0];
await click(within(nav).getByRole("link", { name: "Settings" }));
await click(await screen.findByRole("tab", { name: "Team" }));
await user.type(await screen.findByLabelText("Name"), "Petra");
await click(screen.getByRole("button", { name: "Invite" }));
const link = (await screen.findByLabelText("Invite link", {}, T)) as HTMLInputElement;
expect(link.value).toMatch(/\/#signin=iin_testcode$/);
expect(clicks).toBe(3);
});
});
describe("focus", () => {
it("+ Host puts the cursor in Hostname, so typing right after the click lands there", async () => {
start();
+13 -1
View File
@@ -12,6 +12,7 @@ export interface Mock {
calls: { method: string; path: string; body: unknown }[];
state: {
engine: "pingora" | "caddy";
previewClosed: boolean;
switching: number;
intermediate: "ok" | "due";
renewal: boolean;
@@ -65,7 +66,7 @@ export type Route = [string, RegExp, (mm: RegExpMatchArray, body: Json) => [numb
export function newMock(): Mock {
return {
calls: [],
state: { engine: "pingora", switching: 0, intermediate: "due", renewal: false, requestPolls: 0, hostsAdded: [] },
state: { engine: "pingora", switching: 0, intermediate: "due", renewal: false, requestPolls: 0, hostsAdded: [], previewClosed: false },
};
}
@@ -170,6 +171,17 @@ export function mockRoutes(m: Mock): Route[] {
["GET", /^\/tokens$/, () => [200, { items: [] }]],
["POST", /^\/tokens$/, (_, b) => [201, { id: "tk_1", name: b.name, token: "ian_tk1_secretvalue", expires_at: later(365 * 86400) }]],
["GET", /^\/share-links$/, () => [200, { items: [], epoch: 0 }]],
// T4: previews and the team (invented .test names only).
["GET", /^\/previews$/, () => [200, {
domain: "preview.home.test",
items: m.state.previewClosed ? [] : [{ hostname: "fix-42--shop.preview.home.test", url: "https://fix-42--shop.preview.home.test/", project: "team/shop", branch: "fix-42", upstream: "http://10.0.0.7:8080", expires_at: later(86400), state: "live" }],
}]],
["DELETE", /^\/previews\/fix-42--shop\.preview\.home\.test$/, () => {
m.state.previewClosed = true;
return [202, { apply: apply("ch_pv", "queued", "Closed the preview of fix-42 (team/shop)", ["fix-42--shop.preview.home.test"]) }];
}],
["GET", /^\/team$/, () => [200, { me: { id: "m1", name: "Mark", role: "admin", added_at: now(), tessera_root: null, match_code: null }, members: [{ id: "m1", name: "Mark", role: "admin", added_at: now(), tessera_root: null, match_code: null }], invites: [], authelia: false }]],
["POST", /^\/team\/invites$/, (_, b) => [201, { invite: { id: "iv1", name: b.name, role: b.role, expires_at: later(7 * 86400) }, link_fragment: "#signin=iin_testcode" }]],
];
}
-83
View File
@@ -1,83 +0,0 @@
# Benchmarks and conformance (ROADMAP §5 layers 2 and 5)
Data, not marketing: every run's raw output is committed here, and this page summarises it, including where Caddy
wins.
| Folder | What | Made by |
| :-- | :-- | :-- |
| `results/<date>-<label>.csv` and `results/<date>-<label>/` | load and soak runs: one CSV row per engine, scenario and concurrency; oha's raw JSON; `machine.txt` | `scripts/bench.sh <label>` |
| `conformance/` | h2spec and testssl.sh outputs for Ianitor and for Caddy | `scripts/conformance.sh` |
## How the runs are made
`tests/diff/src/bin/pair.rs` (`ianitor-pair`) compiles one route, `localhost` → a small upstream that answers
`200 ok`, for both engines with Ianitor's compilers, and starts Ianitor's edge (in its own process with the
upstream in a child) and two Caddys: one as Go starts it (every core) and one with `GOMAXPROCS=2`. Edge runs Pingora
with **two worker threads** (`crates/edge/src/lib.rs`), a deliberate budget for a home server, so the second Caddy
is the like-for-like comparison and the first shows what Caddy does with the whole machine.
[oha](https://github.com/hatoo/oha) then drives each engine in turn, the same way:
| Scenario | What it measures |
| :-- | :-- |
| `https-h1-keepalive`, 1/16/64/256 connections | HTTP/1.1 over TLS, connections reused: the proxy path itself |
| `https-h2`, 1/16/64/256 connections | the same over HTTP/2 |
| `https-h1-new-conn`, 16 connections | a new TLS handshake per request |
| `http-redirect`, 64 connections | the plain-HTTP listener's 308 (no upstream) |
| `soak-https-h1`, 32 connections, 5 minutes | latency and errors over time, memory after (`rss_kb_after`) |
Caveats that apply to every number: the load generator, both proxies and the upstream share one machine and its
cores; loopback has no network latency, so small differences in CPU per request dominate; the upstream is trivial.
Compare rows of one file with each other, not numbers across machines. `machine.txt` records the CPU, the kernel,
whether it is WSL2, the build (release or debug) and the tool versions.
## Results
### Load and soak: 2026-11-18, WSL2 Ubuntu 26.04 (`results/2026-11-18-wsl2-ubuntu.csv`)
AMD Ryzen 7 5800X3D (16 threads), 32 GB, WSL2 kernel 6.18; release build; Caddy v2.11.7 built with Go 1.26.8 from
its official module (no Nix on this machine: Caddy reports its version as "unknown"); oha 1.17; 15 s a run, one run
each. Requests per second (higher is better), and p99 latency in ms:
| Scenario | Ianitor (2 threads) | Caddy (all cores) | Caddy (GOMAXPROCS=2) |
| :-- | --: | --: | --: |
| HTTP/1.1, keep-alive, 1 conn | 1,861 / 9.0 | 1,757 / 2.5 | **2,351** / 0.8 |
| HTTP/2, 1 conn | **2,173** / 0.8 | 1,375 / 1.4 | 1,588 / 1.4 |
| HTTP/1.1, 16 conns | 3,843 / 28.8 | 6,905 / 45.5 | **7,759** / 11.2 |
| HTTP/2, 16 conns | 4,723 / 27.5 | **6,090** / 35.6 | 3,426 / 28.6 |
| HTTP/1.1, 64 conns | 6,596 / 50.9 | **15,653** / 31.3 | 6,561 / 39.8 |
| HTTP/2, 64 conns | **11,726** / 23.2 | 8,472 / 59.6 | 5,708 / 37.3 |
| HTTP/1.1, 256 conns | 4,421 / 155.6 | **12,632** / 101.9 | 4,473 / 147.0 |
| HTTP/2, 256 conns | 3,981 / 146.6 | **10,077** / 101.9 | 3,607 / 134.4 |
| New TLS connection per request, 16 | 1,218 / 50.6 | **2,236** / 65.0 | 1,823 / 21.4 |
| Plain-HTTP redirect, 64 | 13,582 / 32.4 | **54,027** / 16.3 | 17,027 / 15.5 |
| Soak, HTTP/1.1, 32 conns, 5 min | 6,245 / 31.3 | **13,031** / 35.4 | (not run) |
Every request of every run succeeded (success rate 1.0, no unexpected status). Memory (resident, after each run, the
process that serves the port): Ianitor 13 MB at the start, 56 MB after the soak; Caddy 60 MB and 77 MB.
**Where Caddy wins:** almost everywhere with the whole machine, by about 2× under HTTP/1.1 load and 4× on the
plain-HTTP redirect; with the same two cores it is still ahead on HTTP/1.1 at 1 to 16 connections, on new TLS
connections (about 1.5×, so rustls handshakes cost Ianitor more than Go's) and on the redirect.
**Where Ianitor wins:** HTTP/2 at 1 and 64 connections (ahead of both Caddys), HTTP/2 at 16 and 256 connections
against Caddy on two cores, and memory, which stays below Caddy's in every run. At 64 and 256 HTTP/1.1 connections
Ianitor and Caddy on two cores are even.
How much to read into it: one run each, on a desktop that was doing other things; a 2-second smoke run of the same
script just before gave Ianitor 14,341 requests/s on HTTP/1.1 with 16 connections, against 3,843 here, so single
numbers move a lot on this machine. The ordering at 64 connections and above, the redirect and the handshake cost
were the same in both runs. For a home server, every row is far beyond what it will see; the numbers are here to
keep the comparison honest, not to choose an engine.
### Conformance: 2026-11-18, same machine (`conformance/`)
| | h2spec (145 cases) | testssl.sh 3.2.2 |
| :-- | :-- | :-- |
| Ianitor | 144 passed, 1 skipped, **0 failed** | A+; TLS 1.2 and 1.3; no server cipher order (rustls follows the client) |
| Caddy 2.11.7 | 140 passed, 1 skipped, **4 failed** | A+; TLS 1.2 and 1.3; server cipher order; session tickets valid 7 days (LOW) |
Caddy's four h2spec failures (Go's HTTP/2 server): HEADERS larger than SETTINGS_MAX_FRAME_SIZE (4.2/3), several
SETTINGS_INITIAL_WINDOW_SIZE values (6.5.3/1), a connection-specific header field and a `TE` other than
`trailers` (8.1.2.2/1 and 2). The two HIGH findings testssl.sh reports for both engines belong to the throwaway test
certificate (a validity of about 2,100 years, no CRL or OCSP URL), not to the engines; HSTS and security headers
are the routes' business (header rules), not set on the test route.
@@ -1,4 +0,0 @@
1: Sends a HEADERS frame that contains the connection-specific header field
1: Sends multiple values of SETTINGS_INITIAL_WINDOW_SIZE
2: Sends a HEADERS frame that contains the TE header field with any value other than "trailers"
3: Sends a large size HEADERS frame that exceeds the SETTINGS_MAX_FRAME_SIZE
-314
View File
@@ -1,314 +0,0 @@
Generic tests for HTTP/2 server
1. Starting HTTP/2
1: Sends a client connection preface
✔ 1: Sends a client connection preface
2. Streams and Multiplexing
1: Sends a PRIORITY frame on idle stream
✔ 1: Sends a PRIORITY frame on idle stream
2: Sends a WINDOW_UPDATE frame on half-closed (remote) stream
✔ 2: Sends a WINDOW_UPDATE frame on half-closed (remote) stream
3: Sends a PRIORITY frame on half-closed (remote) stream
✔ 3: Sends a PRIORITY frame on half-closed (remote) stream
4: Sends a RST_STREAM frame on half-closed (remote) stream
✔ 4: Sends a RST_STREAM frame on half-closed (remote) stream
5: Sends a PRIORITY frame on closed stream
✔ 5: Sends a PRIORITY frame on closed stream
3. Frame Definitions
3.1. DATA
1: Sends a DATA frame
✔ 1: Sends a DATA frame
2: Sends multiple DATA frames
✔ 2: Sends multiple DATA frames
3: Sends a DATA frame with padding
✔ 3: Sends a DATA frame with padding
3.2. HEADERS
1: Sends a HEADERS frame
✔ 1: Sends a HEADERS frame
2: Sends a HEADERS frame with padding
✔ 2: Sends a HEADERS frame with padding
3: Sends a HEADERS frame with priority
✔ 3: Sends a HEADERS frame with priority
3.3. PRIORITY
1: Sends a PRIORITY frame with priority 1
✔ 1: Sends a PRIORITY frame with priority 1
2: Sends a PRIORITY frame with priority 256
✔ 2: Sends a PRIORITY frame with priority 256
3: Sends a PRIORITY frame with stream dependency
✔ 3: Sends a PRIORITY frame with stream dependency
4: Sends a PRIORITY frame with exclusive
✔ 4: Sends a PRIORITY frame with exclusive
5: Sends a PRIORITY frame for an idle stream, then send a HEADER frame for a lower stream ID
✔ 5: Sends a PRIORITY frame for an idle stream, then send a HEADER frame for a lower stream ID
3.4. RST_STREAM
1: Sends a RST_STREAM frame
✔ 1: Sends a RST_STREAM frame
3.5. SETTINGS
1: Sends a SETTINGS frame
✔ 1: Sends a SETTINGS frame
3.7. PING
1: Sends a PING frame
✔ 1: Sends a PING frame
3.8. GOAWAY
1: Sends a GOAWAY frame
✔ 1: Sends a GOAWAY frame
3.9. WINDOW_UPDATE
1: Sends a WINDOW_UPDATE frame with stream ID 0
✔ 1: Sends a WINDOW_UPDATE frame with stream ID 0
2: Sends a WINDOW_UPDATE frame with stream ID 1
✔ 2: Sends a WINDOW_UPDATE frame with stream ID 1
3.10. CONTINUATION
1: Sends a CONTINUATION frame
✔ 1: Sends a CONTINUATION frame
2: Sends multiple CONTINUATION frames
✔ 2: Sends multiple CONTINUATION frames
4. HTTP Message Exchanges
1: Sends a GET request
✔ 1: Sends a GET request
2: Sends a HEAD request
✔ 2: Sends a HEAD request
3: Sends a POST request
✔ 3: Sends a POST request
4: Sends a POST request with trailers
✔ 4: Sends a POST request with trailers
5. HPACK
1: Sends a indexed header field representation
✔ 1: Sends a indexed header field representation
2: Sends a literal header field with incremental indexing - indexed name
✔ 2: Sends a literal header field with incremental indexing - indexed name
3: Sends a literal header field with incremental indexing - indexed name (with Huffman coding)
✔ 3: Sends a literal header field with incremental indexing - indexed name (with Huffman coding)
4: Sends a literal header field with incremental indexing - new name
✔ 4: Sends a literal header field with incremental indexing - new name
5: Sends a literal header field with incremental indexing - new name (with Huffman coding)
✔ 5: Sends a literal header field with incremental indexing - new name (with Huffman coding)
6: Sends a literal header field without indexing - indexed name
✔ 6: Sends a literal header field without indexing - indexed name
7: Sends a literal header field without indexing - indexed name (with Huffman coding)
✔ 7: Sends a literal header field without indexing - indexed name (with Huffman coding)
8: Sends a literal header field without indexing - new name
✔ 8: Sends a literal header field without indexing - new name
9: Sends a literal header field without indexing - new name (huffman encoded)
✔ 9: Sends a literal header field without indexing - new name (huffman encoded)
10: Sends a literal header field never indexed - indexed name
✔ 10: Sends a literal header field never indexed - indexed name
11: Sends a literal header field never indexed - indexed name (huffman encoded)
✔ 11: Sends a literal header field never indexed - indexed name (huffman encoded)
12: Sends a literal header field never indexed - new name
✔ 12: Sends a literal header field never indexed - new name
13: Sends a literal header field never indexed - new name (huffman encoded)
✔ 13: Sends a literal header field never indexed - new name (huffman encoded)
14: Sends a dynamic table size update
✔ 14: Sends a dynamic table size update
15: Sends multiple dynamic table size update
✔ 15: Sends multiple dynamic table size update
Hypertext Transfer Protocol Version 2 (HTTP/2)
3. Starting HTTP/2
3.5. HTTP/2 Connection Preface
1: Sends client connection preface
✔ 1: Sends client connection preface
2: Sends invalid connection preface
✔ 2: Sends invalid connection preface
4. HTTP Frames
4.1. Frame Format
1: Sends a frame with unknown type
✔ 1: Sends a frame with unknown type
2: Sends a frame with undefined flag
✔ 2: Sends a frame with undefined flag
3: Sends a frame with reserved field bit
✔ 3: Sends a frame with reserved field bit
4.2. Frame Size
1: Sends a DATA frame with 2^14 octets in length
✔ 1: Sends a DATA frame with 2^14 octets in length
2: Sends a large size DATA frame that exceeds the SETTINGS_MAX_FRAME_SIZE
✔ 2: Sends a large size DATA frame that exceeds the SETTINGS_MAX_FRAME_SIZE
3: Sends a large size HEADERS frame that exceeds the SETTINGS_MAX_FRAME_SIZE
× 3: Sends a large size HEADERS frame that exceeds the SETTINGS_MAX_FRAME_SIZE
-> The endpoint MUST respond with a connection error of type FRAME_SIZE_ERROR.
Expected: GOAWAY Frame (Error Code: FRAME_SIZE_ERROR)
Connection closed
Actual: DATA Frame (length:63, flags:0x01, stream_id:1)
4.3. Header Compression and Decompression
1: Sends invalid header block fragment
✔ 1: Sends invalid header block fragment
2: Sends a PRIORITY frame while sending the header blocks
✔ 2: Sends a PRIORITY frame while sending the header blocks
3: Sends a HEADERS frame to another stream while sending the header blocks
✔ 3: Sends a HEADERS frame to another stream while sending the header blocks
5. Streams and Multiplexing
5.1. Stream States
1: idle: Sends a DATA frame
✔ 1: idle: Sends a DATA frame
2: idle: Sends a RST_STREAM frame
✔ 2: idle: Sends a RST_STREAM frame
3: idle: Sends a WINDOW_UPDATE frame
✔ 3: idle: Sends a WINDOW_UPDATE frame
4: idle: Sends a CONTINUATION frame
✔ 4: idle: Sends a CONTINUATION frame
5: half closed (remote): Sends a DATA frame
✔ 5: half closed (remote): Sends a DATA frame
6: half closed (remote): Sends a HEADERS frame
✔ 6: half closed (remote): Sends a HEADERS frame
7: half closed (remote): Sends a CONTINUATION frame
✔ 7: half closed (remote): Sends a CONTINUATION frame
8: closed: Sends a DATA frame after sending RST_STREAM frame
✔ 8: closed: Sends a DATA frame after sending RST_STREAM frame
9: closed: Sends a HEADERS frame after sending RST_STREAM frame
✔ 9: closed: Sends a HEADERS frame after sending RST_STREAM frame
10: closed: Sends a CONTINUATION frame after sending RST_STREAM frame
✔ 10: closed: Sends a CONTINUATION frame after sending RST_STREAM frame
11: closed: Sends a DATA frame
✔ 11: closed: Sends a DATA frame
12: closed: Sends a HEADERS frame
✔ 12: closed: Sends a HEADERS frame
13: closed: Sends a CONTINUATION frame
✔ 13: closed: Sends a CONTINUATION frame
5.1.1. Stream Identifiers
1: Sends even-numbered stream identifier
✔ 1: Sends even-numbered stream identifier
2: Sends stream identifier that is numerically smaller than previous
✔ 2: Sends stream identifier that is numerically smaller than previous
5.1.2. Stream Concurrency
1: Sends HEADERS frames that causes their advertised concurrent stream limit to be exceeded
✔ 1: Sends HEADERS frames that causes their advertised concurrent stream limit to be exceeded
5.3. Stream Priority
5.3.1. Stream Dependencies
1: Sends HEADERS frame that depend on itself
✔ 1: Sends HEADERS frame that depend on itself
2: Sends PRIORITY frame that depend on itself
✔ 2: Sends PRIORITY frame that depend on itself
5.4. Error Handling
5.4.1. Connection Error Handling
1: Sends an invalid PING frame for connection close
✔ 1: Sends an invalid PING frame for connection close
5.5. Extending HTTP/2
1: Sends an unknown extension frame
✔ 1: Sends an unknown extension frame
2: Sends an unknown extension frame in the middle of a header block
✔ 2: Sends an unknown extension frame in the middle of a header block
6. Frame Definitions
6.1. DATA
1: Sends a DATA frame with 0x0 stream identifier
✔ 1: Sends a DATA frame with 0x0 stream identifier
2: Sends a DATA frame on the stream that is not in "open" or "half-closed (local)" state
✔ 2: Sends a DATA frame on the stream that is not in "open" or "half-closed (local)" state
3: Sends a DATA frame with invalid pad length
✔ 3: Sends a DATA frame with invalid pad length
6.2. HEADERS
1: Sends a HEADERS frame without the END_HEADERS flag, and a PRIORITY frame
✔ 1: Sends a HEADERS frame without the END_HEADERS flag, and a PRIORITY frame
2: Sends a HEADERS frame to another stream while sending a HEADERS frame
✔ 2: Sends a HEADERS frame to another stream while sending a HEADERS frame
3: Sends a HEADERS frame with 0x0 stream identifier
✔ 3: Sends a HEADERS frame with 0x0 stream identifier
4: Sends a HEADERS frame with invalid pad length
✔ 4: Sends a HEADERS frame with invalid pad length
6.3. PRIORITY
1: Sends a PRIORITY frame with 0x0 stream identifier
✔ 1: Sends a PRIORITY frame with 0x0 stream identifier
2: Sends a PRIORITY frame with a length other than 5 octets
✔ 2: Sends a PRIORITY frame with a length other than 5 octets
6.4. RST_STREAM
1: Sends a RST_STREAM frame with 0x0 stream identifier
✔ 1: Sends a RST_STREAM frame with 0x0 stream identifier
2: Sends a RST_STREAM frame on a idle stream
✔ 2: Sends a RST_STREAM frame on a idle stream
3: Sends a RST_STREAM frame with a length other than 4 octets
✔ 3: Sends a RST_STREAM frame with a length other than 4 octets
6.5. SETTINGS
1: Sends a SETTINGS frame with ACK flag and payload
✔ 1: Sends a SETTINGS frame with ACK flag and payload
2: Sends a SETTINGS frame with a stream identifier other than 0x0
✔ 2: Sends a SETTINGS frame with a stream identifier other than 0x0
3: Sends a SETTINGS frame with a length other than a multiple of 6 octets
✔ 3: Sends a SETTINGS frame with a length other than a multiple of 6 octets
6.5.2. Defined SETTINGS Parameters
1: SETTINGS_ENABLE_PUSH (0x2): Sends the value other than 0 or 1
✔ 1: SETTINGS_ENABLE_PUSH (0x2): Sends the value other than 0 or 1
2: SETTINGS_INITIAL_WINDOW_SIZE (0x4): Sends the value above the maximum flow control window size
✔ 2: SETTINGS_INITIAL_WINDOW_SIZE (0x4): Sends the value above the maximum flow control window size
3: SETTINGS_MAX_FRAME_SIZE (0x5): Sends the value below the initial value
✔ 3: SETTINGS_MAX_FRAME_SIZE (0x5): Sends the value below the initial value
4: SETTINGS_MAX_FRAME_SIZE (0x5): Sends the value above the maximum allowed frame size
✔ 4: SETTINGS_MAX_FRAME_SIZE (0x5): Sends the value above the maximum allowed frame size
5: Sends a SETTINGS frame with unknown identifier
✔ 5: Sends a SETTINGS frame with unknown identifier
6.5.3. Settings Synchronization
1: Sends multiple values of SETTINGS_INITIAL_WINDOW_SIZE
× 1: Sends multiple values of SETTINGS_INITIAL_WINDOW_SIZE
-> The endpoint MUST process the values in the settings in the order they apper.
Expected: SETTINGS Frame (length:0, flags:0x01, stream_id:0)
Actual: Connection closed
2: Sends a SETTINGS frame without ACK flag
✔ 2: Sends a SETTINGS frame without ACK flag
6.7. PING
1: Sends a PING frame
✔ 1: Sends a PING frame
2: Sends a PING frame with ACK
✔ 2: Sends a PING frame with ACK
3: Sends a PING frame with a stream identifier field value other than 0x0
✔ 3: Sends a PING frame with a stream identifier field value other than 0x0
4: Sends a PING frame with a length field value other than 8
✔ 4: Sends a PING frame with a length field value other than 8
6.8. GOAWAY
1: Sends a GOAWAY frame with a stream identifier other than 0x0
✔ 1: Sends a GOAWAY frame with a stream identifier other than 0x0
6.9. WINDOW_UPDATE
1: Sends a WINDOW_UPDATE frame with a flow control window increment of 0
✔ 1: Sends a WINDOW_UPDATE frame with a flow control window increment of 0
2: Sends a WINDOW_UPDATE frame with a flow control window increment of 0 on a stream
✔ 2: Sends a WINDOW_UPDATE frame with a flow control window increment of 0 on a stream
3: Sends a WINDOW_UPDATE frame with a length other than 4 octets
✔ 3: Sends a WINDOW_UPDATE frame with a length other than 4 octets
6.9.1. The Flow-Control Window
1: Sends SETTINGS frame to set the initial window size to 1 and sends HEADERS frame
✔ 1: Sends SETTINGS frame to set the initial window size to 1 and sends HEADERS frame
2: Sends multiple WINDOW_UPDATE frames increasing the flow control window to above 2^31-1
✔ 2: Sends multiple WINDOW_UPDATE frames increasing the flow control window to above 2^31-1
3: Sends multiple WINDOW_UPDATE frames increasing the flow control window to above 2^31-1 on a stream
✔ 3: Sends multiple WINDOW_UPDATE frames increasing the flow control window to above 2^31-1 on a stream
6.9.2. Initial Flow-Control Window Size
1: Changes SETTINGS_INITIAL_WINDOW_SIZE after sending HEADERS frame
✔ 1: Changes SETTINGS_INITIAL_WINDOW_SIZE after sending HEADERS frame
2: Sends a SETTINGS frame for window size to be negative
2: Sends a SETTINGS frame for window size to be negative
3: Sends a SETTINGS_INITIAL_WINDOW_SIZE settings with an exceeded maximum window size value
✔ 3: Sends a SETTINGS_INITIAL_WINDOW_SIZE settings with an exceeded maximum window size value
6.10. CONTINUATION
1: Sends multiple CONTINUATION frames preceded by a HEADERS frame
✔ 1: Sends multiple CONTINUATION frames preceded by a HEADERS frame
2: Sends a CONTINUATION frame followed by any frame other than CONTINUATION
File diff suppressed because it is too large Load Diff
-197
View File
@@ -1,197 +0,0 @@
Start 2026-11-18 18:02:54 -->> 127.0.0.1:30028 (localhost) <<--
A record via: supplied IP "127.0.0.1"
rDNS (127.0.0.1): localhost. kubernetes.docker.internal.
Service detected: HTTP
Testing protocols via sockets except NPN+ALPN
SSLv2 not offered (OK)
SSLv3 not offered (OK)
TLS 1 not offered
TLS 1.1 not offered
TLS 1.2 offered (OK)
TLS 1.3 offered (OK): final
NPN/SPDY not offered
ALPN/HTTP2 h2, http/1.1 (offered)
Testing cipher categories
NULL ciphers (no encryption) not offered (OK)
Anonymous NULL Ciphers (no authentication) not offered (OK)
Export ciphers (w/o ADH+NULL) not offered (OK)
LOW: 64 Bit + DES, RC[2,4], MD5 (w/o export) not offered (OK)
Triple DES Ciphers / IDEA not offered
Obsoleted CBC ciphers (AES, ARIA etc.) not offered
Strong encryption (AEAD ciphers) with no FS not offered
Forward Secrecy strong encryption (AEAD ciphers) offered (OK)
Testing server's cipher preferences
Hexcode Cipher Suite Name (OpenSSL) KeyExch. Encryption Bits Cipher Suite Name (IANA/RFC)
-----------------------------------------------------------------------------------------------------------------------------
SSLv2
-
SSLv3
-
TLSv1
-
TLSv1.1
-
TLSv1.2 (server order -- server prioritizes ChaCha ciphers when preferred by clients)
xc02b ECDHE-ECDSA-AES128-GCM-SHA256 ECDH 253 AESGCM 128 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
xc02c ECDHE-ECDSA-AES256-GCM-SHA384 ECDH 253 AESGCM 256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
xcca9 ECDHE-ECDSA-CHACHA20-POLY1305 ECDH 253 ChaCha20 256 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
TLSv1.3 (no server order, thus listed by strength)
x1302 TLS_AES_256_GCM_SHA384 ECDH/MLKEM AESGCM 256 TLS_AES_256_GCM_SHA384
x1303 TLS_CHACHA20_POLY1305_SHA256 ECDH/MLKEM ChaCha20 256 TLS_CHACHA20_POLY1305_SHA256
x1301 TLS_AES_128_GCM_SHA256 ECDH/MLKEM AESGCM 128 TLS_AES_128_GCM_SHA256
Has server cipher order? yes (OK) -- only for < TLS 1.3
Testing robust forward secrecy (FS) -- omitting Null Authentication/Encryption, 3DES, RC4
FS is offered (OK) TLS_AES_256_GCM_SHA384
TLS_CHACHA20_POLY1305_SHA256
ECDHE-ECDSA-AES256-GCM-SHA384
ECDHE-ECDSA-CHACHA20-POLY1305
TLS_AES_128_GCM_SHA256
ECDHE-ECDSA-AES128-GCM-SHA256
KEMs offered X25519MLKEM768
Elliptic curves offered: prime256v1 X25519
TLS 1.2 sig_algs offered: ECDSA+SHA512 ECDSA+SHA384 ECDSA+SHA256
TLS 1.3 sig_algs offered: ECDSA+SHA256
Testing server defaults (Server Hello)
TLS extensions (standard) "server name/#0" "EC point formats/#11"
"application layer protocol negotiation/#16"
"extended master secret/#23" "session ticket/#35"
"supported versions/#43" "key share/#51"
"renegotiation info/#65281"
Session Ticket RFC 5077 hint 604800 seconds but: FS requires session ticket keys to be rotated < daily !
SSL Session ID support yes
Session Resumption Tickets: yes, ID: yes
TLS clock skew Random values, no fingerprinting possible
Certificate Compression none
Client Authentication none
Signature Algorithm ECDSA with SHA256
Server key size EC 256 bits (curve P-256)
Server key usage Digital Signature
Server extended key usage TLS Web Server Authentication
Serial 29F7BED5DF8BBC472F523278F287E910BD19DC07 (OK: length 20)
Fingerprints SHA1 76D4AE2FBE2B32E3C3380B7FAFFC515CF672FE23
SHA256 0D5E04B7C6D8AD0D952CD17CE75AF5B0263F167F8179214877C8B1D58A7B54AA
Common Name (CN) localhost (request w/o SNI didn't succeed, usual for EC certificates)
subjectAltName (SAN) localhost
Trust (hostname) Ok via SAN and CN (SNI mandatory)
Chain of trust Ok
EV cert (experimental) no
Certificate Validity (UTC) 755730 >= 60 days (1975-01-01 00:00 --> 4096-01-01 00:00)
>= 10 years is way too long
ETS/"eTLS", visibility info not present
Certificate Revocation List --
OCSP URI --
NOT ok -- neither CRL nor OCSP URI provided
OCSP stapling not offered
OCSP must staple extension --
DNS CAA RR (experimental) not offered
Certificate Transparency --
Certificates provided 1
Issuer Ianitor Pair Test CA
Intermediate Bad OCSP (exp.) Ok
Testing HTTP header response @ "/"
HTTP Status Code 200 OK
HTTP clock skew 0 sec from localtime
Strict Transport Security not offered
Public Key Pinning --
Server banner (no "Server" line in header, interesting!)
Application banner --
Cookie(s) (none issued at "/")
Security headers --
Reverse Proxy banner Via: 1.1 Caddy
Testing vulnerabilities
Heartbleed (CVE-2014-0160) not vulnerable (OK), no heartbeat extension
CCS (CVE-2014-0224) not vulnerable (OK)
Ticketbleed (CVE-2016-9244), experiment. not vulnerable (OK)
ROBOT Server does not support any cipher suites that use RSA key transport
Secure Renegotiation (RFC 5746) supported (OK)
Secure Client-Initiated Renegotiation not vulnerable (OK)
CRIME, TLS (CVE-2012-4929) not vulnerable (OK)
BREACH (CVE-2013-3587) no gzip/deflate/compress/br HTTP compression (OK) - only supplied "/" tested
POODLE, SSL (CVE-2014-3566) not vulnerable (OK), no SSLv3 support
TLS_FALLBACK_SCSV (RFC 7507) No fallback possible (OK), no protocol below TLS 1.2 offered
SWEET32 (CVE-2016-2183, CVE-2016-6329) not vulnerable (OK)
FREAK (CVE-2015-0204) not vulnerable (OK)
DROWN (CVE-2016-0800, CVE-2016-0703) not vulnerable on this host and port (OK)
no RSA certificate, thus certificate can't be used with SSLv2 elsewhere
LOGJAM (CVE-2015-4000), experimental not vulnerable (OK): no DH EXPORT ciphers, no DH key detected with <= TLS 1.2
BEAST (CVE-2011-3389) not vulnerable (OK), no SSL3 or TLS1
LUCKY13 (CVE-2013-0169), experimental not vulnerable (OK)
Winshock (CVE-2014-6321), experimental not vulnerable (OK)
RC4 (CVE-2013-2566, CVE-2015-2808) no RC4 ciphers detected (OK)
Running client simulations (HTTP) via sockets
Browser Protocol Cipher Suite Name (OpenSSL) Forward Secrecy
------------------------------------------------------------------------------------------------
Android 7.0 (native) TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 256 bit ECDH (P-256)
Android 8.1 (native) TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 253 bit ECDH (X25519)
Android 9.0 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Android 10.0 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Android 11/12 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Android 13/14 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Android 15 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 X25519MLKEM768
Chrome 101 (Win 10) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Chromium 137 (Win 11) TLSv1.3 TLS_AES_128_GCM_SHA256 X25519MLKEM768
Firefox 100 (Win 10) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Firefox 137 (Win 11) TLSv1.3 TLS_AES_128_GCM_SHA256 X25519MLKEM768
IE 8 Win 7 No connection
IE 11 Win 7 TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 256 bit ECDH (P-256)
IE 11 Win 8.1 TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 256 bit ECDH (P-256)
IE 11 Win Phone 8.1 TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 256 bit ECDH (P-256)
IE 11 Win 10 TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 256 bit ECDH (P-256)
Edge 15 Win 10 TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 253 bit ECDH (X25519)
Edge 101 Win 10 21H2 TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Edge 133 Win 11 23H2 TLSv1.3 TLS_AES_128_GCM_SHA256 X25519MLKEM768
Safari 18.4 (iOS 18.4) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Safari 15.4 (macOS 12.3.1) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Safari 18.4 (macOS 15.4) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Java 7u25 No connection
Java 8u442 (OpenJDK) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Java 11.0.2 (OpenJDK) TLSv1.3 TLS_AES_128_GCM_SHA256 256 bit ECDH (P-256)
Java 17.0.3 (OpenJDK) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Java 21.0.6 (OpenJDK) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
go 1.17.8 TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
LibreSSL 3.3.6 (macOS) TLSv1.3 TLS_CHACHA20_POLY1305_SHA256 253 bit ECDH (X25519)
OpenSSL 1.0.2e TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 256 bit ECDH (P-256)
OpenSSL 1.1.1d (Debian) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
OpenSSL 3.0.15 (Debian) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
OpenSSL 3.5.0 (git) TLSv1.3 TLS_AES_128_GCM_SHA256 X25519MLKEM768
Apple Mail (16.0) TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 256 bit ECDH (P-256)
Thunderbird (91.9) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Rating (experimental)
Rating specs (not complete) SSL Labs's 'SSL Server Rating Guide' (version 2009r from 2025-05-16)
Specification documentation https://github.com/ssllabs/research/wiki/SSL-Server-Rating-Guide
Protocol Support (weighted) 100 (30)
Key Exchange (weighted) 100 (30)
Cipher Strength (weighted) 90 (36)
Final Score 96
Overall Grade A+
Done 2026-11-18 18:05:17 [ 150s] -->> 127.0.0.1:30028 (localhost) <<--
-261
View File
@@ -1,261 +0,0 @@
Generic tests for HTTP/2 server
1. Starting HTTP/2
1: Sends a client connection preface
✔ 1: Sends a client connection preface
2. Streams and Multiplexing
1: Sends a PRIORITY frame on idle stream
✔ 1: Sends a PRIORITY frame on idle stream
2: Sends a WINDOW_UPDATE frame on half-closed (remote) stream
✔ 2: Sends a WINDOW_UPDATE frame on half-closed (remote) stream
3: Sends a PRIORITY frame on half-closed (remote) stream
✔ 3: Sends a PRIORITY frame on half-closed (remote) stream
4: Sends a RST_STREAM frame on half-closed (remote) stream
✔ 4: Sends a RST_STREAM frame on half-closed (remote) stream
5: Sends a PRIORITY frame on closed stream
✔ 5: Sends a PRIORITY frame on closed stream
3. Frame Definitions
3.1. DATA
1: Sends a DATA frame
✔ 1: Sends a DATA frame
2: Sends multiple DATA frames
✔ 2: Sends multiple DATA frames
3: Sends a DATA frame with padding
✔ 3: Sends a DATA frame with padding
3.2. HEADERS
1: Sends a HEADERS frame
✔ 1: Sends a HEADERS frame
2: Sends a HEADERS frame with padding
✔ 2: Sends a HEADERS frame with padding
3: Sends a HEADERS frame with priority
✔ 3: Sends a HEADERS frame with priority
3.3. PRIORITY
1: Sends a PRIORITY frame with priority 1
✔ 1: Sends a PRIORITY frame with priority 1
2: Sends a PRIORITY frame with priority 256
✔ 2: Sends a PRIORITY frame with priority 256
3: Sends a PRIORITY frame with stream dependency
✔ 3: Sends a PRIORITY frame with stream dependency
4: Sends a PRIORITY frame with exclusive
✔ 4: Sends a PRIORITY frame with exclusive
5: Sends a PRIORITY frame for an idle stream, then send a HEADER frame for a lower stream ID
✔ 5: Sends a PRIORITY frame for an idle stream, then send a HEADER frame for a lower stream ID
3.4. RST_STREAM
1: Sends a RST_STREAM frame
✔ 1: Sends a RST_STREAM frame
3.5. SETTINGS
1: Sends a SETTINGS frame
✔ 1: Sends a SETTINGS frame
3.7. PING
1: Sends a PING frame
✔ 1: Sends a PING frame
3.8. GOAWAY
1: Sends a GOAWAY frame
✔ 1: Sends a GOAWAY frame
3.9. WINDOW_UPDATE
1: Sends a WINDOW_UPDATE frame with stream ID 0
✔ 1: Sends a WINDOW_UPDATE frame with stream ID 0
2: Sends a WINDOW_UPDATE frame with stream ID 1
✔ 2: Sends a WINDOW_UPDATE frame with stream ID 1
3.10. CONTINUATION
1: Sends a CONTINUATION frame
✔ 1: Sends a CONTINUATION frame
2: Sends multiple CONTINUATION frames
✔ 2: Sends multiple CONTINUATION frames
4. HTTP Message Exchanges
1: Sends a GET request
✔ 1: Sends a GET request
2: Sends a HEAD request
✔ 2: Sends a HEAD request
3: Sends a POST request
✔ 3: Sends a POST request
4: Sends a POST request with trailers
✔ 4: Sends a POST request with trailers
5. HPACK
1: Sends a indexed header field representation
✔ 1: Sends a indexed header field representation
2: Sends a literal header field with incremental indexing - indexed name
✔ 2: Sends a literal header field with incremental indexing - indexed name
3: Sends a literal header field with incremental indexing - indexed name (with Huffman coding)
✔ 3: Sends a literal header field with incremental indexing - indexed name (with Huffman coding)
4: Sends a literal header field with incremental indexing - new name
✔ 4: Sends a literal header field with incremental indexing - new name
5: Sends a literal header field with incremental indexing - new name (with Huffman coding)
✔ 5: Sends a literal header field with incremental indexing - new name (with Huffman coding)
6: Sends a literal header field without indexing - indexed name
✔ 6: Sends a literal header field without indexing - indexed name
7: Sends a literal header field without indexing - indexed name (with Huffman coding)
✔ 7: Sends a literal header field without indexing - indexed name (with Huffman coding)
8: Sends a literal header field without indexing - new name
✔ 8: Sends a literal header field without indexing - new name
9: Sends a literal header field without indexing - new name (huffman encoded)
✔ 9: Sends a literal header field without indexing - new name (huffman encoded)
10: Sends a literal header field never indexed - indexed name
✔ 10: Sends a literal header field never indexed - indexed name
11: Sends a literal header field never indexed - indexed name (huffman encoded)
✔ 11: Sends a literal header field never indexed - indexed name (huffman encoded)
12: Sends a literal header field never indexed - new name
✔ 12: Sends a literal header field never indexed - new name
13: Sends a literal header field never indexed - new name (huffman encoded)
✔ 13: Sends a literal header field never indexed - new name (huffman encoded)
14: Sends a dynamic table size update
✔ 14: Sends a dynamic table size update
15: Sends multiple dynamic table size update
✔ 15: Sends multiple dynamic table size update
Hypertext Transfer Protocol Version 2 (HTTP/2)
3. Starting HTTP/2
3.5. HTTP/2 Connection Preface
1: Sends client connection preface
✔ 1: Sends client connection preface
2: Sends invalid connection preface
✔ 2: Sends invalid connection preface
4. HTTP Frames
4.1. Frame Format
1: Sends a frame with unknown type
✔ 1: Sends a frame with unknown type
2: Sends a frame with undefined flag
✔ 2: Sends a frame with undefined flag
3: Sends a frame with reserved field bit
✔ 3: Sends a frame with reserved field bit
4.2. Frame Size
1: Sends a DATA frame with 2^14 octets in length
✔ 1: Sends a DATA frame with 2^14 octets in length
2: Sends a large size DATA frame that exceeds the SETTINGS_MAX_FRAME_SIZE
✔ 2: Sends a large size DATA frame that exceeds the SETTINGS_MAX_FRAME_SIZE
3: Sends a large size HEADERS frame that exceeds the SETTINGS_MAX_FRAME_SIZE
✔ 3: Sends a large size HEADERS frame that exceeds the SETTINGS_MAX_FRAME_SIZE
4.3. Header Compression and Decompression
1: Sends invalid header block fragment
✔ 1: Sends invalid header block fragment
2: Sends a PRIORITY frame while sending the header blocks
✔ 2: Sends a PRIORITY frame while sending the header blocks
3: Sends a HEADERS frame to another stream while sending the header blocks
✔ 3: Sends a HEADERS frame to another stream while sending the header blocks
5. Streams and Multiplexing
5.1. Stream States
1: idle: Sends a DATA frame
✔ 1: idle: Sends a DATA frame
2: idle: Sends a RST_STREAM frame
✔ 2: idle: Sends a RST_STREAM frame
3: idle: Sends a WINDOW_UPDATE frame
✔ 3: idle: Sends a WINDOW_UPDATE frame
4: idle: Sends a CONTINUATION frame
✔ 4: idle: Sends a CONTINUATION frame
5: half closed (remote): Sends a DATA frame
✔ 5: half closed (remote): Sends a DATA frame
6: half closed (remote): Sends a HEADERS frame
✔ 6: half closed (remote): Sends a HEADERS frame
7: half closed (remote): Sends a CONTINUATION frame
✔ 7: half closed (remote): Sends a CONTINUATION frame
8: closed: Sends a DATA frame after sending RST_STREAM frame
✔ 8: closed: Sends a DATA frame after sending RST_STREAM frame
9: closed: Sends a HEADERS frame after sending RST_STREAM frame
✔ 9: closed: Sends a HEADERS frame after sending RST_STREAM frame
10: closed: Sends a CONTINUATION frame after sending RST_STREAM frame
✔ 10: closed: Sends a CONTINUATION frame after sending RST_STREAM frame
11: closed: Sends a DATA frame
✔ 11: closed: Sends a DATA frame
12: closed: Sends a HEADERS frame
✔ 12: closed: Sends a HEADERS frame
13: closed: Sends a CONTINUATION frame
✔ 13: closed: Sends a CONTINUATION frame
5.1.1. Stream Identifiers
1: Sends even-numbered stream identifier
✔ 1: Sends even-numbered stream identifier
2: Sends stream identifier that is numerically smaller than previous
✔ 2: Sends stream identifier that is numerically smaller than previous
5.1.2. Stream Concurrency
1: Sends HEADERS frames that causes their advertised concurrent stream limit to be exceeded
✔ 1: Sends HEADERS frames that causes their advertised concurrent stream limit to be exceeded
5.3. Stream Priority
5.3.1. Stream Dependencies
1: Sends HEADERS frame that depend on itself
✔ 1: Sends HEADERS frame that depend on itself
2: Sends PRIORITY frame that depend on itself
✔ 2: Sends PRIORITY frame that depend on itself
5.4. Error Handling
5.4.1. Connection Error Handling
1: Sends an invalid PING frame for connection close
✔ 1: Sends an invalid PING frame for connection close
5.5. Extending HTTP/2
1: Sends an unknown extension frame
✔ 1: Sends an unknown extension frame
2: Sends an unknown extension frame in the middle of a header block
✔ 2: Sends an unknown extension frame in the middle of a header block
6. Frame Definitions
6.1. DATA
1: Sends a DATA frame with 0x0 stream identifier
✔ 1: Sends a DATA frame with 0x0 stream identifier
2: Sends a DATA frame on the stream that is not in "open" or "half-closed (local)" state
✔ 2: Sends a DATA frame on the stream that is not in "open" or "half-closed (local)" state
3: Sends a DATA frame with invalid pad length
✔ 3: Sends a DATA frame with invalid pad length
6.2. HEADERS
1: Sends a HEADERS frame without the END_HEADERS flag, and a PRIORITY frame
✔ 1: Sends a HEADERS frame without the END_HEADERS flag, and a PRIORITY frame
2: Sends a HEADERS frame to another stream while sending a HEADERS frame
✔ 2: Sends a HEADERS frame to another stream while sending a HEADERS frame
3: Sends a HEADERS frame with 0x0 stream identifier
✔ 3: Sends a HEADERS frame with 0x0 stream identifier
4: Sends a HEADERS frame with invalid pad length
✔ 4: Sends a HEADERS frame with invalid pad length
6.3. PRIORITY
1: Sends a PRIORITY frame with 0x0 stream identifier
✔ 1: Sends a PRIORITY frame with 0x0 stream identifier
2: Sends a PRIORITY frame with a length other than 5 octets
✔ 2: Sends a PRIORITY frame with a length other than 5 octets
6.4. RST_STREAM
1: Sends a RST_STREAM frame with 0x0 stream identifier
✔ 1: Sends a RST_STREAM frame with 0x0 stream identifier
2: Sends a RST_STREAM frame on a idle stream
✔ 2: Sends a RST_STREAM frame on a idle stream
3: Sends a RST_STREAM frame with a length other than 4 octets
✔ 3: Sends a RST_STREAM frame with a length other than 4 octets
6.5. SETTINGS
1: Sends a SETTINGS frame with ACK flag and payload
✔ 1: Sends a SETTINGS frame with ACK flag and payload
2: Sends a SETTINGS frame with a stream identifier other than 0x0
✔ 2: Sends a SETTINGS frame with a stream identifier other than 0x0
3: Sends a SETTINGS frame with a length other than a multiple of 6 octets
✔ 3: Sends a SETTINGS frame with a length other than a multiple of 6 octets
6.5.2. Defined SETTINGS Parameters
1: SETTINGS_ENABLE_PUSH (0x2): Sends the value other than 0 or 1
✔ 1: SETTINGS_ENABLE_PUSH (0x2): Sends the value other than 0 or 1
2: SETTINGS_INITIAL_WINDOW_SIZE (0x4): Sends the value above the maximum flow control window size
✔ 2: SETTINGS_INITIAL_WINDOW_SIZE (0x4): Sends the value above the maximum flow control window size
3: SETTINGS_MAX_FRAME_SIZE (0x5): Sends the value below the initial value
✔ 3: SETTINGS_MAX_FRAME_SIZE (0x5): Sends the value below the initial value
4: SETTINGS_MAX_FRAME_SIZE (0x5): Sends the value above the maximum allowed frame size
✔ 4: SETTINGS_MAX_FRAME_SIZE (0x5): Sends the value above the maximum allowed frame size
5: Sends a SETTINGS frame with unknown identifier
✔ 5: Sends a SETTINGS frame with unknown identifier
6.5.3. Settings Synchronization
1: Sends multiple values of SETTINGS_INITIAL_WINDOW_SIZE
File diff suppressed because it is too large Load Diff
-196
View File
@@ -1,196 +0,0 @@
Start 2026-11-18 18:00:21 -->> 127.0.0.1:24056 (localhost) <<--
A record via: supplied IP "127.0.0.1"
rDNS (127.0.0.1): localhost. kubernetes.docker.internal.
Service detected: HTTP
Testing protocols via sockets except NPN+ALPN
SSLv2 not offered (OK)
SSLv3 not offered (OK)
TLS 1 not offered
TLS 1.1 not offered
TLS 1.2 offered (OK)
TLS 1.3 offered (OK): final
NPN/SPDY not offered
ALPN/HTTP2 h2, http/1.1 (offered)
Testing cipher categories
NULL ciphers (no encryption) not offered (OK)
Anonymous NULL Ciphers (no authentication) not offered (OK)
Export ciphers (w/o ADH+NULL) not offered (OK)
LOW: 64 Bit + DES, RC[2,4], MD5 (w/o export) not offered (OK)
Triple DES Ciphers / IDEA not offered
Obsoleted CBC ciphers (AES, ARIA etc.) not offered
Strong encryption (AEAD ciphers) with no FS not offered
Forward Secrecy strong encryption (AEAD ciphers) offered (OK)
Testing server's cipher preferences
Hexcode Cipher Suite Name (OpenSSL) KeyExch. Encryption Bits Cipher Suite Name (IANA/RFC)
-----------------------------------------------------------------------------------------------------------------------------
SSLv2
-
SSLv3
-
TLSv1
-
TLSv1.1
-
TLSv1.2 (no server order, thus listed by strength)
xc02c ECDHE-ECDSA-AES256-GCM-SHA384 ECDH 253 AESGCM 256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
xcca9 ECDHE-ECDSA-CHACHA20-POLY1305 ECDH 253 ChaCha20 256 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
xc02b ECDHE-ECDSA-AES128-GCM-SHA256 ECDH 253 AESGCM 128 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
TLSv1.3 (no server order, thus listed by strength)
x1302 TLS_AES_256_GCM_SHA384 ECDH 253 AESGCM 256 TLS_AES_256_GCM_SHA384
x1303 TLS_CHACHA20_POLY1305_SHA256 ECDH 253 ChaCha20 256 TLS_CHACHA20_POLY1305_SHA256
x1301 TLS_AES_128_GCM_SHA256 ECDH 253 AESGCM 128 TLS_AES_128_GCM_SHA256
Has server cipher order? no
(limited sense as client will pick)
Testing robust forward secrecy (FS) -- omitting Null Authentication/Encryption, 3DES, RC4
FS is offered (OK) TLS_AES_256_GCM_SHA384
TLS_CHACHA20_POLY1305_SHA256
ECDHE-ECDSA-AES256-GCM-SHA384
ECDHE-ECDSA-CHACHA20-POLY1305
TLS_AES_128_GCM_SHA256
ECDHE-ECDSA-AES128-GCM-SHA256
Elliptic curves offered: prime256v1 secp384r1 X25519
TLS 1.2 sig_algs offered: ECDSA+SHA256
TLS 1.3 sig_algs offered: ECDSA+SHA256
Testing server defaults (Server Hello)
TLS extensions (standard) "server name/#0"
"application layer protocol negotiation/#16"
"extended master secret/#23"
"supported versions/#43" "key share/#51"
"renegotiation info/#65281"
Session Ticket RFC 5077 hint 86400 seconds, session tickets keys seems to be rotated < daily
SSL Session ID support yes
Session Resumption Tickets: yes, ID: yes
TLS clock skew Random values, no fingerprinting possible
Certificate Compression none
Client Authentication none
Signature Algorithm ECDSA with SHA256
Server key size EC 256 bits (curve P-256)
Server key usage Digital Signature
Server extended key usage TLS Web Server Authentication
Serial 29F7BED5DF8BBC472F523278F287E910BD19DC07 (OK: length 20)
Fingerprints SHA1 76D4AE2FBE2B32E3C3380B7FAFFC515CF672FE23
SHA256 0D5E04B7C6D8AD0D952CD17CE75AF5B0263F167F8179214877C8B1D58A7B54AA
Common Name (CN) localhost (request w/o SNI didn't succeed, usual for EC certificates)
subjectAltName (SAN) localhost
Trust (hostname) Ok via SAN and CN (SNI mandatory)
Chain of trust Ok
EV cert (experimental) no
Certificate Validity (UTC) 755730 >= 60 days (1975-01-01 00:00 --> 4096-01-01 00:00)
>= 10 years is way too long
ETS/"eTLS", visibility info not present
Certificate Revocation List --
OCSP URI --
NOT ok -- neither CRL nor OCSP URI provided
OCSP stapling not offered
OCSP must staple extension --
DNS CAA RR (experimental) not offered
Certificate Transparency --
Certificates provided 1
Issuer Ianitor Pair Test CA
Intermediate Bad OCSP (exp.) Ok
Testing HTTP header response @ "/"
HTTP Status Code 200 OK
HTTP clock skew 0 sec from localtime
Strict Transport Security not offered
Public Key Pinning --
Server banner (no "Server" line in header, interesting!)
Application banner --
Cookie(s) (none issued at "/")
Security headers --
Reverse Proxy banner --
Testing vulnerabilities
Heartbleed (CVE-2014-0160) not vulnerable (OK), no heartbeat extension
CCS (CVE-2014-0224) not vulnerable (OK)
Ticketbleed (CVE-2016-9244), experiment. not vulnerable (OK), no session ticket extension
ROBOT Server does not support any cipher suites that use RSA key transport
Secure Renegotiation (RFC 5746) supported (OK)
Secure Client-Initiated Renegotiation not vulnerable (OK) -- mitigated (1 successful reneg within 10 in 33s(timeout))
CRIME, TLS (CVE-2012-4929) not vulnerable (OK)
BREACH (CVE-2013-3587) no gzip/deflate/compress/br HTTP compression (OK) - only supplied "/" tested
POODLE, SSL (CVE-2014-3566) not vulnerable (OK), no SSLv3 support
TLS_FALLBACK_SCSV (RFC 7507) No fallback possible (OK), no protocol below TLS 1.2 offered
SWEET32 (CVE-2016-2183, CVE-2016-6329) not vulnerable (OK)
FREAK (CVE-2015-0204) not vulnerable (OK)
DROWN (CVE-2016-0800, CVE-2016-0703) not vulnerable on this host and port (OK)
no RSA certificate, thus certificate can't be used with SSLv2 elsewhere
LOGJAM (CVE-2015-4000), experimental not vulnerable (OK): no DH EXPORT ciphers, no DH key detected with <= TLS 1.2
BEAST (CVE-2011-3389) not vulnerable (OK), no SSL3 or TLS1
LUCKY13 (CVE-2013-0169), experimental not vulnerable (OK)
Winshock (CVE-2014-6321), experimental not vulnerable (OK)
RC4 (CVE-2013-2566, CVE-2015-2808) no RC4 ciphers detected (OK)
Running client simulations (HTTP) via sockets
Browser Protocol Cipher Suite Name (OpenSSL) Forward Secrecy
------------------------------------------------------------------------------------------------
Android 7.0 (native) TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 256 bit ECDH (P-256)
Android 8.1 (native) TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 253 bit ECDH (X25519)
Android 9.0 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Android 10.0 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Android 11/12 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Android 13/14 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Android 15 (native) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Chrome 101 (Win 10) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Chromium 137 (Win 11) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Firefox 100 (Win 10) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Firefox 137 (Win 11) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
IE 8 Win 7 No connection
IE 11 Win 7 TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 256 bit ECDH (P-256)
IE 11 Win 8.1 TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 256 bit ECDH (P-256)
IE 11 Win Phone 8.1 TLSv1.2 ECDHE-ECDSA-AES128-GCM-SHA256 256 bit ECDH (P-256)
IE 11 Win 10 TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 256 bit ECDH (P-256)
Edge 15 Win 10 TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 253 bit ECDH (X25519)
Edge 101 Win 10 21H2 TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Edge 133 Win 11 23H2 TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Safari 18.4 (iOS 18.4) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Safari 15.4 (macOS 12.3.1) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Safari 18.4 (macOS 15.4) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Java 7u25 No connection
Java 8u442 (OpenJDK) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519)
Java 11.0.2 (OpenJDK) TLSv1.3 TLS_AES_128_GCM_SHA256 256 bit ECDH (P-256)
Java 17.0.3 (OpenJDK) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519)
Java 21.0.6 (OpenJDK) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519)
go 1.17.8 TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
LibreSSL 3.3.6 (macOS) TLSv1.3 TLS_CHACHA20_POLY1305_SHA256 253 bit ECDH (X25519)
OpenSSL 1.0.2e TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 256 bit ECDH (P-256)
OpenSSL 1.1.1d (Debian) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519)
OpenSSL 3.0.15 (Debian) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519)
OpenSSL 3.5.0 (git) TLSv1.3 TLS_AES_256_GCM_SHA384 253 bit ECDH (X25519)
Apple Mail (16.0) TLSv1.2 ECDHE-ECDSA-AES256-GCM-SHA384 256 bit ECDH (P-256)
Thunderbird (91.9) TLSv1.3 TLS_AES_128_GCM_SHA256 253 bit ECDH (X25519)
Rating (experimental)
Rating specs (not complete) SSL Labs's 'SSL Server Rating Guide' (version 2009r from 2025-05-16)
Specification documentation https://github.com/ssllabs/research/wiki/SSL-Server-Rating-Guide
Protocol Support (weighted) 100 (30)
Key Exchange (weighted) 100 (30)
Cipher Strength (weighted) 90 (36)
Final Score 96
Overall Grade A+
Done 2026-11-18 18:02:27 [ 131s] -->> 127.0.0.1:24056 (localhost) <<--
-1
View File
@@ -1 +0,0 @@
{"build":"release","caddy_version":"unknown","edge_threads":2}
-33
View File
@@ -1,33 +0,0 @@
engine,scenario,connections,duration_s,requests,rps,p50_ms,p90_ms,p99_ms,max_ms,success_rate,non_2xx,rss_kb_after
ianitor,https-h1-keepalive,1,15,27924,1861,0.3,0.34,9.03,82.42,1.0,0,13228
ianitor,https-h2,1,15,32594,2173,0.37,0.41,0.77,33.56,1.0,0,13444
ianitor,https-h1-keepalive,16,15.03,57767,3843,1.85,11.28,28.77,130.96,1.0,0,15408
ianitor,https-h2,16,15,70840,4723,1.51,9.54,27.5,80.67,1.0,0,16388
ianitor,https-h1-keepalive,64,15.04,99114,6596,4.94,27.15,50.88,137.67,1.0,0,21272
ianitor,https-h2,64,15.02,176136,11726,4.55,7.93,23.21,65.82,1.0,0,24520
ianitor,https-h1-keepalive,256,15.02,66156,4421,52.26,98.36,155.59,307.77,1.0,0,38620
ianitor,https-h2,256,15,59482,3981,60.98,101.34,146.55,233.81,1.0,0,52184
ianitor,https-h1-new-conn,16,15,18250,1218,8.57,30.28,50.64,122.99,1.0,0,52200
ianitor,http-redirect,64,15,203706,13582,1.84,15.68,32.41,87.56,1.0,203706,55620
caddy,https-h1-keepalive,1,15,26362,1757,0.46,0.53,2.48,106.04,1.0,0,59828
caddy,https-h2,1,15,20631,1375,0.64,0.72,1.4,33.45,1.0,0,60084
caddy,https-h1-keepalive,16,15.01,103603,6905,0.54,2.83,45.47,162.27,1.0,0,65660
caddy,https-h2,16,15.02,91438,6090,0.74,5.56,35.64,134.4,1.0,0,69348
caddy,https-h1-keepalive,64,15.02,234993,15653,1.94,9.85,31.3,146.84,1.0,0,79068
caddy,https-h2,64,15.01,127103,8472,2.46,19.38,59.58,156.96,1.0,0,82992
caddy,https-h1-keepalive,256,15.02,189465,12632,13.37,48.12,101.94,418.37,1.0,0,130136
caddy,https-h2,256,15.09,151866,10077,19.21,53.91,101.9,464.76,1.0,0,130716
caddy,https-h1-new-conn,16,15,33531,2236,2.41,16.71,65.02,173.34,1.0,0,98300
caddy,http-redirect,64,15.02,811365,54027,0.23,2.49,16.27,82.11,1.0,811365,104520
caddy_gomaxprocs2,https-h1-keepalive,1,15,35264,2351,0.41,0.48,0.79,48.27,1.0,0,56800
caddy_gomaxprocs2,https-h2,1,15,23823,1588,0.59,0.68,1.41,27.62,1.0,0,57684
caddy_gomaxprocs2,https-h1-keepalive,16,15,116399,7759,1.57,3.49,11.23,60.1,1.0,0,61076
caddy_gomaxprocs2,https-h2,16,15,51386,3426,2.71,11,28.59,68.23,1.0,0,61652
caddy_gomaxprocs2,https-h1-keepalive,64,15.02,98458,6561,7.37,19.47,39.84,166.73,1.0,0,68012
caddy_gomaxprocs2,https-h2,64,15,85584,5708,10.26,19.29,37.34,79.44,1.0,0,68616
caddy_gomaxprocs2,https-h1-keepalive,256,15,66867,4473,52.61,92.37,147.03,218.19,1.0,0,95680
caddy_gomaxprocs2,https-h2,256,15.01,53887,3607,68.4,97.91,134.35,193.25,1.0,0,98972
caddy_gomaxprocs2,https-h1-new-conn,16,15,27335,1823,7.93,14.23,21.39,67.37,1.0,0,78728
caddy_gomaxprocs2,http-redirect,64,15,255374,17027,2.85,8.19,15.52,59.82,1.0,255374,79764
ianitor,soak-https-h1,32,300.04,1873622,6245,3.23,10.32,31.29,134.28,1.0,0,55588
caddy,soak-https-h1,32,300,3909309,13031,0.81,4,35.44,204.14,1.0,0,76592
1 engine scenario connections duration_s requests rps p50_ms p90_ms p99_ms max_ms success_rate non_2xx rss_kb_after
2 ianitor https-h1-keepalive 1 15 27924 1861 0.3 0.34 9.03 82.42 1.0 0 13228
3 ianitor https-h2 1 15 32594 2173 0.37 0.41 0.77 33.56 1.0 0 13444
4 ianitor https-h1-keepalive 16 15.03 57767 3843 1.85 11.28 28.77 130.96 1.0 0 15408
5 ianitor https-h2 16 15 70840 4723 1.51 9.54 27.5 80.67 1.0 0 16388
6 ianitor https-h1-keepalive 64 15.04 99114 6596 4.94 27.15 50.88 137.67 1.0 0 21272
7 ianitor https-h2 64 15.02 176136 11726 4.55 7.93 23.21 65.82 1.0 0 24520
8 ianitor https-h1-keepalive 256 15.02 66156 4421 52.26 98.36 155.59 307.77 1.0 0 38620
9 ianitor https-h2 256 15 59482 3981 60.98 101.34 146.55 233.81 1.0 0 52184
10 ianitor https-h1-new-conn 16 15 18250 1218 8.57 30.28 50.64 122.99 1.0 0 52200
11 ianitor http-redirect 64 15 203706 13582 1.84 15.68 32.41 87.56 1.0 203706 55620
12 caddy https-h1-keepalive 1 15 26362 1757 0.46 0.53 2.48 106.04 1.0 0 59828
13 caddy https-h2 1 15 20631 1375 0.64 0.72 1.4 33.45 1.0 0 60084
14 caddy https-h1-keepalive 16 15.01 103603 6905 0.54 2.83 45.47 162.27 1.0 0 65660
15 caddy https-h2 16 15.02 91438 6090 0.74 5.56 35.64 134.4 1.0 0 69348
16 caddy https-h1-keepalive 64 15.02 234993 15653 1.94 9.85 31.3 146.84 1.0 0 79068
17 caddy https-h2 64 15.01 127103 8472 2.46 19.38 59.58 156.96 1.0 0 82992
18 caddy https-h1-keepalive 256 15.02 189465 12632 13.37 48.12 101.94 418.37 1.0 0 130136
19 caddy https-h2 256 15.09 151866 10077 19.21 53.91 101.9 464.76 1.0 0 130716
20 caddy https-h1-new-conn 16 15 33531 2236 2.41 16.71 65.02 173.34 1.0 0 98300
21 caddy http-redirect 64 15.02 811365 54027 0.23 2.49 16.27 82.11 1.0 811365 104520
22 caddy_gomaxprocs2 https-h1-keepalive 1 15 35264 2351 0.41 0.48 0.79 48.27 1.0 0 56800
23 caddy_gomaxprocs2 https-h2 1 15 23823 1588 0.59 0.68 1.41 27.62 1.0 0 57684
24 caddy_gomaxprocs2 https-h1-keepalive 16 15 116399 7759 1.57 3.49 11.23 60.1 1.0 0 61076
25 caddy_gomaxprocs2 https-h2 16 15 51386 3426 2.71 11 28.59 68.23 1.0 0 61652
26 caddy_gomaxprocs2 https-h1-keepalive 64 15.02 98458 6561 7.37 19.47 39.84 166.73 1.0 0 68012
27 caddy_gomaxprocs2 https-h2 64 15 85584 5708 10.26 19.29 37.34 79.44 1.0 0 68616
28 caddy_gomaxprocs2 https-h1-keepalive 256 15 66867 4473 52.61 92.37 147.03 218.19 1.0 0 95680
29 caddy_gomaxprocs2 https-h2 256 15.01 53887 3607 68.4 97.91 134.35 193.25 1.0 0 98972
30 caddy_gomaxprocs2 https-h1-new-conn 16 15 27335 1823 7.93 14.23 21.39 67.37 1.0 0 78728
31 caddy_gomaxprocs2 http-redirect 64 15 255374 17027 2.85 8.19 15.52 59.82 1.0 255374 79764
32 ianitor soak-https-h1 32 300.04 1873622 6245 3.23 10.32 31.29 134.28 1.0 0 55588
33 caddy soak-https-h1 32 300 3909309 13031 0.81 4 35.44 204.14 1.0 0 76592
@@ -1,103 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.018795747,
"slowest": 0.0821075,
"fastest": 0.0000375,
"average": 0.001179247194193746,
"requestsPerSec": 54027.367684395205,
"totalData": 0,
"sizePerRequest": 0,
"sizePerSec": 0.0
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 54027.367684395205,
"latency_ms": {
"min": 0.038,
"mean": 1.179,
"p50": 0.23,
"p95": 5.971,
"p99": 16.271,
"max": 82.108
}
},
"responseTimeHistogram": {
"0.0000375": 1,
"0.0082445": 782396,
"0.0164515": 21154,
"0.024658500000000003": 4721,
"0.032865500000000006": 1979,
"0.041072500000000005": 642,
"0.04927950000000001": 285,
"0.05748650000000001": 97,
"0.0656935": 69,
"0.07390050000000001": 13,
"0.0821075": 8
},
"latencyPercentiles": {
"p10": 0.0001,
"p25": 0.0001339,
"p50": 0.0002301,
"p75": 0.0006239,
"p90": 0.0024874,
"p95": 0.0059708,
"p99": 0.0162705,
"p99.9": 0.035564001,
"p99.99": 0.058229699
},
"firstByteHistogram": {
"NaN": 0
},
"firstBytePercentiles": {
"p10": null,
"p25": null,
"p50": null,
"p75": null,
"p90": null,
"p95": null,
"p99": null,
"p99.9": null,
"p99.99": null
},
"rps": {
"mean": 54291.93014905917,
"stddev": 35527.321305323385,
"max": 242214.53287198595,
"min": 34.10571407133535,
"percentiles": {
"p10": 10336.487801940571,
"p25": 27170.358145573246,
"p50": 50733.48409950603,
"p75": 75221.81432615055,
"p90": 101909.04267567223,
"p95": 115807.99195777836,
"p99": 156641.40862929283,
"p99.9": 221158.1045172193,
"p99.99": 242214.53287198595
}
},
"details": {
"DNSDialup": {
"average": 0.0003536109375000002,
"fastest": 0.0001347,
"slowest": 0.0007735
},
"DNSLookup": {
"average": 0.000012493750000000002,
"fastest": 3.3e-6,
"slowest": 0.0000612
},
"firstByte": {
"average": null,
"fastest": null,
"slowest": null
}
},
"statusCodeDistribution": {
"308": 811365
},
"errorDistribution": {
"aborted due to deadline": 61
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.002358804,
"slowest": 0.1060408,
"fastest": 0.0003051,
"average": 0.0005643368714058144,
"requestsPerSec": 1757.2569983442186,
"totalData": 79086,
"sizePerRequest": 3,
"sizePerSec": 5271.57102647843
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 1757.2569983442186,
"latency_ms": {
"min": 0.305,
"mean": 0.564,
"p50": 0.462,
"p95": 0.581,
"p99": 2.482,
"max": 106.041
}
},
"responseTimeHistogram": {
"0.0003051": 1,
"0.01087867": 26273,
"0.02145224": 84,
"0.03202581": 2,
"0.042599380000000006": 1,
"0.05317295000000001": 0,
"0.06374652": 0,
"0.07432009": 0,
"0.08489366000000001": 0,
"0.09546723000000001": 0,
"0.10604080000000002": 1
},
"latencyPercentiles": {
"p10": 0.000409,
"p25": 0.0004393,
"p50": 0.000462,
"p75": 0.0004879,
"p90": 0.0005264,
"p95": 0.0005808,
"p99": 0.0024822,
"p99.9": 0.0170555,
"p99.99": 0.0262408
},
"firstByteHistogram": {
"0.0003048": 1,
"0.01087831": 26273,
"0.021451820000000003": 84,
"0.032025330000000005": 2,
"0.042598840000000006": 1,
"0.05317235000000001": 0,
"0.06374586": 0,
"0.07431937": 0,
"0.08489288": 0,
"0.09546639000000001": 0,
"0.1060399": 1
},
"firstBytePercentiles": {
"p10": 0.0004086,
"p25": 0.0004391,
"p50": 0.0004617,
"p75": 0.0004876,
"p90": 0.0005262,
"p95": 0.0005805,
"p99": 0.0024819,
"p99.9": 0.0170542,
"p99.99": 0.0262398
},
"rps": {
"mean": 1850.6971373175163,
"stddev": 606.3350485897364,
"max": 2964.7198339758224,
"min": 9.387873121017195,
"percentiles": {
"p10": 907.2763563781903,
"p25": 1902.682782723684,
"p50": 2064.026089289704,
"p75": 2140.8910184526935,
"p90": 2218.8603126577123,
"p95": 2277.2205488101326,
"p99": 2732.8211824008627,
"p99.9": 2906.8077437358256,
"p99.99": 2964.7198339758224
}
},
"details": {
"DNSDialup": {
"average": 0.104945,
"fastest": 0.104945,
"slowest": 0.104945
},
"DNSLookup": {
"average": 0.000049,
"fastest": 0.000049,
"slowest": 0.000049
},
"firstByte": {
"average": 0.0005640438625293983,
"fastest": 0.0003048,
"slowest": 0.1060399
}
},
"statusCodeDistribution": {
"200": 26362
},
"errorDistribution": {
"aborted due to deadline": 1
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.005755808,
"slowest": 0.162273399,
"fastest": 0.0001583,
"average": 0.0023110564513672536,
"requestsPerSec": 6905.283634214395,
"totalData": 310809,
"sizePerRequest": 3,
"sizePerSec": 20712.6521300779
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 6905.283634214395,
"latency_ms": {
"min": 0.158,
"mean": 2.311,
"p50": 0.541,
"p95": 9.38,
"p99": 45.474,
"max": 162.273
}
},
"responseTimeHistogram": {
"0.0001583": 1,
"0.0163698099": 100653,
"0.0325813198": 1436,
"0.0487928297": 579,
"0.0650043396": 448,
"0.0812158495": 237,
"0.0974273594": 87,
"0.1136388693": 95,
"0.1298503792": 37,
"0.1460618891": 23,
"0.162273399": 7
},
"latencyPercentiles": {
"p10": 0.0003378,
"p25": 0.0004132,
"p50": 0.0005407,
"p75": 0.0007883,
"p90": 0.0028318,
"p95": 0.0093798,
"p99": 0.0454738,
"p99.9": 0.1078016,
"p99.99": 0.1442385
},
"firstByteHistogram": {
"0.0001582": 1,
"0.0163696899": 100653,
"0.0325811798": 1436,
"0.0487926697": 579,
"0.0650041596": 448,
"0.0812156495": 237,
"0.0974271394": 87,
"0.1136386293": 95,
"0.1298501192": 37,
"0.1460616091": 23,
"0.162273099": 7
},
"firstBytePercentiles": {
"p10": 0.0003376,
"p25": 0.0004129,
"p50": 0.0005404,
"p75": 0.000788,
"p90": 0.0028315,
"p95": 0.0093795,
"p99": 0.0454736,
"p99.9": 0.1078014,
"p99.99": 0.1442384
},
"rps": {
"mean": 8816.869812683235,
"stddev": 9654.48862151181,
"max": 102040.81632706436,
"min": 9.23774728294758,
"percentiles": {
"p10": 71.65839012260524,
"p25": 562.980644725513,
"p50": 5954.0918983284055,
"p75": 14172.200194270597,
"p90": 23184.081607967128,
"p95": 25967.809489617168,
"p99": 31011.019449626285,
"p99.9": 90090.0900897522,
"p99.99": 102040.81632706436
}
},
"details": {
"DNSDialup": {
"average": 0.10573826875,
"fastest": 0.104618,
"slowest": 0.1067038
},
"DNSLookup": {
"average": 0.00002766875,
"fastest": 4.4e-6,
"slowest": 0.0000726
},
"firstByte": {
"average": 0.002310793509174426,
"fastest": 0.0001582,
"slowest": 0.162273099
}
},
"statusCodeDistribution": {
"200": 103603
},
"errorDistribution": {
"aborted due to deadline": 16
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.019466287,
"slowest": 0.418366599,
"fastest": 0.0001414,
"average": 0.020236639322692318,
"requestsPerSec": 12631.607300467853,
"totalData": 568395,
"sizePerRequest": 3,
"sizePerSec": 37843.88800099845
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 12631.607300467853,
"latency_ms": {
"min": 0.141,
"mean": 20.237,
"p50": 13.367,
"p95": 62.893,
"p99": 101.938,
"max": 418.367
}
},
"responseTimeHistogram": {
"0.0001414": 1,
"0.0419639199": 164473,
"0.0837864398": 21159,
"0.12560895970000002": 3121,
"0.16743147960000002": 413,
"0.2092539995": 109,
"0.25107651940000003": 74,
"0.2928990393": 56,
"0.3347215592": 57,
"0.37654407910000004": 1,
"0.418366599": 1
},
"latencyPercentiles": {
"p10": 0.001623,
"p25": 0.0041708,
"p50": 0.0133667,
"p75": 0.0291072,
"p90": 0.0481165,
"p95": 0.0628933,
"p99": 0.1019375,
"p99.9": 0.2090671,
"p99.99": 0.315375999
},
"firstByteHistogram": {
"0.0001413": 1,
"0.0419638299": 164474,
"0.0837863598": 21158,
"0.1256088897": 3121,
"0.16743141960000002": 413,
"0.20925394950000004": 109,
"0.2510764794": 74,
"0.2928990093": 56,
"0.33472153920000003": 57,
"0.37654406910000005": 1,
"0.41836659900000006": 1
},
"firstBytePercentiles": {
"p10": 0.0016227,
"p25": 0.0041704,
"p50": 0.0133662,
"p75": 0.0291072,
"p90": 0.0481162,
"p95": 0.0628933,
"p99": 0.1019374,
"p99.9": 0.2090671,
"p99.99": 0.315375899
},
"rps": {
"mean": 13597.939292163925,
"stddev": 14012.504961474926,
"max": 236966.8246483339,
"min": 9.57544396545946,
"percentiles": {
"p10": 425.0616339369942,
"p25": 3834.2010735762588,
"p50": 10721.39684484533,
"p75": 19647.584381209752,
"p90": 30381.068796506184,
"p95": 38585.73140269472,
"p99": 52505.77563531388,
"p99.9": 177777.77777749032,
"p99.99": 236966.8246483339
}
},
"details": {
"DNSDialup": {
"average": 0.1512655573359374,
"fastest": 0.0959749,
"slowest": 0.329047699
},
"DNSLookup": {
"average": 7.044140625000001e-6,
"fastest": 2.1e-6,
"slowest": 0.0000847
},
"firstByte": {
"average": 0.020236338316702285,
"fastest": 0.0001413,
"slowest": 0.418366599
}
},
"statusCodeDistribution": {
"200": 189465
},
"errorDistribution": {
"aborted due to deadline": 255
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.016419583,
"slowest": 0.1468448,
"fastest": 0.00015,
"average": 0.004074690958513652,
"requestsPerSec": 15653.33192115294,
"totalData": 704979,
"sizePerRequest": 3,
"sizePerSec": 46947.20975951568
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 15653.33192115294,
"latency_ms": {
"min": 0.15,
"mean": 4.075,
"p50": 1.944,
"p95": 14.783,
"p99": 31.295,
"max": 146.845
}
},
"responseTimeHistogram": {
"0.00015": 1,
"0.01481948": 223296,
"0.029488959999999998": 8852,
"0.04415843999999999": 2005,
"0.05882791999999999": 541,
"0.07349739999999999": 156,
"0.08816687999999999": 100,
"0.10283635999999999": 16,
"0.11750583999999999": 12,
"0.13217532": 1,
"0.1468448": 13
},
"latencyPercentiles": {
"p10": 0.0005266,
"p25": 0.0009285,
"p50": 0.0019443,
"p75": 0.004467,
"p90": 0.0098493,
"p95": 0.0147829,
"p99": 0.0312955,
"p99.9": 0.0617255,
"p99.99": 0.1070583
},
"firstByteHistogram": {
"0.0001499": 1,
"0.014819379999999998": 223296,
"0.02948886": 8852,
"0.04415834": 2005,
"0.058827819999999996": 541,
"0.07349729999999999": 156,
"0.08816677999999999": 100,
"0.10283625999999998": 16,
"0.11750573999999998": 12,
"0.13217522": 1,
"0.1468447": 13
},
"firstBytePercentiles": {
"p10": 0.0005264,
"p25": 0.0009283,
"p50": 0.001944,
"p75": 0.0044668,
"p90": 0.009849,
"p95": 0.0147826,
"p99": 0.0312954,
"p99.9": 0.0617254,
"p99.99": 0.1070583
},
"rps": {
"mean": 15870.712525652865,
"stddev": 10795.299117141303,
"max": 76762.0376831455,
"min": 12.236681901335633,
"percentiles": {
"p10": 1616.6841807453031,
"p25": 7000.07000069973,
"p50": 15302.907552435288,
"p75": 22911.704146311884,
"p90": 30499.662252063812,
"p95": 34871.79487179422,
"p99": 44062.454641590186,
"p99.9": 64894.77655739068,
"p99.99": 76762.0376831455
}
},
"details": {
"DNSDialup": {
"average": 0.06819543281250003,
"fastest": 0.043867,
"slowest": 0.0927161
},
"DNSLookup": {
"average": 0.000013640625000000001,
"fastest": 2.9e-6,
"slowest": 0.0000837
},
"firstByte": {
"average": 0.004074481777389089,
"fastest": 0.0001499,
"slowest": 0.1468447
}
},
"statusCodeDistribution": {
"200": 234993
},
"errorDistribution": {
"aborted due to deadline": 64
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.004018174,
"slowest": 0.1733402,
"fastest": 0.0009088,
"average": 0.0071451484561748865,
"requestsPerSec": 2235.8677262956508,
"totalData": 100593,
"sizePerRequest": 3,
"sizePerSec": 6704.4040358678385
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 2235.8677262956508,
"latency_ms": {
"min": 0.909,
"mean": 7.145,
"p50": 2.415,
"p95": 30.459,
"p99": 65.017,
"max": 173.34
}
},
"responseTimeHistogram": {
"0.0009088": 1,
"0.018151940000000002": 30515,
"0.03539508": 1809,
"0.05263822": 583,
"0.06988136": 346,
"0.08712450000000001": 183,
"0.10436764": 61,
"0.12161078": 26,
"0.13885392": 2,
"0.15609705999999998": 1,
"0.1733402": 4
},
"latencyPercentiles": {
"p10": 0.0014034,
"p25": 0.0017098,
"p50": 0.0024147,
"p75": 0.0070902,
"p90": 0.0167069,
"p95": 0.0304586,
"p99": 0.065017399,
"p99.9": 0.1041768,
"p99.99": 0.1636814
},
"firstByteHistogram": {
"0.0009085": 1,
"0.018151639999999997": 30515,
"0.035394779999999994": 1809,
"0.05263791999999999": 583,
"0.06988106": 346,
"0.08712419999999998": 183,
"0.10436733999999999": 61,
"0.12161047999999999": 26,
"0.13885361999999998": 2,
"0.15609675999999997": 1,
"0.17333989999999996": 4
},
"firstBytePercentiles": {
"p10": 0.0014031,
"p25": 0.0017094,
"p50": 0.0024144,
"p75": 0.0070898,
"p90": 0.0167066,
"p95": 0.0304584,
"p99": 0.065017099,
"p99.9": 0.1041765,
"p99.99": 0.1636812
},
"rps": {
"mean": 2726.7928945700846,
"stddev": 2523.963895476176,
"max": 30326.004549011384,
"min": 11.541386836124897,
"percentiles": {
"p10": 76.16146230007695,
"p25": 442.6280301577233,
"p50": 2197.4802226779657,
"p75": 4400.528063367616,
"p90": 6141.490492499327,
"p95": 7287.263944700669,
"p99": 8893.829905502533,
"p99.9": 17117.958294430544,
"p99.99": 30326.004549011384
}
},
"details": {
"DNSDialup": {
"average": 0.003323362418895918,
"fastest": 0.0005222,
"slowest": 0.1078611
},
"DNSLookup": {
"average": 9.968837762070787e-6,
"fastest": 2.4e-6,
"slowest": 0.0086609
},
"firstByte": {
"average": 0.007144812531209925,
"fastest": 0.0009085,
"slowest": 0.1733399
}
},
"statusCodeDistribution": {
"200": 33531
},
"errorDistribution": {
"aborted due to deadline": 16
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.001672101,
"slowest": 0.0334476,
"fastest": 0.0003876,
"average": 0.0007189138965634228,
"requestsPerSec": 1375.313355810829,
"totalData": 61893,
"sizePerRequest": 3,
"sizePerSec": 4125.740089724682
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 1375.313355810829,
"latency_ms": {
"min": 0.388,
"mean": 0.719,
"p50": 0.639,
"p95": 0.768,
"p99": 1.396,
"max": 33.448
}
},
"responseTimeHistogram": {
"0.0003876": 1,
"0.0036936": 20527,
"0.0069996": 30,
"0.0103056": 18,
"0.0136116": 8,
"0.016917599999999998": 11,
"0.020223599999999998": 17,
"0.023529599999999998": 4,
"0.026835599999999998": 1,
"0.030141599999999998": 5,
"0.0334476": 9
},
"latencyPercentiles": {
"p10": 0.0005769,
"p25": 0.0006077,
"p50": 0.0006393,
"p75": 0.0006773,
"p90": 0.0007196,
"p95": 0.000768,
"p99": 0.0013964,
"p99.9": 0.0197775,
"p99.99": 0.0331157
},
"firstByteHistogram": {
"0.0003872": 1,
"0.0036931500000000005": 20527,
"0.006999100000000001": 30,
"0.010305050000000003": 18,
"0.013611000000000003": 8,
"0.016916950000000004": 11,
"0.020222900000000005": 17,
"0.023528850000000004": 4,
"0.026834800000000006": 1,
"0.030140750000000008": 5,
"0.0334467": 9
},
"firstBytePercentiles": {
"p10": 0.0005765,
"p25": 0.0006073,
"p50": 0.0006389,
"p75": 0.0006768,
"p90": 0.000719,
"p95": 0.0007672,
"p99": 0.0013961,
"p99.9": 0.0197764,
"p99.99": 0.0331148
},
"rps": {
"mean": 1442.112017183624,
"stddev": 341.72586892201025,
"max": 2276.636648790987,
"min": 11.322450820113986,
"percentiles": {
"p10": 1316.8157369609844,
"p25": 1455.165317174096,
"p50": 1519.3527557260143,
"p75": 1565.6476040373018,
"p90": 1614.6611229969456,
"p95": 1665.1229589234974,
"p99": 2058.6297760206025,
"p99.9": 2184.646305762854,
"p99.99": 2276.636648790987
}
},
"details": {
"DNSDialup": {
"average": 0.085987001,
"fastest": 0.085987001,
"slowest": 0.085987001
},
"DNSLookup": {
"average": 0.0000567,
"fastest": 0.0000567,
"slowest": 0.0000567
},
"firstByte": {
"average": 0.0007184533032814724,
"fastest": 0.0003872,
"slowest": 0.0334467
}
},
"statusCodeDistribution": {
"200": 20631
},
"errorDistribution": {
"aborted due to deadline": 1
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.016245923,
"slowest": 0.1344025,
"fastest": 0.0002386,
"average": 0.0026058178862726437,
"requestsPerSec": 6090.337123469872,
"totalData": 274314,
"sizePerRequest": 3,
"sizePerSec": 18267.814832456912
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 6090.337123469872,
"latency_ms": {
"min": 0.239,
"mean": 2.606,
"p50": 0.74,
"p95": 11.112,
"p99": 35.638,
"max": 134.403
}
},
"responseTimeHistogram": {
"0.0002386": 1,
"0.01365499": 87639,
"0.02707138": 2257,
"0.04048777": 831,
"0.05390416": 291,
"0.06732055": 224,
"0.08073694000000001": 106,
"0.09415333000000001": 41,
"0.10756972000000001": 36,
"0.12098611000000001": 8,
"0.1344025": 4
},
"latencyPercentiles": {
"p10": 0.0004685,
"p25": 0.000564799,
"p50": 0.0007405,
"p75": 0.001199,
"p90": 0.0055644,
"p95": 0.0111118,
"p99": 0.035638,
"p99.9": 0.079941899,
"p99.99": 0.1125405
},
"firstByteHistogram": {
"0.0002382": 1,
"0.013654620000000001": 87639,
"0.027071040000000005": 2257,
"0.04048746000000001": 831,
"0.05390388000000001": 291,
"0.0673203": 224,
"0.08073672000000001": 106,
"0.09415314000000001": 41,
"0.10756956000000001": 36,
"0.12098598": 8,
"0.1344024": 4
},
"firstBytePercentiles": {
"p10": 0.0004682,
"p25": 0.0005643,
"p50": 0.00074,
"p75": 0.0011984,
"p90": 0.0055637,
"p95": 0.0111114,
"p99": 0.0356376,
"p99.9": 0.079941499,
"p99.99": 0.1125401
},
"rps": {
"mean": 7202.567464768243,
"stddev": 7170.45659781321,
"max": 95238.0952529792,
"min": 10.48230115860863,
"percentiles": {
"p10": 89.10433128134964,
"p25": 1628.27690727568,
"p50": 5737.593757498369,
"p75": 10941.475826973277,
"p90": 16276.041666666271,
"p95": 19174.22983510327,
"p99": 23237.613629521147,
"p99.9": 94339.62262990378,
"p99.99": 95238.0952529792
}
},
"details": {
"DNSDialup": {
"average": 0.06899092577442661,
"fastest": 0.067862099,
"slowest": 0.071486299
},
"DNSLookup": {
"average": 0.000049345408910955866,
"fastest": 6.8e-6,
"slowest": 0.0001534
},
"firstByte": {
"average": 0.002605233972582489,
"fastest": 0.0002382,
"slowest": 0.1344024
}
},
"statusCodeDistribution": {
"200": 91438
},
"errorDistribution": {
"aborted due to deadline": 16
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.091610981,
"slowest": 0.4647646,
"fastest": 0.0002843,
"average": 0.025152170551815487,
"requestsPerSec": 10076.790356672924,
"totalData": 455598,
"sizePerRequest": 3,
"sizePerSec": 30188.824809597045
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 10076.790356672924,
"latency_ms": {
"min": 0.284,
"mean": 25.152,
"p50": 19.212,
"p95": 67.038,
"p99": 101.9,
"max": 464.765
}
},
"responseTimeHistogram": {
"0.0002843": 1,
"0.04673233": 129811,
"0.09318036": 19798,
"0.13962839": 1883,
"0.18607642": 290,
"0.23252445": 68,
"0.27897248": 7,
"0.32542051000000005": 4,
"0.37186854": 2,
"0.41831657": 0,
"0.4647646": 2
},
"latencyPercentiles": {
"p10": 0.0034031,
"p25": 0.0089379,
"p50": 0.0192123,
"p75": 0.0348282,
"p90": 0.0539113,
"p95": 0.0670376,
"p99": 0.1019004,
"p99.9": 0.1601791,
"p99.99": 0.2271948
},
"firstByteHistogram": {
"0.0002841": 1,
"0.046732130000000004": 129812,
"0.09318016": 19797,
"0.13962819": 1883,
"0.18607622000000001": 290,
"0.23252425000000002": 68,
"0.27897228": 7,
"0.32542031000000005": 4,
"0.37186834": 2,
"0.41831637": 0,
"0.4647644": 2
},
"firstBytePercentiles": {
"p10": 0.0034026,
"p25": 0.0089373,
"p50": 0.0192114,
"p75": 0.0348281,
"p90": 0.0539112,
"p95": 0.0670375,
"p99": 0.1018999,
"p99.9": 0.160179,
"p99.99": 0.2271945
},
"rps": {
"mean": 10605.623717862149,
"stddev": 9230.80300616933,
"max": 111524.16356901842,
"min": 13.229543332436503,
"percentiles": {
"p10": 700.1890510437828,
"p25": 3572.5222006737363,
"p50": 8740.584590863515,
"p75": 15748.425157488562,
"p90": 22083.06218462441,
"p95": 26421.169962431315,
"p99": 36228.81099223658,
"p99.9": 94490.19983400247,
"p99.99": 111524.16356901842
}
},
"details": {
"DNSDialup": {
"average": 0.10547651010452719,
"fastest": 0.072120499,
"slowest": 0.216904999
},
"DNSLookup": {
"average": 6.99253157388741e-6,
"fastest": 2.6e-6,
"slowest": 0.0000909
},
"firstByte": {
"average": 0.025151754616056263,
"fastest": 0.0002841,
"slowest": 0.4647644
}
},
"statusCodeDistribution": {
"200": 151866
},
"errorDistribution": {
"aborted due to deadline": 209
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.010748297,
"slowest": 0.1569616,
"fastest": 0.0002245,
"average": 0.007512949975279854,
"requestsPerSec": 8471.729555642152,
"totalData": 381309,
"sizePerRequest": 3,
"sizePerSec": 25402.39783223913
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 8471.729555642152,
"latency_ms": {
"min": 0.225,
"mean": 7.513,
"p50": 2.461,
"p95": 30.522,
"p99": 59.582,
"max": 156.962
}
},
"responseTimeHistogram": {
"0.0002245": 1,
"0.01589821": 110166,
"0.03157192": 10984,
"0.047245630000000004": 3570,
"0.06291934": 1396,
"0.07859305000000001": 648,
"0.09426676": 225,
"0.10994047": 54,
"0.12561418": 19,
"0.14128789": 29,
"0.1569616": 11
},
"latencyPercentiles": {
"p10": 0.0006895,
"p25": 0.0011646,
"p50": 0.0024605,
"p75": 0.00967,
"p90": 0.0193773,
"p95": 0.0305215,
"p99": 0.0595816,
"p99.9": 0.0907694,
"p99.99": 0.1363714
},
"firstByteHistogram": {
"0.0002243": 2,
"0.015897989999999997": 110165,
"0.03157167999999999": 10984,
"0.04724536999999999": 3570,
"0.06291905999999999": 1396,
"0.07859274999999998": 648,
"0.09426643999999998": 225,
"0.10994012999999998": 54,
"0.12561382": 19,
"0.14128750999999998": 29,
"0.15696119999999997": 11
},
"firstBytePercentiles": {
"p10": 0.0006892,
"p25": 0.0011644,
"p50": 0.0024601,
"p75": 0.0096697,
"p90": 0.0193772,
"p95": 0.0305214,
"p99": 0.059581,
"p99.9": 0.090769,
"p99.99": 0.1363713
},
"rps": {
"mean": 9967.99791405974,
"stddev": 13712.545585557658,
"max": 225806.45161368826,
"min": 14.836949345171242,
"percentiles": {
"p10": 99.03931860948775,
"p25": 1900.6842463286118,
"p50": 6768.69852968809,
"p75": 14186.26901124974,
"p90": 23539.826569824312,
"p95": 30052.75447548217,
"p99": 40046.05296090477,
"p99.9": 198019.80198021766,
"p99.99": 225806.45161368826
}
},
"details": {
"DNSDialup": {
"average": 0.05095217967317911,
"fastest": 0.0345505,
"slowest": 0.0871411
},
"DNSLookup": {
"average": 0.00001849738794520989,
"fastest": 2.8e-6,
"slowest": 0.0001439
},
"firstByte": {
"average": 0.007512631878932849,
"fastest": 0.0002243,
"slowest": 0.1569612
}
},
"statusCodeDistribution": {
"200": 127103
},
"errorDistribution": {
"aborted due to deadline": 64
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 300.003628013,
"slowest": 0.204141902,
"fastest": 0.0001267,
"average": 0.0024508333589749417,
"requestsPerSec": 13030.97907812834,
"totalData": 11727927,
"sizePerRequest": 3,
"sizePerSec": 39092.61723825485
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 13030.97907812834,
"latency_ms": {
"min": 0.127,
"mean": 2.451,
"p50": 0.814,
"p95": 9.595,
"p99": 35.443,
"max": 204.142
}
},
"responseTimeHistogram": {
"0.0001267": 1,
"0.0205282202": 3832478,
"0.0409297404": 44599,
"0.0613312606": 17472,
"0.08173278079999999": 8451,
"0.10213430099999998": 3901,
"0.12253582119999999": 1613,
"0.1429373414": 628,
"0.1633388616": 108,
"0.1837403818": 52,
"0.204141902": 6
},
"latencyPercentiles": {
"p10": 0.0003553,
"p25": 0.0004996,
"p50": 0.000814401,
"p75": 0.0014808,
"p90": 0.0039954,
"p95": 0.009594901,
"p99": 0.035443086,
"p99.9": 0.092844401,
"p99.99": 0.131851711
},
"firstByteHistogram": {
"0.0001265": 1,
"0.020528030200000002": 3832479,
"0.0409295604": 44599,
"0.0613310906": 17472,
"0.0817326208": 8450,
"0.102134151": 3901,
"0.1225356812": 1613,
"0.1429372114": 628,
"0.1633387416": 108,
"0.1837402718": 52,
"0.204141802": 6
},
"firstBytePercentiles": {
"p10": 0.0003551,
"p25": 0.0004994,
"p50": 0.0008142,
"p75": 0.001480599,
"p90": 0.003995,
"p95": 0.009594501,
"p99": 0.035442386,
"p99.9": 0.092844301,
"p99.99": 0.131851411
},
"rps": {
"mean": 14634.436809419303,
"stddev": 15168.46742844932,
"max": 294117.6473096741,
"min": 9.362568264827344,
"percentiles": {
"p10": 98.58917898976765,
"p25": 2112.314582785661,
"p50": 11046.39485840811,
"p75": 23341.580691840434,
"p90": 34526.24339761367,
"p95": 40115.57930451167,
"p99": 47730.69837527305,
"p99.9": 143884.89209655894,
"p99.99": 254237.2882263559
}
},
"details": {
"DNSDialup": {
"average": 0.0650016463125,
"fastest": 0.048728695,
"slowest": 0.068113693
},
"DNSLookup": {
"average": 0.000017812499999999993,
"fastest": 5e-6,
"slowest": 0.0000669
},
"firstByte": {
"average": 0.0024505522780103343,
"fastest": 0.0001265,
"slowest": 0.204141802
}
},
"statusCodeDistribution": {
"200": 3909309
},
"errorDistribution": {
"aborted due to deadline": 32
}
}
@@ -1,103 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.002150269,
"slowest": 0.059823898,
"fastest": 0.0000588,
"average": 0.003753154335351309,
"requestsPerSec": 17026.55922116867,
"totalData": 0,
"sizePerRequest": 0,
"sizePerSec": 0.0
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 17026.55922116867,
"latency_ms": {
"min": 0.059,
"mean": 3.753,
"p50": 2.855,
"p95": 10.46,
"p99": 15.523,
"max": 59.824
}
},
"responseTimeHistogram": {
"0.0000588": 1,
"0.0060353098": 206113,
"0.0120118196": 41464,
"0.0179883294": 6588,
"0.0239648392": 1003,
"0.029941349000000003": 160,
"0.035917858799999994": 17,
"0.041894368599999995": 17,
"0.0478708784": 9,
"0.0538473882": 1,
"0.059823898": 1
},
"latencyPercentiles": {
"p10": 0.0004776,
"p25": 0.0012618,
"p50": 0.0028546,
"p75": 0.0051908,
"p90": 0.0081868,
"p95": 0.0104601,
"p99": 0.0155229,
"p99.9": 0.023271099,
"p99.99": 0.0379197
},
"firstByteHistogram": {
"NaN": 0
},
"firstBytePercentiles": {
"p10": null,
"p25": null,
"p50": null,
"p75": null,
"p90": null,
"p95": null,
"p99": null,
"p99.9": null,
"p99.99": null
},
"rps": {
"mean": 16989.314383689936,
"stddev": 5376.689770903059,
"max": 30322.50291176298,
"min": 74.45073966809896,
"percentiles": {
"p10": 9528.872483624458,
"p25": 13226.556445362341,
"p50": 17339.41059512616,
"p75": 20818.11384085071,
"p90": 23923.92392392406,
"p95": 25248.73004899496,
"p99": 27751.523317314095,
"p99.9": 30022.82034574568,
"p99.99": 30322.50291176298
}
},
"details": {
"DNSDialup": {
"average": 0.0003298953124999999,
"fastest": 0.0001012,
"slowest": 0.0007817
},
"DNSLookup": {
"average": 0.000013368750000000005,
"fastest": 2.1e-6,
"slowest": 0.0001601
},
"firstByte": {
"average": null,
"fastest": null,
"slowest": null
}
},
"statusCodeDistribution": {
"308": 255374
},
"errorDistribution": {
"aborted due to deadline": 61
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.002064744,
"slowest": 0.0482662,
"fastest": 0.0002228,
"average": 0.0004213640438123845,
"requestsPerSec": 2350.676430329636,
"totalData": 105792,
"sizePerRequest": 3,
"sizePerSec": 7051.829318515038
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 2350.676430329636,
"latency_ms": {
"min": 0.223,
"mean": 0.421,
"p50": 0.406,
"p95": 0.512,
"p99": 0.79,
"max": 48.266
}
},
"responseTimeHistogram": {
"0.0002228": 1,
"0.005027139999999999": 35256,
"0.00983148": 4,
"0.014635819999999999": 2,
"0.019440159999999998": 0,
"0.0242445": 0,
"0.029048839999999996": 0,
"0.033853180000000004": 0,
"0.03865752": 0,
"0.04346186": 0,
"0.0482662": 1
},
"latencyPercentiles": {
"p10": 0.0003478,
"p25": 0.0003683,
"p50": 0.0004057,
"p75": 0.0004461,
"p90": 0.0004799,
"p95": 0.0005116,
"p99": 0.00079,
"p99.9": 0.0017707,
"p99.99": 0.0072501
},
"firstByteHistogram": {
"0.0002226": 1,
"0.005026879999999999": 35256,
"0.009831159999999999": 4,
"0.014635439999999998": 2,
"0.019439719999999997": 0,
"0.024243999999999998": 0,
"0.029048279999999996": 0,
"0.03385256": 0,
"0.03865684": 0,
"0.04346112": 0,
"0.0482654": 1
},
"firstBytePercentiles": {
"p10": 0.0003476,
"p25": 0.000368,
"p50": 0.000405401,
"p75": 0.0004458,
"p90": 0.0004796,
"p95": 0.0005113,
"p99": 0.0007898,
"p99.9": 0.0017704,
"p99.99": 0.0072498
},
"rps": {
"mean": 2355.480608037043,
"stddev": 305.6269134036098,
"max": 2831.543393402497,
"min": 20.57096778175026,
"percentiles": {
"p10": 2072.5388601034974,
"p25": 2184.2463829920093,
"p50": 2404.625244382889,
"p75": 2567.3149992811614,
"p90": 2671.983228166774,
"p95": 2712.7499246459897,
"p99": 2765.600032777776,
"p99.9": 2813.7875590392805,
"p99.99": 2831.543393402497
}
},
"details": {
"DNSDialup": {
"average": 0.0469521,
"fastest": 0.0469521,
"slowest": 0.0469521
},
"DNSLookup": {
"average": 0.0000333,
"fastest": 0.0000333,
"slowest": 0.0000333
},
"firstByte": {
"average": 0.00042111634077245856,
"fastest": 0.0002226,
"slowest": 0.0482654
}
},
"statusCodeDistribution": {
"200": 35264
},
"errorDistribution": {
"aborted due to deadline": 1
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.004796639,
"slowest": 0.0601028,
"fastest": 0.0001558,
"average": 0.0020574272899509124,
"requestsPerSec": 7758.519012341544,
"totalData": 349197,
"sizePerRequest": 3,
"sizePerSec": 23272.358059980503
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 7758.519012341544,
"latency_ms": {
"min": 0.156,
"mean": 2.057,
"p50": 1.57,
"p95": 4.809,
"p99": 11.228,
"max": 60.103
}
},
"responseTimeHistogram": {
"0.0001558": 1,
"0.006150500000000001": 112848,
"0.0121452": 2589,
"0.018139900000000004": 600,
"0.024134600000000003": 198,
"0.0301293": 67,
"0.036124": 41,
"0.0421187": 19,
"0.0481134": 4,
"0.0541081": 6,
"0.0601028": 26
},
"latencyPercentiles": {
"p10": 0.0007209,
"p25": 0.0010639,
"p50": 0.0015703,
"p75": 0.0022893,
"p90": 0.0034932,
"p95": 0.0048093,
"p99": 0.0112279,
"p99.9": 0.0279622,
"p99.99": 0.058274
},
"firstByteHistogram": {
"0.0001556": 1,
"0.0061503": 112848,
"0.012145000000000001": 2589,
"0.0181397": 600,
"0.0241344": 198,
"0.0301291": 68,
"0.036123800000000005": 40,
"0.0421185": 19,
"0.0481132": 4,
"0.0541079": 6,
"0.0601026": 26
},
"firstBytePercentiles": {
"p10": 0.0007205,
"p25": 0.0010637,
"p50": 0.00157,
"p75": 0.0022891,
"p90": 0.0034929,
"p95": 0.004809,
"p99": 0.0112276,
"p99.9": 0.0279619,
"p99.99": 0.0582734
},
"rps": {
"mean": 8219.237452143676,
"stddev": 15997.850144047194,
"max": 624999.999635083,
"min": 16.93494441104497,
"percentiles": {
"p10": 3525.5603122639604,
"p25": 6021.67804094736,
"p50": 8276.48809921183,
"p75": 10083.084617246475,
"p90": 11154.99412101651,
"p95": 11714.174150721796,
"p99": 13102.489472998985,
"p99.9": 23999.999999885404,
"p99.99": 624999.999635083
}
},
"details": {
"DNSDialup": {
"average": 0.054984587499999994,
"fastest": 0.0524595,
"slowest": 0.0572887
},
"DNSLookup": {
"average": 0.000028637499999999998,
"fastest": 5.5e-6,
"slowest": 0.0000644
},
"firstByte": {
"average": 0.0020571085423671497,
"fastest": 0.0001556,
"slowest": 0.0601026
}
},
"statusCodeDistribution": {
"200": 116399
},
"errorDistribution": {
"aborted due to deadline": 16
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.0046378,
"slowest": 0.2181895,
"fastest": 0.0004581,
"average": 0.05724174818779055,
"requestsPerSec": 4473.48352520712,
"totalData": 200601,
"sizePerRequest": 3,
"sizePerSec": 13369.26640108567
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 4473.48352520712,
"latency_ms": {
"min": 0.458,
"mean": 57.242,
"p50": 52.612,
"p95": 108.747,
"p99": 147.025,
"max": 218.19
}
},
"responseTimeHistogram": {
"0.0004581": 1,
"0.022231240000000003": 3857,
"0.04400438000000001": 19941,
"0.06577752000000002": 22166,
"0.08755066000000002": 12520,
"0.10932380000000001": 5131,
"0.13109694000000002": 1990,
"0.15287008000000002": 715,
"0.17464322000000002": 325,
"0.19641636": 197,
"0.2181895": 24
},
"latencyPercentiles": {
"p10": 0.026986199,
"p25": 0.038062098,
"p50": 0.0526119,
"p75": 0.0716704,
"p90": 0.092374001,
"p95": 0.108747,
"p99": 0.147025301,
"p99.9": 0.192869101,
"p99.99": 0.211826801
},
"firstByteHistogram": {
"0.0004579": 1,
"0.02223103": 3858,
"0.044004159999999994": 19942,
"0.06577728999999999": 22164,
"0.08755041999999999": 12520,
"0.10932354999999999": 5131,
"0.13109668": 1990,
"0.15286981": 715,
"0.17464294": 325,
"0.19641607": 197,
"0.2181892": 24
},
"firstBytePercentiles": {
"p10": 0.026985899,
"p25": 0.038061798,
"p50": 0.0526117,
"p75": 0.0716702,
"p90": 0.092373801,
"p95": 0.1087468,
"p99": 0.147025101,
"p99.9": 0.192868801,
"p99.99": 0.211826601
},
"rps": {
"mean": 4502.987802008221,
"stddev": 2838.169442761876,
"max": 27472.52747257541,
"min": 11.687827478316159,
"percentiles": {
"p10": 1059.415555751777,
"p25": 2416.7237281992957,
"p50": 4248.945730340718,
"p75": 6224.462136195428,
"p90": 8056.292066082553,
"p95": 9484.02849244303,
"p99": 12308.56027073252,
"p99.9": 15449.593194153273,
"p99.99": 27472.52747257541
}
},
"details": {
"DNSDialup": {
"average": 0.08048447843750003,
"fastest": 0.0477648,
"slowest": 0.128978001
},
"DNSLookup": {
"average": 6.845703125000003e-6,
"fastest": 1.9e-6,
"slowest": 0.0001189
},
"firstByte": {
"average": 0.057241450203732384,
"fastest": 0.0004579,
"slowest": 0.2181892
}
},
"statusCodeDistribution": {
"200": 66867
},
"errorDistribution": {
"aborted due to deadline": 256
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.016737208,
"slowest": 0.166731802,
"fastest": 0.0002387,
"average": 0.009739633160423882,
"requestsPerSec": 6560.679502835979,
"totalData": 295374,
"sizePerRequest": 3,
"sizePerSec": 19669.65232917859
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 6560.679502835979,
"latency_ms": {
"min": 0.239,
"mean": 9.74,
"p50": 7.366,
"p95": 25.614,
"p99": 39.844,
"max": 166.732
}
},
"responseTimeHistogram": {
"0.0002387": 1,
"0.0168880102": 84981,
"0.0335373204": 11313,
"0.0501866306": 1763,
"0.0668359408": 285,
"0.083485251": 48,
"0.10013456119999999": 11,
"0.11678387139999999": 18,
"0.1334331816": 0,
"0.1500824918": 30,
"0.166731802": 8
},
"latencyPercentiles": {
"p10": 0.002615,
"p25": 0.004519,
"p50": 0.0073656,
"p75": 0.012175101,
"p90": 0.019472301,
"p95": 0.025613601,
"p99": 0.0398441,
"p99.9": 0.0704864,
"p99.99": 0.148703101
},
"firstByteHistogram": {
"0.0002386": 1,
"0.0168879202": 84981,
"0.0335372404": 11313,
"0.050186560600000006": 1763,
"0.06683588080000001": 285,
"0.08348520100000001": 48,
"0.10013452120000002": 11,
"0.11678384140000002": 18,
"0.13343316160000002": 0,
"0.15008248180000003": 30,
"0.166731802": 8
},
"firstBytePercentiles": {
"p10": 0.0026147,
"p25": 0.0045188,
"p50": 0.0073654,
"p75": 0.012174901,
"p90": 0.0194718,
"p95": 0.025613501,
"p99": 0.0398437,
"p99.9": 0.0704862,
"p99.99": 0.148702901
},
"rps": {
"mean": 6556.6940634554,
"stddev": 3500.6037679130523,
"max": 15039.886184643516,
"min": 12.601282651797792,
"percentiles": {
"p10": 1600.5601960686654,
"p25": 3829.294099863541,
"p50": 6613.557793476607,
"p75": 9481.541254791226,
"p90": 11020.38771727662,
"p95": 11861.919218320745,
"p99": 13184.246013603382,
"p99.9": 14657.947067384583,
"p99.99": 15039.886184643516
}
},
"details": {
"DNSDialup": {
"average": 0.086538041625,
"fastest": 0.072438501,
"slowest": 0.112627201
},
"DNSLookup": {
"average": 0.000011654687500000001,
"fastest": 2.3e-6,
"slowest": 0.0000813
},
"firstByte": {
"average": 0.009739357007140051,
"fastest": 0.0002386,
"slowest": 0.166731802
}
},
"statusCodeDistribution": {
"200": 98458
},
"errorDistribution": {
"aborted due to deadline": 62
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.001670186,
"slowest": 0.0673689,
"fastest": 0.0011287,
"average": 0.008770213088567843,
"requestsPerSec": 1823.1969947936036,
"totalData": 82005,
"sizePerRequest": 3,
"sizePerSec": 5466.3913406474885
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 1823.1969947936036,
"latency_ms": {
"min": 1.129,
"mean": 8.77,
"p50": 7.934,
"p95": 16.433,
"p99": 21.387,
"max": 67.369
}
},
"responseTimeHistogram": {
"0.0011287": 1,
"0.007752719999999999": 13146,
"0.014376739999999999": 11573,
"0.021000759999999997": 2294,
"0.027624779999999998": 264,
"0.0342488": 36,
"0.04087282": 5,
"0.04749684": 0,
"0.05412086": 0,
"0.06074488": 4,
"0.0673689": 12
},
"latencyPercentiles": {
"p10": 0.0043039,
"p25": 0.0057605,
"p50": 0.007934,
"p75": 0.0109823,
"p90": 0.0142346,
"p95": 0.0164328,
"p99": 0.0213872,
"p99.9": 0.0316213,
"p99.99": 0.0657409
},
"firstByteHistogram": {
"0.0011284": 1,
"0.0077524099999999995": 13146,
"0.014376419999999999": 11573,
"0.02100043": 2294,
"0.02762444": 264,
"0.03424845": 36,
"0.04087246": 5,
"0.04749647": 0,
"0.05412048": 0,
"0.06074449": 4,
"0.0673685": 12
},
"firstBytePercentiles": {
"p10": 0.0043036,
"p25": 0.0057602,
"p50": 0.0079337,
"p75": 0.010982,
"p90": 0.0142343,
"p95": 0.0164326,
"p99": 0.0213869,
"p99.9": 0.031621,
"p99.99": 0.0657406
},
"rps": {
"mean": 1865.6878466656424,
"stddev": 806.3740144583545,
"max": 11855.364552481875,
"min": 16.184712891285667,
"percentiles": {
"p10": 861.5676222887545,
"p25": 1401.4294580472636,
"p50": 1864.589375984081,
"p75": 2333.1541200459365,
"p90": 2783.662991200708,
"p95": 3027.329477837645,
"p99": 3653.885679051755,
"p99.9": 10213.702074165707,
"p99.99": 11855.364552481875
}
},
"details": {
"DNSDialup": {
"average": 0.0041902446019754635,
"fastest": 0.0004388,
"slowest": 0.0623406
},
"DNSLookup": {
"average": 9.343519297603825e-6,
"fastest": 2.9e-6,
"slowest": 0.0060626
},
"firstByte": {
"average": 0.008769826130455488,
"fastest": 0.0011284,
"slowest": 0.0673685
}
},
"statusCodeDistribution": {
"200": 27335
},
"errorDistribution": {
"aborted due to deadline": 16
}
}
@@ -1,111 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.00223488,
"slowest": 0.027620101,
"fastest": 0.0003776,
"average": 0.000624054979473615,
"requestsPerSec": 1587.96340615619,
"totalData": 71469,
"sizePerRequest": 3,
"sizePerSec": 4763.89021846857
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 1587.96340615619,
"latency_ms": {
"min": 0.378,
"mean": 0.624,
"p50": 0.588,
"p95": 0.749,
"p99": 1.414,
"max": 27.62
}
},
"responseTimeHistogram": {
"0.0003776": 1,
"0.0031018501": 23752,
"0.0058261002": 39,
"0.0085503503": 8,
"0.011274600400000001": 6,
"0.013998850500000002": 7,
"0.0167231006": 3,
"0.0194473507": 4,
"0.0221716008": 2,
"0.0248958509": 0,
"0.027620101": 1
},
"latencyPercentiles": {
"p10": 0.0004916,
"p25": 0.000546801,
"p50": 0.0005879,
"p75": 0.0006248,
"p90": 0.0006784,
"p95": 0.0007492,
"p99": 0.0014144,
"p99.9": 0.0080586,
"p99.99": 0.020332001
},
"firstByteHistogram": {
"0.0003773": 1,
"0.0031015101": 23752,
"0.0058257202": 39,
"0.008549930300000001": 8,
"0.0112741404": 6,
"0.0139983505": 7,
"0.016722560600000002": 3,
"0.0194467707": 4,
"0.0221709808": 2,
"0.0248951909": 0,
"0.027619401": 1
},
"firstBytePercentiles": {
"p10": 0.0004912,
"p25": 0.0005464,
"p50": 0.0005876,
"p75": 0.0006244,
"p90": 0.0006778,
"p95": 0.0007487,
"p99": 0.0014141,
"p99.9": 0.0080579,
"p99.99": 0.020331301
},
"rps": {
"mean": 1599.664298342526,
"stddev": 304.009822680561,
"max": 2298.6384130292395,
"min": 22.371764542278953,
"percentiles": {
"p10": 1407.332200765958,
"p25": 1555.193828990857,
"p50": 1635.2728350521156,
"p75": 1724.647679116921,
"p90": 1864.2417714440055,
"p95": 1952.522263121158,
"p99": 2060.3893950522333,
"p99.9": 2196.7293141324017,
"p99.99": 2298.6384130292395
}
},
"details": {
"DNSDialup": {
"average": 0.042964001,
"fastest": 0.042964001,
"slowest": 0.042964001
},
"DNSLookup": {
"average": 0.0000416,
"fastest": 0.0000416,
"slowest": 0.0000416
},
"firstByte": {
"average": 0.0006236448253788323,
"fastest": 0.0003773,
"slowest": 0.027619401
}
},
"statusCodeDistribution": {
"200": 23823
},
"errorDistribution": {}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.001381334,
"slowest": 0.068229001,
"fastest": 0.000343,
"average": 0.004648210778032954,
"requestsPerSec": 3426.4844587011153,
"totalData": 154158,
"sizePerRequest": 3,
"sizePerSec": 10276.253670760798
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 3426.4844587011153,
"latency_ms": {
"min": 0.343,
"mean": 4.648,
"p50": 2.706,
"p95": 15.93,
"p99": 28.589,
"max": 68.229
}
},
"responseTimeHistogram": {
"0.000343": 1,
"0.0071316001": 43052,
"0.0139202002": 5052,
"0.0207088003": 1967,
"0.0274974004": 727,
"0.034286000500000004": 326,
"0.041074600600000004": 170,
"0.047863200700000004": 39,
"0.054651800800000004": 31,
"0.061440400900000004": 10,
"0.068229001": 11
},
"latencyPercentiles": {
"p10": 0.0012123,
"p25": 0.0018349,
"p50": 0.0027058,
"p75": 0.0047379,
"p90": 0.0109985,
"p95": 0.0159298,
"p99": 0.0285888,
"p99.9": 0.048228701,
"p99.99": 0.066864201
},
"firstByteHistogram": {
"0.0003426": 1,
"0.0071311801": 43054,
"0.013919760199999999": 5051,
"0.020708340299999996": 1966,
"0.027496920399999996": 727,
"0.034285500499999996": 326,
"0.04107408059999999": 170,
"0.0478626607": 39,
"0.054651240799999994": 31,
"0.06143982089999999": 10,
"0.068228401": 11
},
"firstBytePercentiles": {
"p10": 0.0012119,
"p25": 0.0018345,
"p50": 0.0027053,
"p75": 0.0047372,
"p90": 0.0109979,
"p95": 0.0159293,
"p99": 0.0285884,
"p99.9": 0.048228201,
"p99.99": 0.066863801
},
"rps": {
"mean": 3546.8989902223993,
"stddev": 2152.2391804070685,
"max": 10022.550739138387,
"min": 17.735496354468726,
"percentiles": {
"p10": 402.51977378388324,
"p25": 1761.7675710406404,
"p50": 3641.1817657709794,
"p75": 5219.1127508323925,
"p90": 6473.0697975499825,
"p95": 6961.979280318372,
"p99": 7505.5541100411665,
"p99.9": 8746.143193799813,
"p99.99": 10022.550739138387
}
},
"details": {
"DNSDialup": {
"average": 0.051438553954384715,
"fastest": 0.0489099,
"slowest": 0.0550978
},
"DNSLookup": {
"average": 0.00004745068695753747,
"fastest": 5.9e-6,
"slowest": 0.0001463
},
"firstByte": {
"average": 0.004647635703109795,
"fastest": 0.0003426,
"slowest": 0.068228401
}
},
"statusCodeDistribution": {
"200": 51386
},
"errorDistribution": {
"aborted due to deadline": 16
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.012466199,
"slowest": 0.193254797,
"fastest": 0.0082419,
"average": 0.07044534605138456,
"requestsPerSec": 3606.5360136235668,
"totalData": 161661,
"sizePerRequest": 3,
"sizePerSec": 10768.450556829126
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 3606.5360136235668,
"latency_ms": {
"min": 8.242,
"mean": 70.445,
"p50": 68.399,
"p95": 108.55,
"p99": 134.345,
"max": 193.255
}
},
"responseTimeHistogram": {
"0.0082419": 1,
"0.0267431897": 314,
"0.045244479399999996": 5069,
"0.0637457691": 16265,
"0.0822470588": 18675,
"0.1007483485": 9007,
"0.1192496382": 3235,
"0.1377509279": 894,
"0.1562522176": 282,
"0.1747535073": 134,
"0.193254797": 11
},
"latencyPercentiles": {
"p10": 0.045255097,
"p25": 0.055998799,
"p50": 0.068398696,
"p75": 0.082402895,
"p90": 0.097909198,
"p95": 0.108549894,
"p99": 0.1343454,
"p99.9": 0.16636569,
"p99.99": 0.184468389
},
"firstByteHistogram": {
"0.0082417": 1,
"0.0267429697": 314,
"0.0452442394": 5069,
"0.0637455091": 16265,
"0.0822467788": 18675,
"0.1007480485": 9007,
"0.1192493182": 3235,
"0.1377505879": 894,
"0.1562518576": 282,
"0.17475312729999998": 134,
"0.193254397": 11
},
"firstBytePercentiles": {
"p10": 0.045254597,
"p25": 0.055998399,
"p50": 0.068398296,
"p75": 0.082402395,
"p90": 0.097908798,
"p95": 0.108549494,
"p99": 0.134345,
"p99.9": 0.16636519,
"p99.99": 0.184467989
},
"rps": {
"mean": 3725.090712920856,
"stddev": 2222.2177970570033,
"max": 16580.998176093126,
"min": 6.566850926593501,
"percentiles": {
"p10": 973.9627296928842,
"p25": 2110.573975617737,
"p50": 3578.244662804117,
"p75": 5078.101712142901,
"p90": 6638.108968707412,
"p95": 7661.599258034662,
"p99": 9869.689259000877,
"p99.9": 15037.59398495838,
"p99.99": 16580.998176093126
}
},
"details": {
"DNSDialup": {
"average": 0.09872306716434409,
"fastest": 0.061666496,
"slowest": 0.16976059
},
"DNSLookup": {
"average": 8.837910609237815e-6,
"fastest": 2.2e-6,
"slowest": 0.0002139
},
"firstByte": {
"average": 0.0704447562041305,
"fastest": 0.0082417,
"slowest": 0.193254397
}
},
"statusCodeDistribution": {
"200": 53887
},
"errorDistribution": {
"aborted due to deadline": 256
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.003713894,
"slowest": 0.079442,
"fastest": 0.0003078,
"average": 0.011152737680442688,
"requestsPerSec": 5708.453293970816,
"totalData": 256752,
"sizePerRequest": 3,
"sizePerSec": 17112.56305031752
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 5708.453293970816,
"latency_ms": {
"min": 0.308,
"mean": 11.153,
"p50": 10.255,
"p95": 23.188,
"p99": 37.342,
"max": 79.442
}
},
"responseTimeHistogram": {
"0.0003078": 1,
"0.008221220000000001": 29665,
"0.016134640000000002": 40765,
"0.024048060000000003": 11332,
"0.03196148": 2270,
"0.039874900000000005": 924,
"0.04778832": 384,
"0.05570174": 149,
"0.06361516": 53,
"0.07152858000000001": 36,
"0.07944200000000001": 5
},
"latencyPercentiles": {
"p10": 0.0029656,
"p25": 0.006794,
"p50": 0.010255,
"p75": 0.0141449,
"p90": 0.0192869,
"p95": 0.023187701,
"p99": 0.037342,
"p99.9": 0.0562323,
"p99.99": 0.069859
},
"firstByteHistogram": {
"0.0003075": 1,
"0.00822094": 29666,
"0.016134379999999997": 40765,
"0.024047819999999994": 11332,
"0.03196126": 2269,
"0.0398747": 924,
"0.04778813999999999": 384,
"0.055701579999999994": 149,
"0.06361502": 53,
"0.07152845999999999": 36,
"0.0794419": 5
},
"firstBytePercentiles": {
"p10": 0.0029654,
"p25": 0.0067934,
"p50": 0.0102546,
"p75": 0.0141444,
"p90": 0.0192867,
"p95": 0.0231829,
"p99": 0.0373416,
"p99.9": 0.0562318,
"p99.99": 0.0698585
},
"rps": {
"mean": 5707.375447740455,
"stddev": 2140.898003961851,
"max": 11484.619921158206,
"min": 14.114883663505633,
"percentiles": {
"p10": 2605.1060077752104,
"p25": 4484.076433120714,
"p50": 6039.862488436646,
"p75": 7197.16168271699,
"p90": 8168.052443084634,
"p95": 8824.33487843727,
"p99": 9585.405967167944,
"p99.9": 10336.384071932633,
"p99.99": 11484.619921158206
}
},
"details": {
"DNSDialup": {
"average": 0.0747351895878197,
"fastest": 0.057600001,
"slowest": 0.106284601
},
"DNSLookup": {
"average": 0.000016428272808001737,
"fastest": 2.1e-6,
"slowest": 0.0002039
},
"firstByte": {
"average": 0.011152140165720274,
"fastest": 0.0003075,
"slowest": 0.0794419
}
},
"statusCodeDistribution": {
"200": 85584
},
"errorDistribution": {
"aborted due to deadline": 64
}
}
@@ -1,103 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.002780824,
"slowest": 0.087557499,
"fastest": 0.0000344,
"average": 0.0047049367742727334,
"requestsPerSec": 13582.01538704289,
"totalData": 0,
"sizePerRequest": 0,
"sizePerSec": 0.0
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 13582.01538704289,
"latency_ms": {
"min": 0.034,
"mean": 4.705,
"p50": 1.837,
"p95": 20.83,
"p99": 32.408,
"max": 87.557
}
},
"responseTimeHistogram": {
"0.0000344": 1,
"0.0087867099": 171211,
"0.0175390198": 15640,
"0.0262913297": 11298,
"0.035043639599999996": 4412,
"0.043795949499999993": 805,
"0.0525482594": 220,
"0.061300569299999996": 98,
"0.0700528792": 19,
"0.0788051891": 0,
"0.087557499": 2
},
"latencyPercentiles": {
"p10": 0.0007834,
"p25": 0.0011793,
"p50": 0.0018371,
"p75": 0.0035278,
"p90": 0.0156791,
"p95": 0.0208298,
"p99": 0.032408,
"p99.9": 0.048070499,
"p99.99": 0.062111599
},
"firstByteHistogram": {
"NaN": 0
},
"firstBytePercentiles": {
"p10": null,
"p25": null,
"p50": null,
"p75": null,
"p90": null,
"p95": null,
"p99": null,
"p99.9": null,
"p99.99": null
},
"rps": {
"mean": 14750.279700369903,
"stddev": 14560.69116016888,
"max": 68204.77433420006,
"min": 40.72341066709136,
"percentiles": {
"p10": 88.6061368610332,
"p25": 1208.1854564674761,
"p50": 11023.921910545645,
"p75": 25486.68727293039,
"p90": 37901.03026744765,
"p95": 41947.83877439307,
"p99": 48502.425121255284,
"p99.9": 55047.724862357965,
"p99.99": 68204.77433420006
}
},
"details": {
"DNSDialup": {
"average": 0.0003320484374999999,
"fastest": 0.000121,
"slowest": 0.0007906
},
"DNSLookup": {
"average": 0.000012546875,
"fastest": 2.9e-6,
"slowest": 0.0001175
},
"firstByte": {
"average": null,
"fastest": null,
"slowest": null
}
},
"statusCodeDistribution": {
"308": 203706
},
"errorDistribution": {
"aborted due to deadline": 62
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.002190688,
"slowest": 0.082422398,
"fastest": 0.0002387,
"average": 0.0005324675257484613,
"requestsPerSec": 1861.3948176473145,
"totalData": 83772,
"sizePerRequest": 3,
"sizePerSec": 5583.984482146851
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 1861.3948176473145,
"latency_ms": {
"min": 0.239,
"mean": 0.532,
"p50": 0.3,
"p95": 0.412,
"p99": 9.03,
"max": 82.422
}
},
"responseTimeHistogram": {
"0.0002387": 1,
"0.0084570698": 27612,
"0.0166754396": 250,
"0.0248938094": 59,
"0.0331121792": 1,
"0.041330549": 0,
"0.0495489188": 0,
"0.0577672886": 0,
"0.0659856584": 0,
"0.0742040282": 0,
"0.082422398": 1
},
"latencyPercentiles": {
"p10": 0.0002824,
"p25": 0.0002911,
"p50": 0.0003002,
"p75": 0.0003116,
"p90": 0.0003388,
"p95": 0.000412,
"p99": 0.009029999,
"p99.9": 0.0171978,
"p99.99": 0.023654
},
"firstByteHistogram": {
"0.0002385": 1,
"0.008456779800000001": 27612,
"0.0166750596": 250,
"0.024893339400000002": 59,
"0.033111619200000005": 1,
"0.041329899": 0,
"0.04954817880000001": 0,
"0.05776645860000001": 0,
"0.0659847384": 0,
"0.07420301820000001": 0,
"0.082421298": 1
},
"firstBytePercentiles": {
"p10": 0.0002821,
"p25": 0.0002909,
"p50": 0.0003,
"p75": 0.0003113,
"p90": 0.0003385,
"p95": 0.0004117,
"p99": 0.009029699,
"p99.9": 0.017197,
"p99.99": 0.0236532
},
"rps": {
"mean": 2124.484265564842,
"stddev": 1347.8575502140113,
"max": 3645.643456057386,
"min": 12.074684629160716,
"percentiles": {
"p10": 70.81350555177794,
"p25": 608.951588348692,
"p50": 3104.999048468054,
"p75": 3249.918752029405,
"p90": 3328.933019572346,
"p95": 3383.0288607359867,
"p99": 3489.0965732087448,
"p99.9": 3600.884788833553,
"p99.99": 3645.643456057386
}
},
"details": {
"DNSDialup": {
"average": 0.081536798,
"fastest": 0.081536798,
"slowest": 0.081536798
},
"DNSLookup": {
"average": 0.0000458,
"fastest": 0.0000458,
"slowest": 0.0000458
},
"firstByte": {
"average": 0.0005321862014396212,
"fastest": 0.0002385,
"slowest": 0.082421298
}
},
"statusCodeDistribution": {
"200": 27924
},
"errorDistribution": {
"aborted due to deadline": 1
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.03402794,
"slowest": 0.130961199,
"fastest": 0.0001862,
"average": 0.004149040110114824,
"requestsPerSec": 3843.347919173815,
"totalData": 173301,
"sizePerRequest": 3,
"sizePerSec": 11527.250095026762
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 3843.347919173815,
"latency_ms": {
"min": 0.186,
"mean": 4.149,
"p50": 1.855,
"p95": 18.713,
"p99": 28.766,
"max": 130.961
}
},
"responseTimeHistogram": {
"0.0001862": 1,
"0.0132636999": 52977,
"0.026341199800000003": 3490,
"0.039418699700000004": 1217,
"0.0524961996": 57,
"0.0655736995": 3,
"0.07865119940000001": 6,
"0.09172869930000001": 4,
"0.1048061992": 5,
"0.1178836991": 6,
"0.130961199": 1
},
"latencyPercentiles": {
"p10": 0.0009131,
"p25": 0.0011822,
"p50": 0.0018548,
"p75": 0.0026308,
"p90": 0.0112775,
"p95": 0.018713299,
"p99": 0.028765999,
"p99.9": 0.0428159,
"p99.99": 0.1050984
},
"firstByteHistogram": {
"0.0001859": 1,
"0.0132634099": 52977,
"0.0263409198": 3490,
"0.03941842970000001": 1217,
"0.052495939600000006": 57,
"0.0655734495": 3,
"0.07865095940000001": 6,
"0.0917284693": 4,
"0.10480597920000001": 5,
"0.11788348910000002": 6,
"0.130960999": 1
},
"firstBytePercentiles": {
"p10": 0.0009128,
"p25": 0.0011819,
"p50": 0.0018545,
"p75": 0.0026305,
"p90": 0.0112772,
"p95": 0.018712999,
"p99": 0.028765699,
"p99.9": 0.0428156,
"p99.99": 0.1050981
},
"rps": {
"mean": 4687.215272300966,
"stddev": 4249.667886126964,
"max": 18300.837615252258,
"min": 9.473159696631534,
"percentiles": {
"p10": 76.57612815780362,
"p25": 607.0723933828876,
"p50": 4152.361275686176,
"p75": 7117.139747132983,
"p90": 11249.415614773832,
"p95": 13226.58543672865,
"p99": 14836.795252224973,
"p99.9": 17690.76542045258,
"p99.99": 18300.837615252258
}
},
"details": {
"DNSDialup": {
"average": 0.0998782625,
"fastest": 0.086856,
"slowest": 0.1134017
},
"DNSLookup": {
"average": 0.000027018750000000006,
"fastest": 5.8e-6,
"slowest": 0.0000528
},
"firstByte": {
"average": 0.004148775954108705,
"fastest": 0.0001859,
"slowest": 0.130960999
}
},
"statusCodeDistribution": {
"200": 57767
},
"errorDistribution": {
"aborted due to deadline": 14
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.02036436,
"slowest": 0.307769899,
"fastest": 0.0007085,
"average": 0.057897151761926315,
"requestsPerSec": 4421.463981050856,
"totalData": 198468,
"sizePerRequest": 3,
"sizePerSec": 13213.261359260396
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 4421.463981050856,
"latency_ms": {
"min": 0.709,
"mean": 57.897,
"p50": 52.26,
"p95": 114.007,
"p99": 155.594,
"max": 307.77
}
},
"responseTimeHistogram": {
"0.0007085": 1,
"0.0314146399": 13286,
"0.062120779800000005": 27831,
"0.09282691970000001": 16633,
"0.12353305960000001": 6055,
"0.1542391995": 1668,
"0.18494533940000002": 359,
"0.2156514793": 87,
"0.24635761920000002": 47,
"0.27706375910000003": 44,
"0.307769899": 145
},
"latencyPercentiles": {
"p10": 0.0227912,
"p25": 0.0346661,
"p50": 0.0522601,
"p75": 0.074456899,
"p90": 0.098357199,
"p95": 0.1140067,
"p99": 0.1555942,
"p99.9": 0.288823099,
"p99.99": 0.305920899
},
"firstByteHistogram": {
"0.0007083": 1,
"0.0314144299": 13286,
"0.0621205598": 27831,
"0.09282668969999999": 16633,
"0.1235328196": 6055,
"0.1542389495": 1668,
"0.1849450794": 359,
"0.2156512093": 87,
"0.2463573392": 47,
"0.2770634691": 44,
"0.307769599": 145
},
"firstBytePercentiles": {
"p10": 0.0227909,
"p25": 0.034666,
"p50": 0.05226,
"p75": 0.074456599,
"p90": 0.098356899,
"p95": 0.1140066,
"p99": 0.155594,
"p99.9": 0.288822999,
"p99.99": 0.305920699
},
"rps": {
"mean": 5496.792005988151,
"stddev": 9329.201442555335,
"max": 281250.00000069453,
"min": 6.819621688306462,
"percentiles": {
"p10": 83.23483877412131,
"p25": 802.8662324498608,
"p50": 4426.336703384787,
"p75": 8480.209025692833,
"p90": 11862.787095923737,
"p95": 14050.864128143876,
"p99": 18224.633971543284,
"p99.9": 172413.7930951901,
"p99.99": 281250.00000069453
}
},
"details": {
"DNSDialup": {
"average": 0.15998890273046876,
"fastest": 0.1231775,
"slowest": 0.241296799
},
"DNSLookup": {
"average": 6.783203125000001e-6,
"fastest": 2.2e-6,
"slowest": 0.0000495
},
"firstByte": {
"average": 0.057896894489721726,
"fastest": 0.0007083,
"slowest": 0.307769599
}
},
"statusCodeDistribution": {
"200": 66156
},
"errorDistribution": {
"aborted due to deadline": 256
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.036446055,
"slowest": 0.1376657,
"fastest": 0.0001935,
"average": 0.009662872524779646,
"requestsPerSec": 6595.707498782364,
"totalData": 297342,
"sizePerRequest": 3,
"sizePerSec": 19774.752552058417
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 6595.707498782364,
"latency_ms": {
"min": 0.193,
"mean": 9.663,
"p50": 4.938,
"p95": 33.788,
"p99": 50.88,
"max": 137.666
}
},
"responseTimeHistogram": {
"0.0001935": 1,
"0.013940719999999998": 79769,
"0.027687939999999998": 9875,
"0.04143516": 7034,
"0.055182379999999996": 1704,
"0.0689296": 569,
"0.08267682": 94,
"0.09642403999999999": 22,
"0.11017126": 27,
"0.12391848": 9,
"0.1376657": 10
},
"latencyPercentiles": {
"p10": 0.0031773,
"p25": 0.0039024,
"p50": 0.004938,
"p75": 0.0083745,
"p90": 0.0271535,
"p95": 0.033787599,
"p99": 0.050880099,
"p99.9": 0.0751186,
"p99.99": 0.1239474
},
"firstByteHistogram": {
"0.0001934": 1,
"0.013940599999999997": 79769,
"0.027687799999999995": 9875,
"0.04143499999999999": 7034,
"0.055182199999999994": 1704,
"0.06892939999999999": 569,
"0.08267659999999998": 94,
"0.09642379999999998": 22,
"0.11017099999999998": 27,
"0.12391819999999998": 9,
"0.1376654": 10
},
"firstBytePercentiles": {
"p10": 0.0031771,
"p25": 0.0039023,
"p50": 0.0049379,
"p75": 0.0083743,
"p90": 0.0271533,
"p95": 0.033787299,
"p99": 0.050879899,
"p99.9": 0.0751182,
"p99.99": 0.1239473
},
"rps": {
"mean": 7151.913612124201,
"stddev": 5949.056372473474,
"max": 20847.81097993122,
"min": 12.05063193513868,
"percentiles": {
"p10": 81.88197532077213,
"p25": 789.3033608537072,
"p50": 6479.2817253406865,
"p75": 13466.930645307371,
"p90": 15285.906796194184,
"p95": 15963.695143624791,
"p99": 17204.301075273863,
"p99.9": 20505.809979503636,
"p99.99": 20847.81097993122
}
},
"details": {
"DNSDialup": {
"average": 0.071270578125,
"fastest": 0.01819,
"slowest": 0.1329798
},
"DNSLookup": {
"average": 0.0000122875,
"fastest": 2.5e-6,
"slowest": 0.0000632
},
"firstByte": {
"average": 0.00966263009082475,
"fastest": 0.0001934,
"slowest": 0.1376654
}
},
"statusCodeDistribution": {
"200": 99114
},
"errorDistribution": {
"aborted due to deadline": 62
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.000988698,
"slowest": 0.122994999,
"fastest": 0.0007963,
"average": 0.01313843324213699,
"requestsPerSec": 1217.6530739227412,
"totalData": 54750,
"sizePerRequest": 3,
"sizePerSec": 3649.759432676562
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 1217.6530739227412,
"latency_ms": {
"min": 0.796,
"mean": 13.138,
"p50": 8.574,
"p95": 36.093,
"p99": 50.643,
"max": 122.995
}
},
"responseTimeHistogram": {
"0.0007963": 1,
"0.0130161699": 11248,
"0.0252360398": 4128,
"0.0374559097": 2124,
"0.0496757796": 551,
"0.0618956495": 130,
"0.0741155194": 35,
"0.0863353893": 13,
"0.0985552592": 2,
"0.1107751291": 16,
"0.122994999": 2
},
"latencyPercentiles": {
"p10": 0.0033333,
"p25": 0.0045663,
"p50": 0.008574199,
"p75": 0.0173364,
"p90": 0.0302762,
"p95": 0.0360932,
"p99": 0.050642799,
"p99.9": 0.0964043,
"p99.99": 0.111215699
},
"firstByteHistogram": {
"0.0007962": 1,
"0.0130160099": 11248,
"0.0252358198": 4128,
"0.03745562969999999": 2124,
"0.049675439599999996": 551,
"0.0618952495": 130,
"0.07411505939999999": 35,
"0.08633486929999999": 13,
"0.0985546792": 2,
"0.1107744891": 16,
"0.122994299": 2
},
"firstBytePercentiles": {
"p10": 0.0033331,
"p25": 0.004566,
"p50": 0.008573899,
"p75": 0.0173361,
"p90": 0.0302759,
"p95": 0.0360926,
"p99": 0.050642499,
"p99.9": 0.0964039,
"p99.99": 0.111215399
},
"rps": {
"mean": 1623.8342116429112,
"stddev": 1490.9497185280286,
"max": 13242.10990949649,
"min": 9.110795555670109,
"percentiles": {
"p10": 66.88023755860222,
"p25": 214.64757176177963,
"p50": 1448.4656610177435,
"p75": 2599.16374731618,
"p90": 3559.0355013795183,
"p95": 4058.4827362291403,
"p99": 6388.755789809181,
"p99.9": 9176.416609327147,
"p99.99": 13242.10990949649
}
},
"details": {
"DNSDialup": {
"average": 0.004792804314465752,
"fastest": 0.00035,
"slowest": 0.107325499
},
"DNSLookup": {
"average": 8.753638301369792e-6,
"fastest": 2.8e-6,
"slowest": 0.0054627
},
"firstByte": {
"average": 0.013138131625698619,
"fastest": 0.0007962,
"slowest": 0.122994299
}
},
"statusCodeDistribution": {
"200": 18250
},
"errorDistribution": {
"aborted due to deadline": 16
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.00111823,
"slowest": 0.033558699,
"fastest": 0.0003061,
"average": 0.0004550638255813963,
"requestsPerSec": 2172.8380178228886,
"totalData": 97782,
"sizePerRequest": 3,
"sizePerSec": 6518.314068377288
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 2172.8380178228886,
"latency_ms": {
"min": 0.306,
"mean": 0.455,
"p50": 0.37,
"p95": 0.433,
"p99": 0.765,
"max": 33.559
}
},
"responseTimeHistogram": {
"0.0003061": 1,
"0.0036313599": 32442,
"0.0069566198": 22,
"0.0102818797": 20,
"0.0136071396": 14,
"0.0169323995": 35,
"0.0202576594": 20,
"0.0235829193": 4,
"0.0269081792": 11,
"0.0302334391": 8,
"0.033558699": 17
},
"latencyPercentiles": {
"p10": 0.0003497,
"p25": 0.0003597,
"p50": 0.0003701,
"p75": 0.0003828,
"p90": 0.0004061,
"p95": 0.0004327,
"p99": 0.0007653,
"p99.9": 0.024875799,
"p99.99": 0.033113799
},
"firstByteHistogram": {
"0.0003057": 1,
"0.0036309399": 32442,
"0.0069561798": 22,
"0.0102814197": 20,
"0.013606659600000001": 14,
"0.0169318995": 35,
"0.0202571394": 20,
"0.0235823793": 4,
"0.0269076192": 11,
"0.0302328591": 8,
"0.033558099": 17
},
"firstBytePercentiles": {
"p10": 0.0003494,
"p25": 0.0003594,
"p50": 0.0003697,
"p75": 0.0003824,
"p90": 0.0004058,
"p95": 0.0004323,
"p99": 0.0007649,
"p99.9": 0.024874999,
"p99.99": 0.033112799
},
"rps": {
"mean": 2363.0034978010385,
"stddev": 739.063364589429,
"max": 2852.2823352042915,
"min": 17.942111571226594,
"percentiles": {
"p10": 1634.6546791989604,
"p25": 2532.697119817031,
"p50": 2617.397998460656,
"p75": 2671.7363892240896,
"p90": 2716.2704600553375,
"p95": 2742.397464805496,
"p99": 2800.1008036289745,
"p99.9": 2838.537318417298,
"p99.99": 2852.2823352042915
}
},
"details": {
"DNSDialup": {
"average": 0.054373,
"fastest": 0.054373,
"slowest": 0.054373
},
"DNSLookup": {
"average": 0.0000668,
"fastest": 0.0000668,
"slowest": 0.0000668
},
"firstByte": {
"average": 0.0004546897905135944,
"fastest": 0.0003057,
"slowest": 0.033558099
}
},
"statusCodeDistribution": {
"200": 32594
},
"errorDistribution": {
"aborted due to deadline": 1
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.002048744,
"slowest": 0.080674,
"fastest": 0.000205,
"average": 0.003360361990725557,
"requestsPerSec": 4723.0882400871105,
"totalData": 212520,
"sizePerRequest": 3,
"sizePerSec": 14166.06515726703
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 4723.0882400871105,
"latency_ms": {
"min": 0.205,
"mean": 3.36,
"p50": 1.513,
"p95": 15.622,
"p99": 27.496,
"max": 80.674
}
},
"responseTimeHistogram": {
"0.000205": 1,
"0.0082519": 62919,
"0.0162988": 4568,
"0.024345699999999998": 2029,
"0.032392599999999994": 1005,
"0.04043949999999999": 217,
"0.04848639999999999": 71,
"0.056533299999999995": 13,
"0.06458019999999999": 2,
"0.07262709999999999": 5,
"0.08067399999999998": 10
},
"latencyPercentiles": {
"p10": 0.000851,
"p25": 0.0010722,
"p50": 0.0015126,
"p75": 0.0023282,
"p90": 0.0095442,
"p95": 0.0156224,
"p99": 0.0274955,
"p99.9": 0.0425913,
"p99.99": 0.0791286
},
"firstByteHistogram": {
"0.0002047": 1,
"0.0082516": 62919,
"0.016298499999999997": 4568,
"0.024345399999999996": 2029,
"0.0323923": 1005,
"0.040439199999999995": 217,
"0.0484861": 71,
"0.056533": 13,
"0.0645799": 2,
"0.07262679999999999": 5,
"0.08067369999999999": 10
},
"firstBytePercentiles": {
"p10": 0.0008507,
"p25": 0.0010719,
"p50": 0.0015122,
"p75": 0.0023278,
"p90": 0.0095439,
"p95": 0.0156221,
"p99": 0.0274951,
"p99.9": 0.042591,
"p99.99": 0.0791282
},
"rps": {
"mean": 5553.686301294755,
"stddev": 4636.220124623151,
"max": 29126.213592180335,
"min": 12.970858540737687,
"percentiles": {
"p10": 79.97888557421057,
"p25": 1107.4754593506525,
"p50": 5025.814410380619,
"p75": 8877.840909090803,
"p90": 12490.479817212197,
"p95": 13917.306274213552,
"p99": 15435.53231727701,
"p99.9": 20818.87578071068,
"p99.99": 29126.213592180335
}
},
"details": {
"DNSDialup": {
"average": 0.06953728589864486,
"fastest": 0.066216799,
"slowest": 0.077152799
},
"DNSLookup": {
"average": 0.00003968661349520042,
"fastest": 5e-6,
"slowest": 0.0001012
},
"firstByte": {
"average": 0.003359983626806897,
"fastest": 0.0002047,
"slowest": 0.0806737
}
},
"statusCodeDistribution": {
"200": 70840
},
"errorDistribution": {
"aborted due to deadline": 16
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.004394475,
"slowest": 0.233813599,
"fastest": 0.0019897,
"average": 0.06393254985710015,
"requestsPerSec": 3981.3669321700504,
"totalData": 178446,
"sizePerRequest": 3,
"sizePerSec": 11892.91579192502
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 3981.3669321700504,
"latency_ms": {
"min": 1.99,
"mean": 63.933,
"p50": 60.979,
"p95": 117.167,
"p99": 146.548,
"max": 233.814
}
},
"responseTimeHistogram": {
"0.0019897": 1,
"0.0251720899": 4428,
"0.048354479799999996": 15291,
"0.07153686969999999": 18566,
"0.0947192596": 12529,
"0.1179016495": 5779,
"0.1410840394": 2008,
"0.16426642930000002": 616,
"0.1874488192": 126,
"0.2106312091": 72,
"0.233813599": 66
},
"latencyPercentiles": {
"p10": 0.0285981,
"p25": 0.0421162,
"p50": 0.0609785,
"p75": 0.0817872,
"p90": 0.1013445,
"p95": 0.1171666,
"p99": 0.1465478,
"p99.9": 0.213014699,
"p99.99": 0.233074499
},
"firstByteHistogram": {
"0.0019894": 1,
"0.0251717999": 4428,
"0.048354199800000004": 15291,
"0.07153659970000001": 18566,
"0.0947189996": 12529,
"0.1179013995": 5779,
"0.14108379940000002": 2008,
"0.1642661993": 616,
"0.1874485992": 126,
"0.21063099910000002": 72,
"0.233813399": 66
},
"firstBytePercentiles": {
"p10": 0.0285978,
"p25": 0.0421158,
"p50": 0.0609782,
"p75": 0.0817868,
"p90": 0.1013442,
"p95": 0.1171662,
"p99": 0.1465475,
"p99.9": 0.213014499,
"p99.99": 0.233074299
},
"rps": {
"mean": 5779.471101779443,
"stddev": 6601.574808634353,
"max": 44899.130720031004,
"min": 8.940433467976261,
"percentiles": {
"p10": 67.35095234246428,
"p25": 227.93581327497992,
"p50": 3688.8634484510167,
"p75": 9008.893064439195,
"p90": 14666.464370605858,
"p95": 18280.82958919514,
"p99": 28451.882845186923,
"p99.9": 43534.53347450577,
"p99.99": 44899.130720031004
}
},
"details": {
"DNSDialup": {
"average": 0.10169912107360363,
"fastest": 0.0848183,
"slowest": 0.1330386
},
"DNSLookup": {
"average": 6.6574106452371976e-6,
"fastest": 2.1e-6,
"slowest": 0.000086
},
"firstByte": {
"average": 0.06393220326148973,
"fastest": 0.0019894,
"slowest": 0.233813399
}
},
"statusCodeDistribution": {
"200": 59482
},
"errorDistribution": {
"aborted due to deadline": 256
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 15.023609532,
"slowest": 0.0658201,
"fastest": 0.0004612,
"average": 0.005405248224763808,
"requestsPerSec": 11726.276539919329,
"totalData": 528408,
"sizePerRequest": 3,
"sizePerSec": 35171.84062022519
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 11726.276539919329,
"latency_ms": {
"min": 0.461,
"mean": 5.405,
"p50": 4.545,
"p95": 10.65,
"p99": 23.208,
"max": 65.82
}
},
"responseTimeHistogram": {
"0.0004612": 1,
"0.006997090000000001": 151799,
"0.013532980000000002": 18947,
"0.02006887": 2842,
"0.02660476": 1483,
"0.03314065000000001": 574,
"0.03967654": 219,
"0.046212430000000006": 163,
"0.05274832000000001": 80,
"0.05928421000000001": 22,
"0.0658201": 6
},
"latencyPercentiles": {
"p10": 0.0030629,
"p25": 0.0037292,
"p50": 0.0045451,
"p75": 0.005699,
"p90": 0.0079279,
"p95": 0.0106502,
"p99": 0.0232082,
"p99.9": 0.0425018,
"p99.99": 0.053907799
},
"firstByteHistogram": {
"0.0004608": 1,
"0.00699669": 151800,
"0.01353258": 18946,
"0.02006847": 2842,
"0.02660436": 1483,
"0.033140249999999996": 574,
"0.03967614": 219,
"0.046212029999999994": 163,
"0.05274792": 80,
"0.05928381": 22,
"0.0658197": 6
},
"firstBytePercentiles": {
"p10": 0.0030626,
"p25": 0.0037288,
"p50": 0.0045446,
"p75": 0.0056987,
"p90": 0.0079275,
"p95": 0.0106498,
"p99": 0.0232078,
"p99.9": 0.0425014,
"p99.99": 0.053907399
},
"rps": {
"mean": 11895.442419086467,
"stddev": 4680.144007737889,
"max": 49428.483163434095,
"min": 7.767708299001681,
"percentiles": {
"p10": 5033.421921559103,
"p25": 9573.484748448464,
"p50": 13033.295998370142,
"p75": 15115.087697941077,
"p90": 16694.490818031227,
"p95": 17559.747316341523,
"p99": 19370.0621015941,
"p99.9": 27827.79505647037,
"p99.99": 49428.483163434095
}
},
"details": {
"DNSDialup": {
"average": 0.10946267101026484,
"fastest": 0.105613999,
"slowest": 0.117580599
},
"DNSLookup": {
"average": 0.000017014461552436865,
"fastest": 2.7e-6,
"slowest": 0.0001871
},
"firstByte": {
"average": 0.005404881319645097,
"fastest": 0.0004608,
"slowest": 0.0658197
}
},
"statusCodeDistribution": {
"200": 176136
},
"errorDistribution": {
"aborted due to deadline": 35
}
}
@@ -1,113 +0,0 @@
{
"summary": {
"successRate": 1.0,
"total": 300.040740639,
"slowest": 0.134277698,
"fastest": 0.0001588,
"average": 0.005118276956612962,
"requestsPerSec": 6244.6486300816005,
"totalData": 5620866,
"sizePerRequest": 3,
"sizePerSec": 18733.6759269064
},
"metrics": {
"success_rate": 1.0,
"requests_per_sec": 6244.6486300816005,
"latency_ms": {
"min": 0.159,
"mean": 5.118,
"p50": 3.231,
"p95": 18.637,
"p99": 31.29,
"max": 134.278
}
},
"responseTimeHistogram": {
"0.0001588": 1,
"0.013570689800000002": 1735548,
"0.026982579600000004": 101468,
"0.04039446940000001": 32269,
"0.05380635920000001": 3626,
"0.06721824900000001": 577,
"0.08063013880000001": 96,
"0.09404202860000001": 24,
"0.10745391840000001": 10,
"0.12086580820000002": 2,
"0.134277698": 1
},
"latencyPercentiles": {
"p10": 0.0018471,
"p25": 0.0023739,
"p50": 0.003231,
"p75": 0.0048148,
"p90": 0.0103185,
"p95": 0.0186373,
"p99": 0.031289601,
"p99.9": 0.045978201,
"p99.99": 0.064620198
},
"firstByteHistogram": {
"0.0001585": 1,
"0.013570399799999999": 1735552,
"0.026982299599999995": 101464,
"0.04039419939999999": 32269,
"0.05380609919999999": 3626,
"0.067217999": 577,
"0.08062989879999999": 96,
"0.09404179859999999": 24,
"0.10745369839999999": 10,
"0.1208655982": 2,
"0.134277498": 1
},
"firstBytePercentiles": {
"p10": 0.0018469,
"p25": 0.0023736,
"p50": 0.003230698,
"p75": 0.0048145,
"p90": 0.0103182,
"p95": 0.018636705,
"p99": 0.031289501,
"p99.9": 0.045978001,
"p99.99": 0.064619898
},
"rps": {
"mean": 6831.9380563046725,
"stddev": 56287.82989499296,
"max": 9999997.751511324,
"min": 16.082057605351388,
"percentiles": {
"p10": 153.79173523161913,
"p25": 2417.210539039103,
"p50": 6983.156145760573,
"p75": 10011.91417787061,
"p90": 12038.644047401345,
"p95": 12949.051635822501,
"p99": 14395.393473988073,
"p99.9": 16346.58941450963,
"p99.99": 33698.39932558305
}
},
"details": {
"DNSDialup": {
"average": 0.05800439587499999,
"fastest": 0.056025299,
"slowest": 0.060235399
},
"DNSLookup": {
"average": 0.00001675,
"fastest": 2.8e-6,
"slowest": 0.000091
},
"firstByte": {
"average": 0.005117947834417036,
"fastest": 0.0001585,
"slowest": 0.134277498
}
},
"statusCodeDistribution": {
"200": 1873622
},
"errorDistribution": {
"aborted due to deadline": 27
}
}
@@ -1,11 +0,0 @@
label: wsl2-ubuntu
date: 2026-11-18T17:08:35Z
kernel: Linux 6.18.58.1-microsoft-standard-WSL2
cpu: AMD Ryzen 7 5800X3D 8-Core Processor
cpus: 16
memory: 32827248 kB
virtualisation: WSL2
build: release; edge worker threads: 2
caddy: unknown
oha: oha 1.17.0
duration: 15s per run; soak: 300s
+5
View File
@@ -23,6 +23,7 @@ test-hooks = []
[dependencies]
ianitor-core.workspace = true
url.workspace = true
rustls.workspace = true
rustls-pki-types.workspace = true
tokio-rustls.workspace = true
@@ -44,6 +45,10 @@ qrcode = { version = "0.14", default-features = false, features = ["svg"] }
# The offline root CLI asks for its passphrase without echo.
rpassword = "7"
# Windows Server, Caddy mode: the service control manager starts control and the guard.
[target.'cfg(windows)'.dependencies]
windows-service = "0.8"
[dev-dependencies]
ianitor-testkit.workspace = true
p12-keystore = "0.4"
+29 -4
View File
@@ -300,6 +300,8 @@ pub async fn overview(
viewer: Some(Viewer {
via: if actor.token_id.starts_with("user:") {
"authelia".into()
} else if actor.member.is_some() {
"session".into()
} else {
"token".into()
},
@@ -935,6 +937,9 @@ pub struct TokenCreate {
pub expires_in_days: Option<u64>,
#[serde(default)]
pub never_expires: bool,
/// `full` (default) or `previews`: a token for Fabrica that may only use `/api/v1/previews`.
#[serde(default)]
pub scope: Option<String>,
}
/// Make a token. Its value is in this response only.
@@ -966,7 +971,19 @@ pub async fn create_token(
let name = b
.name
.unwrap_or_else(|| format!("Token {}", ianitor_core::time::long_date(now())));
let (rec, value) = st.ctl.tokens.create(&name, expires).map_err(|e| {
let scope = match b.scope.as_deref() {
None => crate::tokens::Scope::Full,
Some(s) => crate::tokens::Scope::parse(s).ok_or_else(|| {
let mut e = ApiError::new(
StatusCode::UNPROCESSABLE_ENTITY,
"token.scope_value",
Params::new(),
);
e.body.field = Some("scope".into());
e
})?,
};
let (rec, value) = st.ctl.tokens.create(&name, expires, scope).map_err(|e| {
if e == "token.name" {
let mut err = ApiError::new(
StatusCode::UNPROCESSABLE_ENTITY,
@@ -1384,7 +1401,11 @@ impl Modify for Bearer {
mint_share_link, list_share_links, stop_share_link, stop_all_share_links, health, openapi,
super::pki::get_certs, super::pki::request_device, super::pki::get_request, super::pki::cancel_request,
super::pki::get_csr, super::pki::get_ext, super::pki::put_certificate, super::pki::renew, super::pki::revoke_device,
super::pki::make_bundle, super::pki::download_bundle, super::pki::get_engine, super::pki::switch_engine
super::pki::make_bundle, super::pki::download_bundle, super::pki::get_engine, super::pki::switch_engine,
super::previews::list_previews, super::previews::open_preview, super::previews::get_preview,
super::previews::kill_preview, super::previews::close_preview,
super::team::sign_out, super::team::get_team, super::team::invite, super::team::cancel_invite,
super::team::remove_member, super::team::set_root
),
components(schemas(
HostSpec, HealthCheckSpec, HeaderRuleSpec, HostWrite, HostPatch, UndoBody, RestoreBody, TokenCreate,
@@ -1394,13 +1415,17 @@ impl Modify for Bearer {
HealthReport, Done, super::pki::CertsView, super::pki::PkiRequestView, super::pki::IntermediateView,
super::pki::RootView, super::pki::DeviceView, super::pki::DeviceRequestBody, super::pki::CertificateBody,
super::pki::BundleBody, super::pki::BundleView, super::pki::EngineSwitchView, super::pki::EngineBody,
FallbackReady
FallbackReady, crate::hostspec::PreviewSpec, super::previews::PreviewOpen, super::previews::PreviewClose,
super::previews::PreviewView, super::previews::PreviewOpened, super::previews::PreviewOne,
super::previews::PreviewList, super::previews::PreviewClosed,
super::team::SignIn, super::team::SignedIn, super::team::MemberView, super::team::TeamView,
super::team::InviteBody, super::team::InviteMade, super::team::InviteView, super::team::RootBody
)),
modifiers(&Bearer),
tags(
(name = "overview"), (name = "hosts"), (name = "applies"), (name = "history"),
(name = "repo"), (name = "settings"), (name = "tokens"), (name = "share-links"),
(name = "certs"), (name = "engine")
(name = "certs"), (name = "engine"), (name = "previews"), (name = "team")
)
)]
pub struct ApiDoc;
+120 -16
View File
@@ -17,6 +17,8 @@
pub mod handlers;
pub mod pki;
pub mod previews;
pub mod team;
pub mod ui;
pub mod views;
@@ -45,11 +47,36 @@ use views::{ErrorBody, ErrorEnvelope};
pub const MAX_BODY: usize = 64 * 1024;
const RATE_PER_MINUTE: u32 = 120;
/// Who is calling: the API token's id and name.
/// Who is calling: the API token's id and name, and what the token may do.
#[derive(Debug, Clone)]
pub struct Actor {
pub token_id: String,
pub name: String,
pub scope: crate::tokens::Scope,
/// A team member signed in with a session (`crate::team`): their id, session and role.
/// `None` for API tokens and Authelia sign-ins, which may do everything.
pub member: Option<String>,
pub session: Option<String>,
pub role: Option<crate::team::Role>,
}
/// What only an admin may do (a `member` session gets 403 `team.admin_only`): API tokens,
/// the team, the engine and the CA.
fn admin_only(method: &str, path: &str) -> bool {
let write = !matches!(method, "GET" | "HEAD" | "OPTIONS");
path.starts_with("/api/v1/tokens")
|| (path.starts_with("/api/v1/team/") && !path.starts_with("/api/v1/team/me/"))
|| (write && path == "/api/v1/engine")
|| (write && path.starts_with("/api/v1/certs/intermediate"))
|| path.starts_with("/api/v1/pki-requests")
}
/// The only routes a `previews` token may call (T4: it can never touch another host).
fn in_preview_scope(path: &str) -> bool {
path == "/api/v1/previews"
|| path
.strip_prefix("/api/v1/previews/")
.is_some_and(|rest| !rest.is_empty() && !rest.contains('/'))
}
pub enum Stored {
@@ -330,11 +357,16 @@ pub(crate) fn host_allowed(ctl: &Control, headers: &HeaderMap) -> bool {
format!("127.0.0.1:{port}"),
format!("[::1]:{port}"),
];
// The admin host edge forwards the UI on, with or without edge's HTTPS port.
// The admin host the engine forwards the UI on, with any port: behind Docker's or a
// router's port mapping the visitor's port is not the engine's (T4). The name is what
// keeps a rebound DNS name out.
let ui = ctl.cfg.ui.as_ref().and_then(|u| u.hostname.as_deref());
let ui_ok = ui.is_some_and(|u| {
let edge_port = ctl.cfg.compile.https_listen.port();
host.eq_ignore_ascii_case(u) || host.eq_ignore_ascii_case(&format!("{u}:{edge_port}"))
let name = match host.rsplit_once(':') {
Some((n, p)) if !p.is_empty() && p.bytes().all(|c| c.is_ascii_digit()) => n,
_ => host,
};
name.eq_ignore_ascii_case(u)
});
ui_ok
|| ok.iter().any(|o| o.eq_ignore_ascii_case(host))
@@ -345,10 +377,6 @@ pub(crate) fn host_allowed(ctl: &Control, headers: &HeaderMap) -> bool {
.any(|a| a.eq_ignore_ascii_case(host))
}
/// Marks a request that came in on control's UI socket (`[ui] socket`).
#[derive(Debug, Clone, Copy)]
pub struct ViaUiSocket;
enum UiIdentity {
/// No sign-in headers: an API-token request.
None,
@@ -360,7 +388,7 @@ enum UiIdentity {
User(String, String),
}
fn ui_identity(ctl: &Control, headers: &HeaderMap, via_socket: bool) -> UiIdentity {
fn ui_identity(ctl: &Control, headers: &HeaderMap) -> UiIdentity {
let names_user = headers.keys().any(|k| k.as_str().starts_with("remote-"));
let proof = headers.get("x-ianitor-proof");
if !names_user && proof.is_none() {
@@ -370,11 +398,7 @@ fn ui_identity(ctl: &Control, headers: &HeaderMap, via_socket: bool) -> UiIdenti
(Some(p), Some(want)) => crate::util::ct_eq(p.as_bytes(), want),
_ => false,
};
// With a UI socket (G14 option b) the proof counts only there: the loopback port is open
// to every local process, and one that learned the proof (say, by taking control's port
// while it restarted and reading what edge sent) must not be able to use it.
let socket_only = ctl.cfg.ui.as_ref().is_some_and(|u| u.socket.is_some());
if !ok || (socket_only && !via_socket) {
if !ok {
return UiIdentity::Forged;
}
let users: Vec<&HeaderValue> = headers.get_all("remote-user").iter().collect();
@@ -436,8 +460,7 @@ async fn guard(State(st): State<Arc<AppState>>, mut req: Request, next: Next) ->
// The web UI, through edge on the admin host (docs/api.md, "Sign-in"): only a request
// with the per-boot proof edge adds is identified by its Remote-User. Any other
// request that names a user is refused, so a local process cannot claim to be one.
let via_socket = req.extensions().get::<ViaUiSocket>().is_some();
match ui_identity(&st.ctl, req.headers(), via_socket) {
match ui_identity(&st.ctl, req.headers()) {
UiIdentity::None => {}
UiIdentity::Forged => {
return Err(ApiError::new(
@@ -470,10 +493,65 @@ async fn guard(State(st): State<Arc<AppState>>, mut req: Request, next: Next) ->
req.extensions_mut().insert(Actor {
token_id: format!("user:{user}"),
name: display,
scope: crate::tokens::Scope::Full,
member: None,
session: None,
role: None,
});
return Ok(next.run(req).await);
}
}
// A team session (crate::team): the cookie, when no API token is given.
if !req.headers().contains_key(header::AUTHORIZATION)
&& let Some(value) = team::session_cookie(req.headers())
{
let ctl = st.ctl.clone();
let found = tokio::task::spawn_blocking(move || ctl.team.check(&value))
.await
.ok()
.flatten();
let Some((member, session)) = found else {
return Err(ApiError::new(
StatusCode::UNAUTHORIZED,
"session.unknown",
Params::new(),
));
};
let same_site = req
.headers()
.get("sec-fetch-site")
.is_none_or(|v| matches!(v.as_bytes(), b"same-origin" | b"none"));
if write && (!ui || !same_site) {
return Err(ApiError::new(
StatusCode::FORBIDDEN,
"request.csrf",
Params::new(),
));
}
if member.role != crate::team::Role::Admin
&& admin_only(method.as_str(), req.uri().path())
{
return Err(ApiError::new(
StatusCode::FORBIDDEN,
"team.admin_only",
Params::new(),
));
}
st.limit(&format!("member:{}", member.id), RATE_PER_MINUTE, 60)
.map_err(|s| {
ApiError::new(StatusCode::TOO_MANY_REQUESTS, "rate.limited", Params::new())
.retry(s)
})?;
req.extensions_mut().insert(Actor {
token_id: format!("member:{}", member.id),
name: member.name.clone(),
scope: crate::tokens::Scope::Full,
member: Some(member.id),
session: Some(session.id),
role: Some(member.role),
});
return Ok(next.run(req).await);
}
let auth = req
.headers()
.get(header::AUTHORIZATION)
@@ -499,6 +577,13 @@ async fn guard(State(st): State<Arc<AppState>>, mut req: Request, next: Next) ->
};
ApiError::new(StatusCode::UNAUTHORIZED, code, params)
})?;
if tok.scope == crate::tokens::Scope::Previews && !in_preview_scope(req.uri().path()) {
return Err(ApiError::new(
StatusCode::FORBIDDEN,
"token.scope",
Params::new(),
));
}
st.limit(&format!("token:{}", tok.id), RATE_PER_MINUTE, 60)
.map_err(|s| {
ApiError::new(StatusCode::TOO_MANY_REQUESTS, "rate.limited", Params::new()).retry(s)
@@ -506,6 +591,10 @@ async fn guard(State(st): State<Arc<AppState>>, mut req: Request, next: Next) ->
req.extensions_mut().insert(Actor {
token_id: tok.id,
name: tok.name,
scope: tok.scope,
member: None,
session: None,
role: None,
});
Ok(next.run(req).await)
}
@@ -629,6 +718,21 @@ pub fn router(st: Arc<AppState>) -> Router {
"/api/v1/engine",
get(pki::get_engine).post(pki::switch_engine),
)
.route(
"/api/v1/previews",
get(previews::list_previews).post(previews::open_preview),
)
.route("/api/v1/previews/close", post(previews::close_preview))
.route(
"/api/v1/previews/{hostname}",
get(previews::get_preview).delete(previews::kill_preview),
)
.route("/api/v1/team", get(team::get_team))
.route("/api/v1/team/invites", post(team::invite))
.route("/api/v1/team/invites/{id}", delete(team::cancel_invite))
.route("/api/v1/team/members/{id}", delete(team::remove_member))
.route("/api/v1/team/me/root", axum::routing::put(team::set_root))
.route("/api/v1/session/end", post(team::sign_out))
.route("/api/v1/health", get(h::health))
.route("/api/v1/openapi.json", get(h::openapi))
.method_not_allowed_fallback(method_not_allowed)
+265
View File
@@ -0,0 +1,265 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! `/api/v1/previews`: Fabrica's branch previews (T4). The only routes a `previews` token may
//! call (the guard in `api` refuses every other route for it).
// An error answer is built once per failed request; boxing it buys nothing.
#![allow(clippy::result_large_err)]
use std::sync::Arc;
use axum::Extension;
use axum::extract::{Path, State};
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
use super::views::{ApplyView, apply_view};
use super::{Actor, ApiError, AppState, Body};
use crate::messages::Params;
use crate::util::rfc3339;
type Shared = State<Arc<AppState>>;
fn json<T: Serialize>(status: StatusCode, v: &T) -> Response {
(status, axum::Json(v)).into_response()
}
#[derive(Debug, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct PreviewOpen {
/// Fabrica's project, e.g. `mnovak/Arca` or `github:acme/web`.
pub project: String,
/// The git branch, as the git host names it.
pub branch: String,
/// Where the branch's build runs, e.g. `http://10.0.0.5:8080` (must be in `[previews] upstreams`).
pub upstream: String,
/// Seconds until the preview closes by itself (default from `[previews]`).
pub ttl: Option<u64>,
}
#[derive(Debug, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct PreviewClose {
pub project: String,
pub branch: String,
}
#[derive(Debug, Clone, Serialize, ToSchema)]
pub struct PreviewView {
pub hostname: String,
/// `https://<hostname>/`
pub url: String,
pub project: String,
pub branch: String,
pub upstream: String,
pub expires_at: String,
/// `applying`, `live` or `failed`.
pub state: String,
/// Why it failed, in plain English.
#[serde(skip_serializing_if = "Option::is_none")]
pub problem: Option<String>,
}
#[derive(Debug, Serialize, ToSchema)]
pub struct PreviewOpened {
pub preview: PreviewView,
pub apply: ApplyView,
}
#[derive(Debug, Serialize, ToSchema)]
pub struct PreviewOne {
pub preview: PreviewView,
}
#[derive(Debug, Serialize, ToSchema)]
pub struct PreviewList {
pub items: Vec<PreviewView>,
/// The domain previews live under; absent when previews are off.
pub domain: Option<String>,
}
#[derive(Debug, Serialize, ToSchema)]
pub struct PreviewClosed {
pub apply: ApplyView,
}
fn view(st: &AppState, p: &crate::previews::Listed) -> PreviewView {
let (state, problem) = st
.ctl
.preview_state(&p.hostname)
.unwrap_or(("live".into(), None));
PreviewView {
url: format!("https://{}/", p.hostname),
hostname: p.hostname.clone(),
project: p.project.clone(),
branch: p.branch.clone(),
upstream: p.upstream.clone(),
expires_at: rfc3339(p.expires_at),
state,
problem,
}
}
/// Every open preview.
#[utoipa::path(get, path = "/api/v1/previews", tag = "previews",
responses((status = 200, body = PreviewList)), security(("bearer" = [])))]
pub async fn list_previews(State(st): Shared) -> Result<Response, ApiError> {
let domain = st.ctl.cfg.previews.as_ref().map(|p| p.domain.clone());
let items = if domain.is_some() {
st.ctl.previews()?.iter().map(|p| view(&st, p)).collect()
} else {
Vec::new()
};
Ok(json(StatusCode::OK, &PreviewList { items, domain }))
}
/// Open a branch's preview, or move it to a new upstream and lifetime. The host is
/// `<branch>--<project>.<preview domain>`; it is live when its apply is kept.
#[utoipa::path(post, path = "/api/v1/previews", tag = "previews", request_body = PreviewOpen,
responses((status = 202, body = PreviewOpened), (status = 403, body = super::views::ErrorEnvelope),
(status = 409, body = super::views::ErrorEnvelope), (status = 422, body = super::views::ErrorEnvelope)),
security(("bearer" = [])))]
pub async fn open_preview(
State(st): Shared,
Extension(actor): Extension<Actor>,
body: Body<PreviewOpen>,
) -> Result<Response, ApiError> {
let b = body.value;
let (hostname, expires_at, rec) =
st.ctl
.open_preview(&b.project, &b.branch, &b.upstream, b.ttl, &actor.name)?;
let preview = PreviewView {
url: format!("https://{hostname}/"),
hostname,
project: b.project,
branch: b.branch,
upstream: b.upstream,
expires_at: rfc3339(expires_at),
state: "applying".into(),
problem: None,
};
Ok(json(
StatusCode::ACCEPTED,
&PreviewOpened {
preview,
apply: apply_view(&st.ctl, &rec),
},
))
}
/// One preview and where it stands (Fabrica polls this after opening one).
#[utoipa::path(get, path = "/api/v1/previews/{hostname}", tag = "previews",
params(("hostname" = String, Path)),
responses((status = 200, body = PreviewOne), (status = 404, body = super::views::ErrorEnvelope)),
security(("bearer" = [])))]
pub async fn get_preview(
State(st): Shared,
Path(hostname): Path<String>,
) -> Result<Response, ApiError> {
st.ctl.previews_cfg()?;
let not_found = || ApiError::new(StatusCode::NOT_FOUND, "preview.not_found", Params::new());
if let Some(p) = st
.ctl
.previews()?
.into_iter()
.find(|p| p.hostname == hostname)
{
return Ok(json(
StatusCode::OK,
&PreviewOne {
preview: view(&st, &p),
},
));
}
// Not at the head: a preview whose apply is still running or failed.
let (state, problem) = st.ctl.preview_state(&hostname).ok_or_else(not_found)?;
let rec = st
.ctl
.records()
.into_iter()
.rev()
.find(|r| r.hosts.contains(&hostname))
.ok_or_else(not_found)?;
let pv = rec
.attempted_host
.as_ref()
.and_then(|h| h.preview.clone())
.ok_or_else(not_found)?;
Ok(json(
StatusCode::OK,
&PreviewOne {
preview: PreviewView {
url: format!("https://{hostname}/"),
hostname,
project: pv.project,
branch: pv.branch,
upstream: rec
.attempted_host
.as_ref()
.and_then(|h| h.upstreams.first().cloned())
.unwrap_or_default(),
expires_at: rfc3339(u64::try_from(pv.expires_at).unwrap_or(0)),
state,
problem,
},
},
))
}
/// Close a preview now (the previews screen's Close, or Fabrica after a merge).
#[utoipa::path(delete, path = "/api/v1/previews/{hostname}", tag = "previews",
params(("hostname" = String, Path)),
responses((status = 202, body = PreviewClosed), (status = 404, body = super::views::ErrorEnvelope)),
security(("bearer" = [])))]
pub async fn kill_preview(
State(st): Shared,
Extension(actor): Extension<Actor>,
Path(hostname): Path<String>,
) -> Result<Response, ApiError> {
let rec = st.ctl.close_preview(&hostname, &actor.name, "Closed the")?;
Ok(json(
StatusCode::ACCEPTED,
&PreviewClosed {
apply: apply_view(&st.ctl, &rec),
},
))
}
/// Close a branch's preview by project and branch (Fabrica, when the branch is merged or
/// deleted).
#[utoipa::path(post, path = "/api/v1/previews/close", tag = "previews", request_body = PreviewClose,
responses((status = 202, body = PreviewClosed), (status = 404, body = super::views::ErrorEnvelope)),
security(("bearer" = [])))]
pub async fn close_preview(
State(st): Shared,
Extension(actor): Extension<Actor>,
body: Body<PreviewClose>,
) -> Result<Response, ApiError> {
let b = body.value;
let p = st.ctl.previews_cfg()?;
let hostname = ianitor_core::preview::hostname(&b.project, &b.branch, &p.domain)
.map_err(crate::previews::name_fail)?;
let mine = st
.ctl
.previews()?
.into_iter()
.any(|x| x.hostname == hostname && x.project == b.project && x.branch == b.branch);
if !mine {
return Err(ApiError::new(
StatusCode::NOT_FOUND,
"preview.not_found",
Params::new(),
));
}
let rec = st.ctl.close_preview(&hostname, &actor.name, "Closed the")?;
Ok(json(
StatusCode::ACCEPTED,
&PreviewClosed {
apply: apply_view(&st.ctl, &rec),
},
))
}
+351
View File
@@ -0,0 +1,351 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Team sign-in and the team list (`crate::team`). `POST /api/v1/session` is the one call
//! without a token or session: it redeems a setup or invite link. Everything else here goes
//! through the guard; inviting and removing people needs the admin role.
// An error answer is built once per failed request; boxing it buys nothing.
#![allow(clippy::result_large_err)]
use std::sync::Arc;
use axum::Extension;
use axum::extract::{Path, Request, State};
use axum::http::{HeaderMap, HeaderValue, StatusCode, header};
use axum::response::{IntoResponse, Response};
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
use super::{Actor, ApiError, AppState, Body};
use crate::messages::Params;
use crate::team::{COOKIE, Member, Role, SESSION_SECS, match_code};
use crate::util::rfc3339;
type Shared = State<Arc<AppState>>;
fn json<T: Serialize>(status: StatusCode, v: &T) -> Response {
(status, axum::Json(v)).into_response()
}
fn refused(code: &'static str) -> ApiError {
let status = match code {
"internal" => StatusCode::INTERNAL_SERVER_ERROR,
"session.code" => StatusCode::UNAUTHORIZED,
"team.not_found" => StatusCode::NOT_FOUND,
"team.last_admin" | "team.full" => StatusCode::CONFLICT,
_ => StatusCode::UNPROCESSABLE_ENTITY,
};
ApiError::new(status, code, Params::new())
}
/// The session cookie's value from a request, if any.
pub fn session_cookie(headers: &HeaderMap) -> Option<String> {
headers
.get_all(header::COOKIE)
.iter()
.filter_map(|v| v.to_str().ok())
.flat_map(|v| v.split(';'))
.filter_map(|kv| kv.trim().split_once('='))
.find(|(k, _)| *k == COOKIE)
.map(|(_, v)| v.to_owned())
}
#[derive(Debug, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct SignIn {
/// The code from a setup or invite link (`#signin=<code>`).
pub code: String,
/// Your name (setup links only; an invite already names you).
pub name: Option<String>,
/// What to call this browser in the sessions list.
pub device: Option<String>,
}
#[derive(Debug, Clone, Serialize, ToSchema)]
pub struct MemberView {
pub id: String,
pub name: String,
/// `admin` or `member`.
pub role: String,
pub added_at: String,
/// The member's Tessera root and its match code, when they recorded it.
pub tessera_root: Option<String>,
pub match_code: Option<String>,
}
impl From<&Member> for MemberView {
fn from(m: &Member) -> Self {
MemberView {
id: m.id.clone(),
name: m.name.clone(),
role: m.role.as_str().into(),
added_at: rfc3339(m.added_at),
tessera_root: m.tessera_root.clone(),
match_code: m.tessera_root.as_deref().and_then(match_code),
}
}
}
#[derive(Debug, Serialize, ToSchema)]
pub struct SignedIn {
pub member: MemberView,
}
/// Redeem a setup or invite link: sets the session cookie. No token needed (this is the
/// door). At most 20 tries a minute for the whole server.
pub async fn sign_in(st: Arc<AppState>, req: Request) -> Response {
async {
if st.limit("signin", 20, 60).is_err() {
return Err(ApiError::new(
StatusCode::TOO_MANY_REQUESTS,
"rate.limited",
Params::new(),
)
.retry(60));
}
// Only the UI's own page signs in (the custom header needs a CORS preflight that
// control never answers), and never a cross-site page.
let h = req.headers();
let ui = h.get("x-ianitor-ui").is_some_and(|v| v.as_bytes() == b"1");
let site_ok = h
.get("sec-fetch-site")
.is_none_or(|v| matches!(v.as_bytes(), b"same-origin" | b"none"));
if !ui || !site_ok {
return Err(ApiError::new(
StatusCode::FORBIDDEN,
"request.csrf",
Params::new(),
));
}
let body = <Body<SignIn> as axum::extract::FromRequest<()>>::from_request(req, &()).await?;
let b = body.value;
let team = st.ctl.team.clone();
let device = b.device.unwrap_or_else(|| "Browser".into());
let (member, value) =
tokio::task::spawn_blocking(move || team.redeem(&b.code, b.name.as_deref(), &device))
.await
.map_err(|_| ApiError::internal("sign-in"))?
.map_err(|r| refused(r.0))?;
log::info!(target: "ianitor::team", "{} ({}) signed in", member.name, member.role.as_str());
let mut resp = json(
StatusCode::OK,
&SignedIn {
member: MemberView::from(&member),
},
);
let cookie = format!(
"{COOKIE}={value}; Path=/; Secure; HttpOnly; SameSite=Strict; Max-Age={SESSION_SECS}"
);
if let Ok(v) = HeaderValue::from_str(&cookie) {
resp.headers_mut().insert(header::SET_COOKIE, v);
}
resp.headers_mut()
.insert(header::CACHE_CONTROL, HeaderValue::from_static("no-store"));
Ok(resp)
}
.await
.unwrap_or_else(IntoResponse::into_response)
}
/// Sign this browser out.
#[utoipa::path(post, path = "/api/v1/session/end", tag = "team",
responses((status = 200, body = super::views::Done)), security(("bearer" = [])))]
pub async fn sign_out(
State(st): Shared,
Extension(actor): Extension<Actor>,
) -> Result<Response, ApiError> {
if let Some(id) = &actor.session {
st.ctl.team.end_session(id).map_err(ApiError::internal)?;
}
let mut resp = json(
StatusCode::OK,
&super::views::Done {
message: "Done.".into(),
},
);
if let Ok(v) = HeaderValue::from_str(&format!(
"{COOKIE}=; Path=/; Secure; HttpOnly; SameSite=Strict; Max-Age=0"
)) {
resp.headers_mut().insert(header::SET_COOKIE, v);
}
Ok(resp)
}
#[derive(Debug, Serialize, ToSchema)]
pub struct InviteView {
pub id: String,
pub name: Option<String>,
pub role: String,
pub expires_at: String,
}
#[derive(Debug, Serialize, ToSchema)]
pub struct TeamView {
/// Who is asking; absent for an API token.
pub me: Option<MemberView>,
pub members: Vec<MemberView>,
pub invites: Vec<InviteView>,
/// Whether Authelia signs people in on this server instead.
pub authelia: bool,
}
/// The team: members, open invites, and who you are.
#[utoipa::path(get, path = "/api/v1/team", tag = "team",
responses((status = 200, body = TeamView)), security(("bearer" = [])))]
pub async fn get_team(
State(st): Shared,
Extension(actor): Extension<Actor>,
) -> Result<Response, ApiError> {
let members = st.ctl.team.members().map_err(ApiError::internal)?;
let invites = st
.ctl
.team
.codes()
.map_err(ApiError::internal)?
.into_iter()
.filter(|c| c.kind == "invite")
.map(|c| InviteView {
id: c.id,
name: c.name,
role: c.role.as_str().into(),
expires_at: rfc3339(c.expires_at),
})
.collect();
let me = actor
.member
.as_ref()
.and_then(|id| members.iter().find(|m| &m.id == id))
.map(MemberView::from);
Ok(json(
StatusCode::OK,
&TeamView {
me,
members: members.iter().map(MemberView::from).collect(),
invites,
authelia: st.ctl.ui_proof.is_some(),
},
))
}
#[derive(Debug, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct InviteBody {
pub name: String,
/// `admin` or `member` (default).
pub role: Option<String>,
}
#[derive(Debug, Serialize, ToSchema)]
pub struct InviteMade {
pub invite: InviteView,
/// Send this to the person: `<the UI's address>/#signin=<code>`. Shown once.
pub link_fragment: String,
}
/// Invite someone (admin). The link is shown once.
#[utoipa::path(post, path = "/api/v1/team/invites", tag = "team", request_body = InviteBody,
responses((status = 201, body = InviteMade), (status = 403, body = super::views::ErrorEnvelope)), security(("bearer" = [])))]
pub async fn invite(
State(st): Shared,
Extension(actor): Extension<Actor>,
body: Body<InviteBody>,
) -> Result<Response, ApiError> {
let role = match body.value.role.as_deref() {
None => Role::Member,
Some(r) => Role::parse(r).ok_or_else(|| refused("team.role"))?,
};
let (code, value) = st
.ctl
.team
.invite(&body.value.name, role, &actor.name)
.map_err(|r| refused(r.0))?;
log::info!(target: "ianitor::team", "{} invited {} as {}", actor.name, code.name.clone().unwrap_or_default(), role.as_str());
Ok(json(
StatusCode::CREATED,
&InviteMade {
invite: InviteView {
id: code.id,
name: code.name,
role: role.as_str().into(),
expires_at: rfc3339(code.expires_at),
},
link_fragment: format!("#signin={value}"),
},
))
}
/// Cancel an invite that was not used (admin).
#[utoipa::path(delete, path = "/api/v1/team/invites/{id}", tag = "team", params(("id" = String, Path)),
responses((status = 200, body = super::views::Done)), security(("bearer" = [])))]
pub async fn cancel_invite(
State(st): Shared,
Path(id): Path<String>,
) -> Result<Response, ApiError> {
if !st.ctl.team.cancel_invite(&id).map_err(ApiError::internal)? {
return Err(refused("team.not_found"));
}
Ok(json(
StatusCode::OK,
&super::views::Done {
message: "Done.".into(),
},
))
}
/// Remove a member and sign them out everywhere (admin). The last admin stays.
#[utoipa::path(delete, path = "/api/v1/team/members/{id}", tag = "team", params(("id" = String, Path)),
responses((status = 200, body = super::views::Done), (status = 409, body = super::views::ErrorEnvelope)), security(("bearer" = [])))]
pub async fn remove_member(
State(st): Shared,
Extension(actor): Extension<Actor>,
Path(id): Path<String>,
) -> Result<Response, ApiError> {
match st.ctl.team.remove(&id).map_err(|r| refused(r.0))? {
Some(m) => {
log::info!(target: "ianitor::team", "{} removed {}", actor.name, m.name);
Ok(json(
StatusCode::OK,
&super::views::Done {
message: "Done.".into(),
},
))
}
None => Err(refused("team.not_found")),
}
}
#[derive(Debug, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct RootBody {
/// Your Tessera root (base64url, as Custos shows it under Domi identity), or null.
pub tessera_root: Option<String>,
}
/// Record your own Tessera root, so the team list shows its match code.
#[utoipa::path(put, path = "/api/v1/team/me/root", tag = "team", request_body = RootBody,
responses((status = 200, body = super::views::Done)), security(("bearer" = [])))]
pub async fn set_root(
State(st): Shared,
Extension(actor): Extension<Actor>,
body: Body<RootBody>,
) -> Result<Response, ApiError> {
let Some(me) = &actor.member else {
return Err(ApiError::new(
StatusCode::FORBIDDEN,
"team.session_only",
Params::new(),
));
};
st.ctl
.team
.set_root(me, body.value.tessera_root.as_deref())
.map_err(|r| refused(r.0))?;
Ok(json(
StatusCode::OK,
&super::views::Done {
message: "Done.".into(),
},
))
}
+16
View File
@@ -43,6 +43,22 @@ pub async fn front(State(st): State<Arc<AppState>>, req: Request, next: Next) ->
.into_response(),
};
}
// The door: redeeming a setup or invite link needs no token (crate::team).
if path == "/api/v1/session" {
if !host_allowed(&st.ctl, req.headers()) {
return ApiError::new(StatusCode::FORBIDDEN, "request.host", Params::new())
.into_response();
}
if req.method() != "POST" {
return ApiError::new(
StatusCode::METHOD_NOT_ALLOWED,
"request.method",
Params::new(),
)
.into_response();
}
return super::team::sign_in(st, req).await;
}
if path.starts_with("/api/") || path == "/api" {
return next.run(req).await;
}
+3
View File
@@ -746,6 +746,8 @@ pub struct TokenView {
pub last_used_at: Option<String>,
pub expires_at: Option<String>,
pub revoked_at: Option<String>,
/// `full` or `previews`.
pub scope: String,
}
impl From<&crate::tokens::TokenRecord> for TokenView {
@@ -757,6 +759,7 @@ impl From<&crate::tokens::TokenRecord> for TokenView {
last_used_at: t(r.last_used_at),
expires_at: t(r.expires_at),
revoked_at: t(r.revoked_at),
scope: r.scope.as_str().into(),
}
}
}
+4 -7
View File
@@ -127,15 +127,12 @@ async fn revert(cfg: &Config, why: &str) -> Result<bool, String> {
return Ok(false);
}
let loaded = async {
let sock = cfg
.caddy_compile()
.caddy_admin_socket
.clone()
.ok_or("no caddy_admin_socket is configured")?;
let sock = crate::caddy_link::Admin::from_compile(cfg.caddy_compile())
.ok_or("no caddy_admin_socket (or loopback caddy_admin) is configured")?;
let text = std::fs::read(&cfg.caddy.config)
.map_err(|e| format!("cannot read {}: {e}", cfg.caddy.config.display()))?;
crate::caddy_link::load(Path::new(&sock), &text).await?;
if !crate::caddy_link::runs(Path::new(&sock), &text).await? {
crate::caddy_link::load(&sock, &text).await?;
if !crate::caddy_link::runs(&sock, &text).await? {
return Err("Caddy took caddy.json but does not run it".to_owned());
}
Ok::<_, String>(())
+92 -51
View File
@@ -3,60 +3,116 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Control's side of the Caddy fallback while it serves (Mark, 2026-11-08: changes keep
//! working under Caddy): loading a config through Caddy's admin API on its Unix socket
//! working under Caddy): loading a config through Caddy's admin API on its Unix socket, or on
//! loopback TCP where there are no Unix sockets (Windows Caddy mode, T4)
//! (`POST /load`, the whole JSON) and reading back what runs (`GET /config/`), probing a host
//! *through* Caddy ("does Caddy answer at all") and its upstreams directly (the health watch,
//! judged like edge's), and the certificate Caddy serves.
use std::net::SocketAddr;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::io::{AsyncReadExt, AsyncWriteExt};
const TIMEOUT: Duration = Duration::from_secs(10);
/// One request to Caddy's admin API (HTTP/1.0: the answer is never chunked).
async fn admin(socket: &Path, request: &[u8]) -> Result<(u16, Vec<u8>), String> {
#[cfg(unix)]
{
use tokio::io::{AsyncReadExt, AsyncWriteExt};
let exchange = async {
let mut s = tokio::net::UnixStream::connect(socket).await?;
/// Where Caddy's admin API listens: a Unix socket (Linux, mode 0660), or loopback TCP
/// (Windows, where control and Caddy are the only services and the port is on 127.0.0.1).
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Admin {
Unix(PathBuf),
Tcp(SocketAddr),
}
impl Admin {
/// From the compile facts: the socket when there is one, else a loopback TCP address.
pub fn from_compile(c: &crate::config::Compile) -> Option<Admin> {
match (&c.caddy_admin_socket, c.caddy_admin) {
(Some(s), _) => Some(Admin::Unix(PathBuf::from(s))),
(None, Some(a)) if a.ip().is_loopback() => Some(Admin::Tcp(a)),
_ => None,
}
}
/// The `Host` header Caddy's admin API accepts (its origin check).
fn host(&self) -> String {
match self {
Admin::Unix(_) => "localhost".into(),
Admin::Tcp(a) => a.to_string(),
}
}
}
impl From<&Path> for Admin {
fn from(p: &Path) -> Admin {
Admin::Unix(p.to_owned())
}
}
async fn exchange(admin: &Admin, request: &[u8]) -> std::io::Result<Vec<u8>> {
let mut buf = Vec::new();
match admin {
#[cfg(unix)]
Admin::Unix(p) => {
let mut s = tokio::net::UnixStream::connect(p).await?;
s.write_all(request).await?;
let mut buf = Vec::new();
s.read_to_end(&mut buf).await?;
Ok::<_, std::io::Error>(buf)
};
let buf = tokio::time::timeout(TIMEOUT, exchange)
.await
.map_err(|_| "Caddy's admin API did not answer within 10 s".to_owned())?
.map_err(|e| format!("Caddy's admin API cannot be reached: {e}"))?;
let split = buf
}
#[cfg(not(unix))]
Admin::Unix(_) => {
return Err(std::io::Error::other(
"Caddy's admin socket needs Unix; set caddy_admin = \"127.0.0.1:2019\" instead",
));
}
Admin::Tcp(a) => {
let mut s = tokio::net::TcpStream::connect(a).await?;
s.write_all(request).await?;
s.read_to_end(&mut buf).await?;
}
}
Ok(buf)
}
/// One request to Caddy's admin API (HTTP/1.0: the answer is never chunked). `request` has
/// `{host}` where the Host header value goes.
async fn admin(admin: &Admin, request: &[u8]) -> Result<(u16, Vec<u8>), String> {
let host = admin.host();
let request = {
let split = request
.windows(4)
.position(|w| w == b"\r\n\r\n")
.ok_or("no answer from Caddy's admin API")?;
let head = String::from_utf8_lossy(&buf[..split]);
let status: u16 = head
.split(' ')
.nth(1)
.and_then(|s| s.parse().ok())
.ok_or("no answer from Caddy's admin API")?;
Ok((status, buf[split + 4..].to_vec()))
}
#[cfg(not(unix))]
{
let _ = (socket, request);
Err("Caddy's admin socket needs Unix".into())
}
.unwrap_or(request.len());
let head = String::from_utf8_lossy(&request[..split]).replace("{host}", &host);
let mut r = head.into_bytes();
r.extend_from_slice(&request[split..]);
r
};
let buf = tokio::time::timeout(TIMEOUT, exchange(admin, &request))
.await
.map_err(|_| "Caddy's admin API did not answer within 10 s".to_owned())?
.map_err(|e| format!("Caddy's admin API cannot be reached: {e}"))?;
let split = buf
.windows(4)
.position(|w| w == b"\r\n\r\n")
.ok_or("no answer from Caddy's admin API")?;
let head = String::from_utf8_lossy(&buf[..split]);
let status: u16 = head
.split(' ')
.nth(1)
.and_then(|s| s.parse().ok())
.ok_or("no answer from Caddy's admin API")?;
Ok((status, buf[split + 4..].to_vec()))
}
/// Load a full Caddy JSON config. Caddy swaps it in gracefully or refuses it (and keeps the
/// old one). `Cache-Control: must-revalidate` makes Caddy load it even when it is the same as
/// the running one, so certificate and device files are read again (without it an identical
/// config is a no-op: QC round 2, B1; `qc_reloading_the_same_caddy_json_rereads_the_certificate_files`).
pub async fn load(socket: &Path, config: &[u8]) -> Result<(), String> {
pub async fn load(socket: &Admin, config: &[u8]) -> Result<(), String> {
let mut req = format!(
"POST /load HTTP/1.0\r\nHost: localhost\r\nContent-Type: application/json\r\nCache-Control: must-revalidate\r\nContent-Length: {}\r\n\r\n",
"POST /load HTTP/1.0\r\nHost: {{host}}\r\nContent-Type: application/json\r\nCache-Control: must-revalidate\r\nContent-Length: {}\r\n\r\n",
config.len()
)
.into_bytes();
@@ -77,8 +133,8 @@ pub async fn load(socket: &Path, config: &[u8]) -> Result<(), String> {
}
/// The config Caddy runs now.
pub async fn running_config(socket: &Path) -> Result<serde_json::Value, String> {
let (status, body) = admin(socket, b"GET /config/ HTTP/1.0\r\nHost: localhost\r\n\r\n").await?;
pub async fn running_config(socket: &Admin) -> Result<serde_json::Value, String> {
let (status, body) = admin(socket, b"GET /config/ HTTP/1.0\r\nHost: {host}\r\n\r\n").await?;
if status != 200 {
return Err(format!(
"Caddy's admin API answered {status} to GET /config/"
@@ -88,7 +144,7 @@ pub async fn running_config(socket: &Path) -> Result<serde_json::Value, String>
}
/// Whether Caddy runs exactly this config (as JSON values, so formatting does not matter).
pub async fn runs(socket: &Path, config: &[u8]) -> Result<bool, String> {
pub async fn runs(socket: &Admin, config: &[u8]) -> Result<bool, String> {
let want: serde_json::Value =
serde_json::from_slice(config).map_err(|e| format!("not JSON: {e}"))?;
Ok(running_config(socket).await? == want)
@@ -315,21 +371,6 @@ pub async fn probe_upstream(
"GET {path} HTTP/1.1\r\nHost: {host_header}\r\nUser-Agent: ianitor-health\r\nConnection: close\r\n\r\n"
);
let run = async {
if let Some(path) = u.unix_path() {
// A socket upstream (the admin host on control's own UI socket): plain HTTP.
#[cfg(unix)]
{
let s = tokio::net::UnixStream::connect(path)
.await
.map_err(|e| io_kind(&e))?;
return ask(s, req.as_bytes()).await.map_err(|e| io_kind(&e));
}
#[cfg(not(unix))]
{
let _ = path;
return Err("refused");
}
}
let tcp = match tokio::net::TcpStream::connect(u.authority()).await {
Ok(t) => t,
Err(e) => return Err(io_kind(&e)),
+69 -23
View File
@@ -58,6 +58,61 @@ pub struct Config {
/// Switching between Pingora and the Caddy fallback at runtime.
#[serde(default)]
pub engine: Option<EngineConfig>,
/// Branch previews for Fabrica (`POST /api/v1/previews`); off without it.
#[serde(default)]
pub previews: Option<PreviewsConfig>,
}
/// `[previews]`: where branch previews live and what they may point at.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct PreviewsConfig {
/// Previews are `<branch>--<project>.<domain>`; a wildcard DNS record points here.
pub domain: String,
/// `domi` (the Domi CA, internal) or `letsencrypt` (public; one certificate per preview).
#[serde(default = "default_preview_tls")]
pub tls: String,
/// `none` (anyone with the address) or `forward-auth` (behind the site's sign-in).
#[serde(default = "default_preview_auth")]
pub auth: String,
/// Where previews may send traffic: `10.0.0.0/8`, `127.0.0.1:20000-29999`, `app.internal`,
/// `*.svc.internal:8080`. Nothing else is accepted; control's own port and Caddy's admin
/// port never are. Empty: every preview is refused.
#[serde(default)]
pub upstreams: Vec<String>,
#[serde(default = "default_preview_ttl")]
pub default_ttl_secs: u64,
#[serde(default = "default_preview_min_ttl")]
pub min_ttl_secs: u64,
#[serde(default = "default_preview_max_ttl")]
pub max_ttl_secs: u64,
#[serde(default = "default_preview_max")]
pub max_previews: usize,
/// How often expired previews are looked for.
#[serde(default = "default_preview_sweep")]
pub sweep_secs: u64,
}
fn default_preview_tls() -> String {
"domi".into()
}
fn default_preview_auth() -> String {
"none".into()
}
fn default_preview_ttl() -> u64 {
72 * 3600
}
fn default_preview_min_ttl() -> u64 {
300
}
fn default_preview_max_ttl() -> u64 {
30 * 86_400
}
fn default_preview_max() -> usize {
100
}
fn default_preview_sweep() -> u64 {
30
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -116,25 +171,21 @@ pub struct Compile {
/// Proxies in front whose X-Forwarded-For is believed (e.g. ["127.0.0.1"] beside Caddy).
#[serde(default)]
pub trusted_proxies: Vec<std::net::IpAddr>,
/// The front proxy's Unix socket (beside Caddy): both engines serve the HTTPS hosts on it
/// and believe its X-Forwarded-For.
#[serde(default)]
pub proxy_socket: Option<String>,
}
impl Compile {
pub fn options(&self) -> CompileOptions {
use ianitor_core::compile::windows_path as w;
CompileOptions {
http_listen: self.http_listen,
https_listen: self.https_listen,
cert_dir: self.cert_dir.clone(),
state_dir: self.state_dir.clone(),
access_log: self.access_log.clone(),
caddy_credentials_dir: self.caddy_credentials_dir.clone(),
cert_dir: w(&self.cert_dir),
state_dir: w(&self.state_dir),
access_log: w(&self.access_log),
caddy_credentials_dir: w(&self.caddy_credentials_dir),
caddy_admin: self.caddy_admin,
caddy_admin_socket: self.caddy_admin_socket.clone(),
trusted_proxies: self.trusted_proxies.clone(),
proxy_socket: self.proxy_socket.clone(),
}
}
}
@@ -195,13 +246,6 @@ impl Config {
}
pub fn check(&self) -> Result<(), ConfigError> {
if let Some(s) = self.ui.as_ref().and_then(|u| u.socket.as_ref())
&& (!s.is_absolute() || s.as_os_str().len() > 100)
{
return Err(ConfigError::Invalid(
"ui.socket must be an absolute path of at most 100 characters".into(),
));
}
if !self.listen.ip().is_loopback() {
return Err(ConfigError::Invalid(format!(
"listen = {} is not a loopback address; ianitor-control only listens on 127.0.0.1 or ::1",
@@ -252,6 +296,9 @@ impl Config {
"pki.kdf_iterations must be at least {MIN_KDF_ITERATIONS}"
)));
}
if let Some(p) = &self.previews {
crate::previews::check_config(p, self).map_err(ConfigError::Invalid)?;
}
if let Some(m) = empty_model() {
for c in std::iter::once(&self.compile).chain(self.compile_caddy.as_ref()) {
ianitor_core::compile::edge(&m, &c.options())
@@ -353,16 +400,15 @@ pub struct UiConfig {
pub proof_credential: Option<String>,
/// The built web UI (served at `/`).
pub static_dir: Option<PathBuf>,
/// A Unix socket (mode 0660; its directory only for the ianitor group) on which control
/// also serves the API for the admin host (G14 option b). With it, the proof signs in only
/// on this socket; over the loopback port, which any local process can reach (or take while
/// control restarts), only API tokens work. The admin host's upstream is then
/// `unix:<this path>`.
#[serde(default)]
pub socket: Option<PathBuf>,
/// Authelia's logout address (e.g. `https://auth.example/logout`), shown as "Sign out".
#[serde(default)]
pub logout_url: Option<String>,
/// Without Authelia (T4): control keeps the admin host in the routes repository itself,
/// as a plain host to this API with this certificate (`letsencrypt` or `domi`); people
/// sign in with team links (crate::team). Unset: the admin host is managed by hand
/// (the NixOS module's Authelia setup).
#[serde(default)]
pub admin_tls: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
+14 -3
View File
@@ -150,7 +150,6 @@ pub async fn run(args: &[String]) -> Result<(), String> {
caddy_admin: None,
caddy_admin_socket: None,
trusted_proxies: Vec::new(),
proxy_socket: None,
},
compile_caddy: None,
pki: Some(ianitor_control::config::PkiConfig {
@@ -169,14 +168,26 @@ pub async fn run(args: &[String]) -> Result<(), String> {
proof_credential: None,
static_dir: Some(PathBuf::from(d)),
logout_url: None,
socket: None,
admin_tls: None,
}),
engine: None,
// Branch previews on a name nobody can own (RFC 2606), from loopback test upstreams.
previews: Some(ianitor_control::config::PreviewsConfig {
domain: "preview.dev.test".into(),
tls: "domi".into(),
auth: "none".into(),
upstreams: vec!["127.0.0.1:20000-29999".into(), "10.0.0.0/8".into()],
default_ttl_secs: 72 * 3600,
min_ttl_secs: 60,
max_ttl_secs: 30 * 86_400,
max_previews: 100,
sweep_secs: 10,
}),
};
cfg.check().map_err(|e| e.to_string())?;
Repo::open_seeded(&cfg.git, &cfg.routes.repo, &cfg.state_dir, "main", SITE)
.map_err(|e| e.to_string())?;
let (_, token) = Tokens::new(&cfg.state_dir).create("dev", None)?;
let (_, token) = Tokens::new(&cfg.state_dir).create("dev", None, Default::default())?;
// Control writes edge.json first; then edge can start from it.
let ctl_cfg = cfg.clone();
+33 -39
View File
@@ -39,8 +39,9 @@ use crate::util::{
write_json,
};
/// What a user asked for.
/// What a user asked for. Built once per request; boxing the host body buys nothing.
#[derive(Debug, Clone)]
#[allow(clippy::large_enum_variant)]
pub enum Change {
Put { spec: HostSpec, create: bool },
ShareLinks { hostname: String, on: bool },
@@ -53,6 +54,8 @@ struct Job {
id: String,
change: Change,
base_rev: Option<String>,
/// Replaces the plan's summary (and so the commit message), e.g. for previews.
summary: Option<String>,
}
/// A refusal, before or during an apply.
@@ -141,6 +144,8 @@ pub struct Control {
pub repo: Repo,
pub edge: EdgeLink,
pub tokens: Tokens,
/// Team members and their sessions (sign-in without Authelia).
pub team: Arc<crate::team::Team>,
pub shares: Shares,
pub share_key: Option<ShareKey>,
/// The Domi CA, when `[pki]` is configured.
@@ -245,6 +250,7 @@ impl Control {
let paused: Option<Reason> = read_json(&cfg.state_dir.join("paused.json"))?;
let c = Arc::new(Control {
tokens: Tokens::new(&cfg.state_dir),
team: Arc::new(crate::team::Team::new(&cfg.state_dir)),
shares: Shares::new(&cfg.state_dir, &cfg.edge.share_revocations),
repo,
edge,
@@ -680,41 +686,6 @@ impl Control {
})?;
// The UI proof belongs to the [ui] host only (core already demands forward-auth for it).
let ui_host = self.cfg.ui.as_ref().and_then(|u| u.hostname.as_deref());
// A socket upstream likewise: only the [ui] host, and only control's own UI socket (a
// route file must not point edge at any other socket on the machine).
let ui_socket = self
.cfg
.ui
.as_ref()
.and_then(|u| u.socket.as_deref())
.and_then(|p| p.to_str());
for h in model.hosts() {
for (i, u) in h.upstreams.iter().enumerate() {
let Some(path) = u.unix_path() else { continue };
if ui_host == Some(h.hostname.as_str()) && ui_socket == Some(path) {
continue;
}
let p = messages::params([
("hostname", h.hostname.to_string()),
("url", u.to_string()),
]);
let fe = FieldError {
code: "host.upstream.unix_socket".into(),
message: message("host.upstream.unix_socket", &p),
field: Some(format!("upstreams[{i}]")),
params: p.clone(),
detail: None,
};
return Err(Fail {
status: 422,
reason: reason(
"apply.failed.validation",
messages::params([("first_error", fe.message.clone())]),
),
errors: vec![fe],
});
}
}
for h in model.hosts() {
let proof = h.request_headers.iter().any(|r| {
matches!(r, ianitor_core::HeaderRule::Set { value: ianitor_core::HeaderValue::Secret(s), .. } if s.as_str() == ianitor_core::UI_PROOF_SECRET)
@@ -775,6 +746,18 @@ impl Control {
change: Change,
base_rev: Option<String>,
actor: &str,
) -> Result<ApplyRecord, Fail> {
self.submit_as(change, base_rev, actor, None)
}
/// [`Control::submit`] with a summary of the caller's own (the history line and commit
/// message), e.g. "Opened the preview of fix-42 (shop)".
pub fn submit_as(
&self,
change: Change,
base_rev: Option<String>,
actor: &str,
summary: Option<String>,
) -> Result<ApplyRecord, Fail> {
if let Some(p) = self.paused_for(&change, false) {
return Err(Fail::new(
@@ -784,7 +767,10 @@ impl Control {
));
}
let (head, tree) = self.head_and_tree()?;
let plan = self.plan(&change, &head, &tree, base_rev.as_deref())?;
let mut plan = self.plan(&change, &head, &tree, base_rev.as_deref())?;
if let Some(s) = &summary {
plan.summary = s.clone();
}
self.compile(&plan.model)?;
let id = format!(
"ch_{}",
@@ -827,6 +813,7 @@ impl Control {
id,
change,
base_rev,
summary,
});
}
self.wake.notify_one();
@@ -965,7 +952,14 @@ impl Control {
Ok(x) => x,
Err(f) => return self.finish(&id, "failed", Some(f.reason), f.errors),
};
let plan = match self.plan(&job.change, &head, &tree, job.base_rev.as_deref()) {
let plan = match self
.plan(&job.change, &head, &tree, job.base_rev.as_deref())
.map(|mut p| {
if let Some(s) = &job.summary {
p.summary = s.clone();
}
p
}) {
Ok(p) => p,
Err(f) => return self.finish(&id, "failed", Some(f.reason), f.errors),
};
@@ -1035,7 +1029,7 @@ impl Control {
}
crash::point("committed");
if !self.edge.attached() {
if !self.edge.attached() && self.engine_running() != "caddy" {
// Development without an edge: write the files directly, nothing to watch.
let r = write_atomic(&self.cfg.edge.config, edge_text.as_bytes(), 0o644)
.and_then(|_| write_atomic(&self.cfg.caddy.config, caddy_text.as_bytes(), 0o644));
+7 -13
View File
@@ -42,13 +42,10 @@ struct Rule {
}
impl Control {
/// Caddy's admin socket, from `[compile_caddy]` (or `[compile]`).
pub fn caddy_socket(&self) -> Option<std::path::PathBuf> {
self.cfg
.caddy_compile()
.caddy_admin_socket
.as_ref()
.map(std::path::PathBuf::from)
/// Caddy's admin API, from `[compile_caddy]` (or `[compile]`): its Unix socket, or its
/// loopback TCP address on Windows.
pub fn caddy_socket(&self) -> Option<caddy_link::Admin> {
caddy_link::Admin::from_compile(self.cfg.caddy_compile())
}
/// Load caddy.json (the last good config) into the running Caddy, even when it is the
@@ -56,7 +53,7 @@ impl Control {
pub async fn caddy_reload(&self) -> Result<(), String> {
let sock = self
.caddy_socket()
.ok_or("no caddy_admin_socket is configured, so Caddy cannot be told")?;
.ok_or("no caddy_admin_socket (or loopback caddy_admin) is configured, so Caddy cannot be told")?;
let text = std::fs::read(&self.cfg.caddy.config)
.map_err(|e| format!("cannot read {}: {e}", self.cfg.caddy.config.display()))?;
caddy_link::load(&sock, &text).await?;
@@ -123,10 +120,7 @@ impl Control {
async fn probe_host(hostname: &str, r: &Rule) -> Vec<(String, caddy_link::UpstreamProbe)> {
let mut out = Vec::new();
for u in &r.upstreams {
let host_header = if r.has_check && u.is_unix() {
// As edge: a socket has no authority to name.
"localhost".to_owned()
} else if r.has_check {
let host_header = if r.has_check {
u.authority()
} else {
hostname.to_owned()
@@ -337,7 +331,7 @@ impl Control {
async fn caddy_watch(
&self,
id: &str,
sock: &std::path::Path,
sock: &caddy_link::Admin,
trial: &str,
judged: &[String],
rules: &BTreeMap<String, Rule>,
+13
View File
@@ -38,6 +38,18 @@ pub struct HostSpec {
pub request_headers: Vec<HeaderRuleSpec>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub response_headers: Vec<HeaderRuleSpec>,
/// Set on a branch preview (Fabrica); written by `/api/v1/previews`.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub preview: Option<PreviewSpec>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct PreviewSpec {
pub project: String,
pub branch: String,
/// Unix seconds.
pub expires_at: i64,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, ToSchema)]
@@ -178,6 +190,7 @@ mod tests {
secret: None,
}],
response_headers: vec![],
preview: None,
};
let text = h.to_toml().unwrap();
assert_eq!(HostSpec::from_toml(&text).unwrap(), h);
+11 -79
View File
@@ -18,10 +18,12 @@ pub mod logger;
pub mod messages;
pub mod pki;
pub mod pki_ctl;
pub mod previews;
pub mod records;
pub mod repo;
pub mod shares;
pub mod switch;
pub mod team;
pub mod tokens;
pub mod util;
@@ -37,12 +39,16 @@ pub async fn serve(
) -> Result<(), String> {
cfg.check().map_err(|e| e.to_string())?;
let listen = cfg.listen;
let ui_socket = cfg.ui.as_ref().and_then(|u| u.socket.clone());
let ctl = Control::open(cfg).await?;
tokio::spawn(ctl.clone().worker());
tokio::spawn(ctl.clone().health_poller());
tokio::spawn(ctl.clone().pusher());
tokio::spawn(ctl.clone().pki_poller());
tokio::spawn(ctl.clone().preview_sweeper());
ctl.ensure_admin_host();
if ctl.cfg.ui.is_some() && !ctl.team.has_members() && ctl.ui_proof.is_none() {
log::warn!(target: "ianitor::team", "nobody is in the team yet: run `ianitor-control team setup-link --config <control.toml>` and open the link it prints");
}
let app = api::router(api::AppState::new(ctl.clone()));
if !listen.ip().is_loopback() {
return Err("ianitor-control only listens on loopback".into());
@@ -51,85 +57,11 @@ pub async fn serve(
.await
.map_err(|e| format!("cannot listen on {listen}: {e}"))?;
log::info!(target: "ianitor::control", "API on http://{listen}/api/v1");
// One shutdown for both listeners.
let (stop_tx, stop_rx) = tokio::sync::watch::channel(false);
tokio::spawn(async move {
shutdown.await;
let _ = stop_tx.send(true);
});
let stopped = |mut rx: tokio::sync::watch::Receiver<bool>| async move {
let _ = rx.wait_for(|s| *s).await;
};
let tcp = axum::serve(listener, app.clone()).with_graceful_shutdown(stopped(stop_rx.clone()));
match ui_socket {
None => tcp.await.map_err(|e| e.to_string())?,
Some(path) => {
let ui = ui_listener(&path)?;
log::info!(target: "ianitor::control", "UI API on unix:{}", path.display());
let ui_app = app.layer(axum::Extension(api::ViaUiSocket));
let ui = serve_ui(ui, ui_app, stopped(stop_rx));
let (a, b) = tokio::join!(std::future::IntoFuture::into_future(tcp), ui);
a.map_err(|e| e.to_string())?;
b?;
}
}
drop(ctl);
Ok(())
}
/// Control's UI socket: a stale socket file from an earlier run is replaced; the new one is
/// 0660 (owner and group: edge and Caddy are in the ianitor group). Its directory is the
/// real fence: only the ianitor group may enter it, so no other user can connect or put a
/// socket of their own in its place.
#[cfg(unix)]
fn ui_listener(path: &std::path::Path) -> Result<tokio::net::UnixListener, String> {
use std::os::unix::fs::{FileTypeExt, PermissionsExt};
if let Ok(m) = std::fs::symlink_metadata(path) {
if !m.file_type().is_socket() {
return Err(format!(
"{} exists and is not a socket; not replacing it",
path.display()
));
}
std::fs::remove_file(path).map_err(|e| format!("cannot remove {}: {e}", path.display()))?;
}
let l = tokio::net::UnixListener::bind(path)
.map_err(|e| format!("cannot listen on {}: {e}", path.display()))?;
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o660))
.map_err(|e| format!("cannot set the mode of {}: {e}", path.display()))?;
Ok(l)
}
#[cfg(unix)]
async fn serve_ui(
l: tokio::net::UnixListener,
app: axum::Router,
stop: impl std::future::Future<Output = ()> + Send + 'static,
) -> Result<(), String> {
axum::serve(l, app)
.with_graceful_shutdown(stop)
axum::serve(listener, app)
.with_graceful_shutdown(shutdown)
.await
.map_err(|e| e.to_string())
}
#[cfg(not(unix))]
struct NoUnixListener;
#[cfg(not(unix))]
fn ui_listener(path: &std::path::Path) -> Result<NoUnixListener, String> {
Err(format!(
"ui.socket {}: a Unix socket needs a Unix system",
path.display()
))
}
#[cfg(not(unix))]
async fn serve_ui(
_l: NoUnixListener,
_app: axum::Router,
_stop: impl std::future::Future<Output = ()> + Send + 'static,
) -> Result<(), String> {
.map_err(|e| e.to_string())?;
drop(ctl);
Ok(())
}
+40 -7
View File
@@ -12,6 +12,8 @@ use log::{Level, LevelFilter, Log, Metadata, Record};
struct Stderr {
own: LevelFilter,
/// `$IANITOR_LOG_FILE` or `--log-file`: append here instead of stderr (Windows services).
file: Option<std::sync::Mutex<std::fs::File>>,
}
impl Log for Stderr {
@@ -33,12 +35,27 @@ impl Log for Stderr {
Level::Debug => "DEBUG",
Level::Trace => "TRACE",
};
let _ = writeln!(
std::io::stderr().lock(),
"{lvl} {}: {}",
r.target(),
r.args()
);
match &self.file {
Some(f) => {
if let Ok(mut f) = f.lock() {
let _ = writeln!(
f,
"{} {lvl} {}: {}",
crate::util::rfc3339(crate::util::now()),
r.target(),
r.args()
);
}
}
None => {
let _ = writeln!(
std::io::stderr().lock(),
"{lvl} {}: {}",
r.target(),
r.args()
);
}
}
}
}
@@ -48,6 +65,22 @@ impl Log for Stderr {
}
pub fn init(level: Option<&str>) {
init_to(
level,
std::env::var_os("IANITOR_LOG_FILE").map(std::path::PathBuf::from),
);
}
/// Like [`init`], appending to `file` when given.
pub fn init_to(level: Option<&str>, file: Option<std::path::PathBuf>) {
let file = file.and_then(|p| {
std::fs::OpenOptions::new()
.create(true)
.append(true)
.open(p)
.ok()
.map(std::sync::Mutex::new)
});
let own = match level.map(str::to_ascii_lowercase).as_deref() {
Some("error") => LevelFilter::Error,
Some("warn") => LevelFilter::Warn,
@@ -55,7 +88,7 @@ pub fn init(level: Option<&str>) {
Some("trace") => LevelFilter::Trace,
_ => LevelFilter::Info,
};
if log::set_boxed_logger(Box::new(Stderr { own })).is_ok() {
if log::set_boxed_logger(Box::new(Stderr { own, file })).is_ok() {
log::set_max_level(own);
}
}
+76 -5
View File
@@ -5,7 +5,7 @@
//! ```text
//! ianitor-control --config <control.toml> run the control plane
//! ianitor-control --dev [--edge-bin <ianitor-edge>] temporary everything on 127.0.0.1
//! ianitor-control token create --name <name> [--expires-days <n> | --never] (--config <c> | --state-dir <d>)
//! ianitor-control token create --name <name> [--scope full|previews] [--expires-days <n> | --never] (--config <c> | --state-dir <d>)
//! ianitor-control token list (--config <c> | --state-dir <d>)
//! ianitor-control token revoke <id> (--config <c> | --state-dir <d>)
//! ianitor-control openapi print the OpenAPI document
@@ -15,6 +15,8 @@
//! ianitor-control ca init --out <dir> [--passphrase-file <f>] the offline root (never on the server)
//! ianitor-control ca sign --root <dir> --csr <f> --out <f> [--yes] sign an intermediate offline
//! ianitor-control check --config <control.toml> check the config and exit
//! ianitor-control team setup-link|list --config <c> the first admin's sign-in link
//! ianitor-control service control|caddy-guard --config <c> [--log-file <f>] Windows service
//! ```
//! The log level comes from `$IANITOR_LOG`. As `GIT_ASKPASS` (with `$IANITOR_ASKPASS=1`),
//! the binary answers git's prompt from the push credential file.
@@ -25,6 +27,8 @@ use std::process::ExitCode;
use ianitor_control::{Config, logger, tokens::Tokens};
mod dev;
#[cfg(windows)]
mod winsvc;
fn usage() -> ExitCode {
eprintln!(
@@ -139,12 +143,19 @@ fn token(args: &[String]) -> Result<(), String> {
match args.first().map(String::as_str) {
Some("create") => {
let mut name = None;
let mut scope = ianitor_control::tokens::Scope::Full;
let mut expires = Some(ianitor_control::util::now() + 365 * 86_400);
let mut it = args.iter().skip(1);
while let Some(a) = it.next() {
match a.as_str() {
"--name" => name = it.next().cloned(),
"--never" => expires = None,
"--scope" => {
scope = it
.next()
.and_then(|s| ianitor_control::tokens::Scope::parse(s))
.ok_or("--scope must be full or previews")?;
}
"--expires-days" => {
let d: u64 = it
.next()
@@ -157,7 +168,7 @@ fn token(args: &[String]) -> Result<(), String> {
}
}
let name = name.ok_or("--name <name> is required")?;
let (rec, value) = tokens.create(&name, expires).map_err(|e| {
let (rec, value) = tokens.create(&name, expires, scope).map_err(|e| {
if e == "token.name" {
"the name must be 1 to 64 letters, digits, spaces, dots, dashes or underscores"
.to_owned()
@@ -166,8 +177,10 @@ fn token(args: &[String]) -> Result<(), String> {
}
})?;
eprintln!(
"Token {} ({}) created. It is shown once; save it in Custos now:",
rec.id, rec.name
"Token {} ({}, scope {}) created. It is shown once; save it in Custos now:",
rec.id,
rec.name,
rec.scope.as_str()
);
println!("{value}");
Ok(())
@@ -186,6 +199,9 @@ fn token(args: &[String]) -> Result<(), String> {
.map(|e| format!(" REVOKED {}", ianitor_control::util::rfc3339(e)))
.unwrap_or_default()
);
if t.scope != ianitor_control::tokens::Scope::Full {
println!(" scope {}", t.scope.as_str());
}
}
Ok(())
}
@@ -371,12 +387,66 @@ fn pki_cli(args: &[String]) -> Result<(), String> {
}
}
/// `team setup-link | list` on the server, as the user control runs as.
fn team_cli(args: &[String]) -> Result<(), String> {
let path = arg_after(args, "--config").ok_or("team setup-link|list --config <control.toml>")?;
let cfg = Config::load(&PathBuf::from(path)).map_err(|e| e.to_string())?;
same_owner(&cfg.state_dir)?;
let team = ianitor_control::team::Team::new(&cfg.state_dir);
match args.first().map(String::as_str) {
Some("setup-link") => {
let (code, until) = team.setup_code()?;
let base = match cfg.ui.as_ref().and_then(|u| u.hostname.as_ref()) {
Some(h) => format!("https://{h}/"),
None => format!("http://{}/", cfg.listen),
};
eprintln!(
"Open this link to sign in as the team's first admin. It works once, until {}:",
ianitor_control::util::rfc3339(until)
);
println!("{base}#signin={code}");
Ok(())
}
Some("list") => {
for m in team.members()? {
println!("{} {} {}", m.id, m.role.as_str(), m.name);
}
Ok(())
}
_ => Err("team setup-link|list --config <control.toml>".into()),
}
}
fn main() -> ExitCode {
if std::env::var("IANITOR_ASKPASS").as_deref() == Ok("1") {
return askpass();
}
logger::init(std::env::var("IANITOR_LOG").ok().as_deref());
let args: Vec<String> = std::env::args().skip(1).collect();
let log_file = args
.iter()
.position(|a| a == "--log-file")
.and_then(|i| args.get(i + 1))
.map(PathBuf::from);
match log_file {
Some(f) => logger::init_to(std::env::var("IANITOR_LOG").ok().as_deref(), Some(f)),
None => logger::init(std::env::var("IANITOR_LOG").ok().as_deref()),
}
// Windows Server, Caddy mode: started by the service control manager.
if args.first().map(String::as_str) == Some("service") {
#[cfg(windows)]
return match winsvc::run(&args[1..]) {
Ok(()) => ExitCode::SUCCESS,
Err(e) => {
eprintln!("ianitor-control: {e}");
ExitCode::FAILURE
}
};
#[cfg(not(windows))]
{
eprintln!("ianitor-control: `service` is for Windows; use the systemd units on Linux");
return ExitCode::FAILURE;
}
}
let rt = match tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
@@ -390,6 +460,7 @@ fn main() -> ExitCode {
let result = match args.first().map(String::as_str) {
Some("token") => token(&args[1..]),
Some("pki") => pki_cli(&args[1..]),
Some("team") => team_cli(&args[1..]),
Some("ca") => ca(&args[1..]),
Some("openapi") => {
println!("{}", ianitor_control::api::openapi_json());
+37 -6
View File
@@ -37,12 +37,6 @@ fn template(code: &str) -> &'static str {
}
"host.upstream.not_url" => "Write it as a full address, like http://10.0.0.23:3000.",
"host.upstream.scheme" => "Start the address with http:// or https://.",
"host.upstream.unix_path" => {
"Write a socket as unix:/absolute/path.sock, with letters, digits, dots, dashes and underscores only."
}
"host.upstream.unix_socket" => {
"Only the web UI's admin host can use a socket, and only control's own ([ui] socket in control.toml)."
}
"host.upstream.no_host" => "Add the server's name or IP address after http://.",
"host.upstream.host_name" => {
"The server name is not usable. Use letters a–z, digits, dots and dashes, or an IP address."
@@ -211,6 +205,43 @@ fn template(code: &str) -> &'static str {
"token.not_found" => "There is no API token with that id.",
"token.name" => "Use 1 to 64 letters, digits, spaces, dots, dashes or underscores.",
"token.expiry" => "Choose between 1 and 3650 days, or never.",
"token.scope" => {
"This API token may only open and close branch previews (/api/v1/previews)."
}
"token.scope_value" => "A token's scope is full or previews.",
"session.code" => {
"This sign-in link does not work: it was used, it expired, or it was mistyped. Ask an admin for a new one."
}
"session.unknown" => {
"You are signed out. Open your sign-in link again, or ask an admin for one."
}
"team.admin_only" => "Only an admin of this team can do that.",
"team.last_admin" => "The team needs at least one admin. Make someone else an admin first.",
"team.full" => "The team is full (64 people, 100 open invites).",
"team.name" => "Enter a name of 1 to 64 characters.",
"team.role" => "A role is admin or member.",
"team.root" => "That is not a Tessera root. Copy it from Custos, Domi identity.",
"team.not_found" => "There is no such member or invite.",
"team.session_only" => "Only a signed-in person can do that, not an API token.",
"preview.off" => {
"Previews are off on this server: set a preview domain under [previews] in control.toml."
}
"preview.taken" => {
"{hostname} is already used by another host or branch, so this branch's preview cannot have it."
}
"preview.not_found" => "There is no preview at that address.",
"preview.branch" => "The branch name {problem}.",
"preview.project" => "The project name {problem}.",
"preview.domain" => "The preview address is not usable: {problem}.",
"preview.ttl" => "Choose a lifetime between {min} and {max} seconds.",
"preview.upstream" => {
"Write the preview's address as http://host:port or https://host:port, without a path, user or password."
}
"preview.upstream_not_allowed" => {
"{upstream} is not an address previews may use. Allowed: {allowed}."
}
"preview.too_many" => "There are already {max} previews. Close some first.",
"preview.expired" => "Preview of {branch} expired",
"rate.limited" => "Too many requests in a short time. Try again in {seconds} s.",
"control.files_unwritten" => {
"The change is live, but Ianitor could not save the proxy settings to disk. Changes are paused until Ianitor restarts and saves them."
+598
View File
@@ -0,0 +1,598 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Branch previews for Fabrica (Fabrica docs/32_coherence.md, T4). A preview is an ordinary
//! host file in the routes repository with a `[preview]` table, so it goes through the same
//! validation, compilers, differential tests and commit-confirmed apply as any host. This
//! module holds what is preview-only: the host body control writes, the upstream allow list
//! (a preview token is hostile: it must not be able to publish this machine's admin ports),
//! and the sweeper that closes expired previews.
// A refusal is built once per failed request; boxing it buys nothing (as in `engine`).
#![allow(clippy::result_large_err)]
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::sync::Arc;
use std::time::Duration;
use crate::config::{Config, PreviewsConfig};
use crate::engine::{Change, Control, Fail};
use crate::hostspec::{HeaderRuleSpec, HostSpec, PreviewSpec};
use crate::messages::{self, Params};
use crate::util::now;
/// The actor name the sweeper's removals carry in the history.
pub const EXPIRY_ACTOR: &str = "Preview expiry";
/// One entry of `[previews] upstreams`.
#[derive(Debug, Clone, PartialEq, Eq)]
enum Target {
Net(IpAddr, u8),
Name(String),
/// `*.suffix`: any name ending in `.suffix`.
Suffix(String),
}
#[derive(Debug, Clone, PartialEq, Eq)]
struct Allowed {
target: Target,
ports: Option<(u16, u16)>,
}
fn parse_ports(p: &str) -> Option<(u16, u16)> {
let (lo, hi) = match p.split_once('-') {
Some((a, b)) => (a.parse().ok()?, b.parse().ok()?),
None => {
let x: u16 = p.parse().ok()?;
(x, x)
}
};
(lo >= 1 && lo <= hi).then_some((lo, hi))
}
fn parse_entry(e: &str) -> Option<Allowed> {
let e = e.trim();
// IPv6 networks carry no port (`fd00::/8`); everything else may end in `:port[-port]`.
if e.matches(':').count() > 1 {
let (ip, bits) = e.split_once('/').unwrap_or((e, "128"));
let ip: Ipv6Addr = ip.parse().ok()?;
let bits: u8 = bits.parse().ok().filter(|b| *b <= 128)?;
return Some(Allowed {
target: Target::Net(IpAddr::V6(ip), bits),
ports: None,
});
}
let (host, ports) = match e.rsplit_once(':') {
Some((h, p)) => (h, Some(parse_ports(p)?)),
None => (e, None),
};
if let Some((ip, bits)) = host.split_once('/') {
let ip: Ipv4Addr = ip.parse().ok()?;
let bits: u8 = bits.parse().ok().filter(|b| *b <= 32)?;
return Some(Allowed {
target: Target::Net(IpAddr::V4(ip), bits),
ports,
});
}
if let Ok(ip) = host.parse::<Ipv4Addr>() {
return Some(Allowed {
target: Target::Net(IpAddr::V4(ip), 32),
ports,
});
}
let name = host.to_ascii_lowercase();
let plain = |n: &str| {
!n.is_empty()
&& n.len() <= 253
&& n.split('.').all(|l| {
!l.is_empty()
&& l.len() <= 63
&& l.bytes()
.all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == b'-')
})
};
if let Some(suffix) = name.strip_prefix("*.") {
return plain(suffix).then(|| Allowed {
target: Target::Suffix(suffix.to_owned()),
ports,
});
}
if !plain(&name) {
return None;
}
Some(Allowed {
target: Target::Name(name),
ports,
})
}
fn in_net(ip: IpAddr, net: IpAddr, bits: u8) -> bool {
match (ip, net) {
(IpAddr::V4(a), IpAddr::V4(n)) => {
let mask = if bits == 0 {
0
} else {
u32::MAX << (32 - u32::from(bits))
};
u32::from(a) & mask == u32::from(n) & mask
}
(IpAddr::V6(a), IpAddr::V6(n)) => {
let mask = if bits == 0 {
0
} else {
u128::MAX << (128 - u32::from(bits))
};
u128::from(a) & mask == u128::from(n) & mask
}
_ => false,
}
}
/// Addresses no preview may ever use, whatever the allow list says.
fn never(ip: IpAddr) -> bool {
match ip {
IpAddr::V4(v) => {
v.is_unspecified() || v.is_link_local() || v.is_multicast() || v.is_broadcast()
}
IpAddr::V6(v) => {
v.is_unspecified()
|| v.is_multicast()
|| (v.segments()[0] & 0xffc0) == 0xfe80
|| v.to_ipv4_mapped().is_some()
}
}
}
/// Check the `[previews]` section at start.
pub fn check_config(p: &PreviewsConfig, cfg: &Config) -> Result<(), String> {
ianitor_core::preview::hostname("p", "main", &p.domain)
.map_err(|e| format!("previews.domain: {e}"))?;
if !["domi", "letsencrypt"].contains(&p.tls.as_str()) {
return Err("previews.tls must be domi or letsencrypt".into());
}
if !["none", "forward-auth"].contains(&p.auth.as_str()) {
return Err("previews.auth must be none or forward-auth".into());
}
for u in &p.upstreams {
if parse_entry(u).is_none() {
return Err(format!(
"previews.upstreams: {u:?} is not a network (10.0.0.0/8), an address with ports (127.0.0.1:20000-29999) or a name (app.internal, *.svc.internal)"
));
}
}
if p.min_ttl_secs == 0
|| p.min_ttl_secs > p.max_ttl_secs
|| !(p.min_ttl_secs..=p.max_ttl_secs).contains(&p.default_ttl_secs)
{
return Err(
"previews: min_ttl_secs ≤ default_ttl_secs ≤ max_ttl_secs, and min_ttl_secs > 0".into(),
);
}
if !(1..=3600).contains(&p.sweep_secs) || !(1..=10_000).contains(&p.max_previews) {
return Err("previews: sweep_secs 1 to 3600, max_previews 1 to 10000".into());
}
let _ = cfg;
Ok(())
}
fn fail(status: u16, code: &str, params: Params) -> Fail {
Fail::new(status, code, params)
}
/// Whether a preview may send traffic to `upstream`; the parsed URL's host and port.
pub fn check_upstream(cfg: &Config, p: &PreviewsConfig, upstream: &str) -> Result<(), Fail> {
let bad = || fail(422, "preview.upstream", Params::new());
if upstream.is_empty()
|| upstream.len() > 512
|| !upstream.bytes().all(|c| c.is_ascii_graphic())
{
return Err(bad());
}
let u = url::Url::parse(upstream).map_err(|_| bad())?;
if !["http", "https"].contains(&u.scheme())
|| !u.username().is_empty()
|| u.password().is_some()
|| u.query().is_some()
|| u.fragment().is_some()
|| !(u.path().is_empty() || u.path() == "/")
{
return Err(bad());
}
let port = u.port_or_known_default().ok_or_else(bad)?;
let host = u.host().ok_or_else(bad)?;
let shown = || {
messages::params([
("upstream", upstream.to_owned()),
("allowed", {
if p.upstreams.is_empty() {
"nothing yet (set [previews] upstreams)".to_owned()
} else {
p.upstreams.join(", ")
}
}),
])
};
let not_allowed = || fail(403, "preview.upstream_not_allowed", shown());
let ip = match &host {
url::Host::Ipv4(v) => Some(IpAddr::V4(*v)),
url::Host::Ipv6(v) => Some(IpAddr::V6(*v)),
url::Host::Domain(_) => None,
};
if let Some(ip) = ip {
if never(ip) {
return Err(not_allowed());
}
// This machine's own control API and Caddy admin API, whatever the list says.
if ip.is_loopback() {
let admin_ports = std::iter::once(cfg.listen.port()).chain(
[cfg.compile.caddy_admin, cfg.caddy_compile().caddy_admin]
.into_iter()
.flatten()
.map(|a| a.port()),
);
if admin_ports.into_iter().any(|a| a == port) || port == 2019 {
return Err(not_allowed());
}
}
}
let name = match &host {
url::Host::Domain(d) => Some(d.to_ascii_lowercase()),
_ => None,
};
let ok = p.upstreams.iter().filter_map(|e| parse_entry(e)).any(|a| {
let port_ok = a.ports.is_none_or(|(lo, hi)| (lo..=hi).contains(&port));
let host_ok = match (&a.target, ip, &name) {
(Target::Net(net, bits), Some(ip), _) => in_net(ip, *net, *bits),
(Target::Name(n), _, Some(h)) => n == h,
(Target::Suffix(s), _, Some(h)) => h.ends_with(&format!(".{s}")),
_ => false,
};
port_ok && host_ok
});
if ok { Ok(()) } else { Err(not_allowed()) }
}
/// The host body of a branch's preview.
pub fn spec(
p: &PreviewsConfig,
hostname: &str,
project: &str,
branch: &str,
upstream: &str,
expires_at: u64,
) -> HostSpec {
HostSpec {
hostname: hostname.to_owned(),
upstreams: vec![upstream.trim_end_matches('/').to_owned()],
tls: p.tls.clone(),
auth: p.auth.clone(),
websockets: true,
share_links: false,
device_certs: false,
access_log: "off".into(),
health_check: None,
request_headers: Vec::new(),
// A preview is not for search engines.
response_headers: vec![HeaderRuleSpec {
action: "set".into(),
name: "X-Robots-Tag".into(),
value: Some("noindex, nofollow".into()),
secret: None,
}],
preview: Some(PreviewSpec {
project: project.to_owned(),
branch: branch.to_owned(),
expires_at: i64::try_from(expires_at).unwrap_or(i64::MAX),
}),
}
}
/// A preview's field problem as an API refusal.
pub fn name_fail(e: ianitor_core::preview::PreviewError) -> Fail {
use ianitor_core::preview::PreviewError as P;
let (code, problem) = match &e {
P::Branch(r) => ("preview.branch", (*r).to_owned()),
P::Project(r) => ("preview.project", (*r).to_owned()),
P::Domain(r) => ("preview.domain", r.clone()),
};
let mut f = fail(422, code, messages::params([("problem", problem)]));
f.reason.field = Some(
match e {
P::Branch(_) => "branch",
P::Project(_) => "project",
P::Domain(_) => "domain",
}
.into(),
);
f
}
/// What the previews screen and Fabrica see.
#[derive(Debug, Clone)]
pub struct Listed {
pub hostname: String,
pub project: String,
pub branch: String,
pub upstream: String,
pub expires_at: u64,
}
impl Control {
/// With `[ui] hostname` and `admin_tls`: make sure the admin host (the web UI and this
/// API, through the engine) is in the routes repository; queue it at start if not.
pub fn ensure_admin_host(&self) {
let Some(ui) = &self.cfg.ui else { return };
let (Some(host), Some(tls)) = (&ui.hostname, &ui.admin_tls) else {
return;
};
let Ok((_, tree, _)) = self.head_model() else {
return;
};
if tree.host(host).is_some() {
return;
}
let spec = HostSpec {
hostname: host.clone(),
upstreams: vec![format!("http://{}", self.cfg.listen)],
tls: tls.clone(),
auth: "none".into(),
websockets: false,
share_links: false,
device_certs: false,
access_log: "off".into(),
// No health path: every API path needs a sign-in, so a probe would see 401 and
// the apply would be reverted. Any answer from control counts as up.
health_check: None,
request_headers: Vec::new(),
response_headers: vec![
HeaderRuleSpec {
action: "set".into(),
name: "X-Robots-Tag".into(),
value: Some("noindex, nofollow".into()),
secret: None,
},
HeaderRuleSpec {
action: "set".into(),
name: "Strict-Transport-Security".into(),
value: Some("max-age=31536000".into()),
secret: None,
},
],
preview: None,
};
match self.submit_as(
Change::Put { spec, create: true },
None,
"Setup",
Some(format!("Added the admin host {host} (the web UI)")),
) {
Ok(_) => log::info!(target: "ianitor::control", "adding the admin host {host}"),
Err(f) => {
log::error!(target: "ianitor::control", "cannot add the admin host {host}: {}", f.reason.message)
}
}
}
pub fn previews_cfg(&self) -> Result<&PreviewsConfig, Fail> {
self.cfg
.previews
.as_ref()
.ok_or_else(|| fail(409, "preview.off", Params::new()))
}
/// Every preview at the branch head, by host name.
pub fn previews(&self) -> Result<Vec<Listed>, Fail> {
let (_, _, model) = self.head_model()?;
Ok(model
.hosts()
.iter()
.filter_map(|h| {
let p = h.preview.as_ref()?;
Some(Listed {
hostname: h.hostname.to_string(),
project: p.project.clone(),
branch: p.branch.clone(),
upstream: h
.upstreams
.first()
.map(ToString::to_string)
.unwrap_or_default(),
expires_at: p.expires_at,
})
})
.collect())
}
/// Open (or move) a branch's preview.
pub fn open_preview(
&self,
project: &str,
branch: &str,
upstream: &str,
ttl: Option<u64>,
actor: &str,
) -> Result<(String, u64, crate::records::ApplyRecord), Fail> {
let p = self.previews_cfg()?;
let hostname =
ianitor_core::preview::hostname(project, branch, &p.domain).map_err(name_fail)?;
let ttl = ttl.unwrap_or(p.default_ttl_secs);
if !(p.min_ttl_secs..=p.max_ttl_secs).contains(&ttl) {
let mut f = fail(
422,
"preview.ttl",
messages::params([
("min", p.min_ttl_secs.to_string()),
("max", p.max_ttl_secs.to_string()),
]),
);
f.reason.field = Some("ttl".into());
return Err(f);
}
check_upstream(&self.cfg, p, upstream)?;
let previews = self.previews()?;
let (_, tree, model) = self.head_model()?;
let existing = model
.hosts()
.iter()
.find(|h| h.hostname.as_str() == hostname);
let create = match existing {
None => {
if previews.len() >= p.max_previews {
return Err(fail(
409,
"preview.too_many",
messages::params([("max", p.max_previews.to_string())]),
));
}
true
}
Some(h) => match &h.preview {
Some(pv) if pv.project == project && pv.branch == branch => false,
_ => {
return Err(fail(
409,
"preview.taken",
messages::params([("hostname", hostname.clone())]),
));
}
},
};
drop(tree);
let expires_at = now().saturating_add(ttl);
let spec = spec(p, &hostname, project, branch, upstream, expires_at);
let summary = format!(
"{} the preview of {branch} ({project})",
if create { "Opened" } else { "Moved" }
);
let rec = self.submit_as(Change::Put { spec, create }, None, actor, Some(summary))?;
Ok((hostname, expires_at, rec))
}
/// Close a preview by its host name. Only preview hosts.
pub fn close_preview(
&self,
hostname: &str,
actor: &str,
why: &str,
) -> Result<crate::records::ApplyRecord, Fail> {
self.previews_cfg()?;
let pv = self
.previews()?
.into_iter()
.find(|p| p.hostname == hostname)
.ok_or_else(|| fail(404, "preview.not_found", Params::new()))?;
let summary = format!("{why} preview of {} ({})", pv.branch, pv.project);
self.submit_as(
Change::Delete {
hostname: hostname.to_owned(),
},
None,
actor,
Some(summary),
)
}
/// Where a preview stands: `applying`, `live`, `failed` (with why), or not a preview.
pub fn preview_state(&self, hostname: &str) -> Option<(String, Option<String>)> {
let live = self.previews().ok()?.iter().any(|p| p.hostname == hostname);
let last = self
.records()
.into_iter()
.rev()
.find(|r| r.hosts.iter().any(|h| h == hostname));
let pending = last
.as_ref()
.is_some_and(|r| !["kept", "reverted", "failed"].contains(&r.state.as_str()));
if pending {
return Some(("applying".into(), None));
}
if live {
return Some(("live".into(), None));
}
let r = last?;
// A preview that never went live because its apply failed.
(r.summary.contains("the preview of") && r.state != "kept").then(|| {
(
"failed".into(),
r.reason.as_ref().map(|x| x.message.clone()),
)
})
}
/// Close expired previews, every `sweep_secs`.
pub async fn preview_sweeper(self: Arc<Self>) {
let Some(p) = self.cfg.previews.clone() else {
return;
};
loop {
tokio::time::sleep(Duration::from_secs(p.sweep_secs)).await;
let Ok(list) = self.previews() else {
continue;
};
let t = now();
let busy: Vec<String> = self
.records()
.into_iter()
.filter(|r| !["kept", "reverted", "failed"].contains(&r.state.as_str()))
.flat_map(|r| r.hosts)
.collect();
for pv in list.iter().filter(|p| p.expires_at <= t) {
if busy.contains(&pv.hostname) {
continue;
}
match self.close_preview(&pv.hostname, EXPIRY_ACTOR, "Closed the expired") {
Ok(_) => {
log::info!(target: "ianitor::previews", "the preview {} expired; closing it", pv.hostname)
}
Err(f) => {
log::warn!(target: "ianitor::previews", "cannot close the expired preview {}: {}", pv.hostname, f.reason.message)
}
}
}
}
}
}
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
use super::*;
#[test]
fn allow_list_entries_parse() {
for ok in [
"10.0.0.0/8",
"127.0.0.1:20000-29999",
"192.168.1.5:8080",
"app.internal",
"app.internal:3000",
"*.svc.internal",
"fd00::/8",
] {
assert!(parse_entry(ok).is_some(), "{ok}");
}
for bad in [
"",
"10.0.0.0/33",
"a b",
"x:0",
"x:9-1",
"*.",
"http://x",
"1.2.3.4/8:70000",
] {
assert!(parse_entry(bad).is_none(), "{bad}");
}
}
#[test]
fn networks_match() {
let n = |s: &str| s.parse::<IpAddr>().unwrap();
assert!(in_net(n("10.1.2.3"), n("10.0.0.0"), 8));
assert!(!in_net(n("11.1.2.3"), n("10.0.0.0"), 8));
assert!(in_net(n("fd12::1"), n("fd00::"), 8));
assert!(in_net(n("1.2.3.4"), n("0.0.0.0"), 0));
assert!(never(n("0.0.0.0")) && never(n("169.254.169.254")) && never(n("::ffff:127.0.0.1")));
}
}
+470
View File
@@ -0,0 +1,470 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Team sign-in without Authelia (T4: Ianitor on any server, for a small team). Authelia stays
//! an option (`[ui] proof_credential`, docs/api.md "Sign-in"); this is the default elsewhere.
//!
//! - **The founding admin** signs in with a one-time **setup link** (`#signin=isc_…`): made at
//! the first start of a server with no member, printed by the installer
//! (`ianitor-control team setup-link`), valid 7 days, one use.
//! - **Teammates** get an **invite link** from an admin (Settings → Team → Invite), for a role:
//! `admin` (everything) or `member` (hosts, previews, history; not tokens, the team, the
//! engine or the CA). One use, 7 days.
//! - Redeeming a link makes a **session**: `ise_` + 32 random bytes in an `HttpOnly`,
//! `Secure`, `SameSite=Strict`, `__Host-` cookie, 30 days, no sliding. Control stores only
//! SHA-256 of codes and sessions (in `team.json`, 0600), so a copy of the state directory
//! signs no one in. Signing out ends the session; removing a member ends all of theirs.
//! - A member may record their **Tessera root** (the Domi identity's public key, as Custos
//! shows it) so the team list shows its match code. Signing in *with* the Tessera key (a
//! browser Domi key) and Custos approval of admin changes need operations Custos does not
//! have yet (docs/custos-ticket.md, T4 part); until then admin changes need the admin role.
use std::path::{Path, PathBuf};
use base64::Engine as _;
use base64::engine::general_purpose::URL_SAFE_NO_PAD;
use serde::{Deserialize, Serialize};
use crate::util::{ct_eq, hex, now, random, read_json, sha256_hex, write_json};
pub const COOKIE: &str = "__Host-ianitor";
pub const SESSION_SECS: u64 = 30 * 86_400;
pub const CODE_SECS: u64 = 7 * 86_400;
const MAX_MEMBERS: usize = 64;
const MAX_SESSIONS: usize = 400;
const MAX_CODES: usize = 100;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum Role {
Admin,
Member,
}
impl Role {
pub fn as_str(self) -> &'static str {
match self {
Role::Admin => "admin",
Role::Member => "member",
}
}
pub fn parse(s: &str) -> Option<Role> {
match s {
"admin" => Some(Role::Admin),
"member" => Some(Role::Member),
_ => None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Member {
pub id: String,
pub name: String,
pub role: Role,
/// The member's Tessera root public key (base64url, 32 bytes), when they gave it.
#[serde(default)]
pub tessera_root: Option<String>,
pub added_at: u64,
pub added_by: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Session {
pub id: String,
pub sha256: String,
pub member: String,
/// What the browser was called at sign-in (`Laptop`, `Phone`).
pub device: String,
pub created_at: u64,
pub expires_at: u64,
pub last_used_at: Option<u64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct Code {
pub id: String,
pub sha256: String,
/// `setup` (the founding admin) or `invite`.
pub kind: String,
pub role: Role,
/// The invitee's name, as the admin typed it.
pub name: Option<String>,
pub expires_at: u64,
pub created_by: String,
}
#[derive(Debug, Default, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
struct TeamFile {
members: Vec<Member>,
sessions: Vec<Session>,
codes: Vec<Code>,
}
/// Why a sign-in or a team change was refused (an API error code).
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Refused(pub &'static str);
pub struct Team {
path: PathBuf,
lock: std::sync::Mutex<()>,
}
struct Guard<'a> {
_m: std::sync::MutexGuard<'a, ()>,
_f: std::fs::File,
}
pub fn valid_name(n: &str) -> bool {
let n = n.trim();
!n.is_empty() && n.chars().count() <= 64 && !n.chars().any(char::is_control)
}
/// A Tessera root as Custos shows it: base64url of 32 bytes.
pub fn valid_root(r: &str) -> bool {
URL_SAFE_NO_PAD
.decode(r.trim())
.is_ok_and(|b| b.len() == 32)
}
/// The 6-digit match code of a Tessera key, exactly as Fundamentum's `tessera::match_code`
/// (docs/TESSERA.md §5): SHA-256 of `"tessera match v1"` and the key, first 4 bytes
/// big-endian, mod 10^6; shown as `474 719`.
pub fn match_code(root: &str) -> Option<String> {
let b = URL_SAFE_NO_PAD.decode(root.trim()).ok()?;
let mut ctx = ring::digest::Context::new(&ring::digest::SHA256);
ctx.update(b"tessera match v1");
ctx.update(&b);
let d = ctx.finish();
let n = u32::from_be_bytes([d.as_ref()[0], d.as_ref()[1], d.as_ref()[2], d.as_ref()[3]]);
let c = n % 1_000_000;
Some(format!("{:03} {:03}", c / 1000, c % 1000))
}
fn secret(prefix: &str) -> Result<String, String> {
Ok(format!(
"{prefix}_{}",
URL_SAFE_NO_PAD.encode(random::<32>().map_err(|e| e.to_string())?)
))
}
fn new_id() -> Result<String, String> {
Ok(hex(&random::<8>().map_err(|e| e.to_string())?))
}
impl Team {
pub fn new(state_dir: &Path) -> Team {
Team {
path: state_dir.join("team.json"),
lock: std::sync::Mutex::new(()),
}
}
fn guard(&self) -> Result<Guard<'_>, String> {
let m = self
.lock
.lock()
.map_err(|_| "team store unavailable".to_owned())?;
let path = self.path.with_file_name("team.lock");
if let Some(d) = path.parent() {
std::fs::create_dir_all(d)
.map_err(|e| format!("cannot create {}: {e}", d.display()))?;
}
let f = std::fs::OpenOptions::new()
.create(true)
.truncate(false)
.write(true)
.open(&path)
.map_err(|e| format!("cannot open {}: {e}", path.display()))?;
f.lock()
.map_err(|e| format!("cannot lock {}: {e}", path.display()))?;
Ok(Guard { _m: m, _f: f })
}
fn load(&self) -> Result<TeamFile, String> {
let mut f: TeamFile = read_json(&self.path)?.unwrap_or_default();
let t = now();
f.sessions.retain(|s| s.expires_at > t);
f.codes.retain(|c| c.expires_at > t);
Ok(f)
}
fn save(&self, f: &TeamFile) -> Result<(), String> {
write_json(&self.path, f)
}
pub fn members(&self) -> Result<Vec<Member>, String> {
let _g = self.guard()?;
Ok(self.load()?.members)
}
/// Open invites (never their values).
pub fn codes(&self) -> Result<Vec<Code>, String> {
let _g = self.guard()?;
Ok(self.load()?.codes)
}
pub fn has_members(&self) -> bool {
self.members().is_ok_and(|m| !m.is_empty())
}
/// A new setup code for the founding admin, while the team has no member. Older setup
/// codes stop working.
pub fn setup_code(&self) -> Result<(String, u64), String> {
let _g = self.guard()?;
let mut f = self.load()?;
if !f.members.is_empty() {
return Err(
"the team already has members; an admin invites people from Settings → Team".into(),
);
}
f.codes.retain(|c| c.kind != "setup");
let value = secret("isc")?;
let expires_at = now() + CODE_SECS;
f.codes.push(Code {
id: new_id()?,
sha256: sha256_hex(value.as_bytes()),
kind: "setup".into(),
role: Role::Admin,
name: None,
expires_at,
created_by: "setup".into(),
});
self.save(&f)?;
Ok((value, expires_at))
}
/// An invite for one person (admin only, checked by the caller).
pub fn invite(&self, name: &str, role: Role, by: &str) -> Result<(Code, String), Refused> {
let _g = self.guard().map_err(|_| Refused("internal"))?;
let mut f = self.load().map_err(|_| Refused("internal"))?;
if !valid_name(name) {
return Err(Refused("team.name"));
}
if f.codes.len() >= MAX_CODES || f.members.len() >= MAX_MEMBERS {
return Err(Refused("team.full"));
}
let value = secret("iin").map_err(|_| Refused("internal"))?;
let code = Code {
id: new_id().map_err(|_| Refused("internal"))?,
sha256: sha256_hex(value.as_bytes()),
kind: "invite".into(),
role,
name: Some(name.trim().to_owned()),
expires_at: now() + CODE_SECS,
created_by: by.to_owned(),
};
f.codes.push(code.clone());
self.save(&f).map_err(|_| Refused("internal"))?;
Ok((code, value))
}
pub fn cancel_invite(&self, id: &str) -> Result<bool, String> {
let _g = self.guard()?;
let mut f = self.load()?;
let before = f.codes.len();
f.codes.retain(|c| !(c.id == id && c.kind == "invite"));
let gone = f.codes.len() != before;
self.save(&f)?;
Ok(gone)
}
/// Redeem a setup or invite code: the member (made now) and a new session's value.
pub fn redeem(
&self,
code: &str,
name: Option<&str>,
device: &str,
) -> Result<(Member, String), Refused> {
let _g = self.guard().map_err(|_| Refused("internal"))?;
let mut f = self.load().map_err(|_| Refused("internal"))?;
let presented = sha256_hex(code.trim().as_bytes());
let Some(pos) = f
.codes
.iter()
.position(|c| ct_eq(c.sha256.as_bytes(), presented.as_bytes()))
else {
return Err(Refused("session.code"));
};
let c = f.codes.remove(pos);
if c.kind == "setup" && !f.members.is_empty() {
return Err(Refused("session.code"));
}
let name = match (c.name.as_deref(), name) {
(Some(n), _) => n.to_owned(),
(None, Some(n)) if valid_name(n) => n.trim().to_owned(),
(None, _) => "Admin".to_owned(),
};
if f.members.len() >= MAX_MEMBERS {
return Err(Refused("team.full"));
}
let member = Member {
id: new_id().map_err(|_| Refused("internal"))?,
name,
role: c.role,
tessera_root: None,
added_at: now(),
added_by: c.created_by.clone(),
};
f.members.push(member.clone());
let value = self.push_session(&mut f, &member.id, device)?;
self.save(&f).map_err(|_| Refused("internal"))?;
Ok((member, value))
}
fn push_session(
&self,
f: &mut TeamFile,
member: &str,
device: &str,
) -> Result<String, Refused> {
let value = secret("ise").map_err(|_| Refused("internal"))?;
let t = now();
if f.sessions.len() >= MAX_SESSIONS {
// The oldest one goes.
f.sessions.sort_by_key(|s| s.created_at);
f.sessions.remove(0);
}
let device = if valid_name(device) {
device.trim().to_owned()
} else {
"Browser".to_owned()
};
f.sessions.push(Session {
id: new_id().map_err(|_| Refused("internal"))?,
sha256: sha256_hex(value.as_bytes()),
member: member.to_owned(),
device,
created_at: t,
expires_at: t + SESSION_SECS,
last_used_at: Some(t),
});
Ok(value)
}
/// The member and session behind a cookie value.
pub fn check(&self, value: &str) -> Option<(Member, Session)> {
if !value.starts_with("ise_") || value.len() > 100 {
return None;
}
let _g = self.guard().ok()?;
let mut f = self.load().ok()?;
let presented = sha256_hex(value.as_bytes());
let s = f
.sessions
.iter_mut()
.find(|s| ct_eq(s.sha256.as_bytes(), presented.as_bytes()))?;
let t = now();
let touch = s.last_used_at.is_none_or(|l| t.saturating_sub(l) >= 60);
if touch {
s.last_used_at = Some(t);
}
let s = s.clone();
let m = f.members.iter().find(|m| m.id == s.member)?.clone();
if touch {
let _ = self.save(&f);
}
Some((m, s))
}
pub fn end_session(&self, id: &str) -> Result<(), String> {
let _g = self.guard()?;
let mut f = self.load()?;
f.sessions.retain(|s| s.id != id);
self.save(&f)
}
/// Remove a member and every session of theirs. The last admin stays.
pub fn remove(&self, id: &str) -> Result<Option<Member>, Refused> {
let _g = self.guard().map_err(|_| Refused("internal"))?;
let mut f = self.load().map_err(|_| Refused("internal"))?;
let Some(m) = f.members.iter().find(|m| m.id == id).cloned() else {
return Ok(None);
};
let admins = f.members.iter().filter(|m| m.role == Role::Admin).count();
if m.role == Role::Admin && admins <= 1 {
return Err(Refused("team.last_admin"));
}
f.members.retain(|x| x.id != id);
f.sessions.retain(|s| s.member != id);
self.save(&f).map_err(|_| Refused("internal"))?;
Ok(Some(m))
}
/// Record (or clear) a member's own Tessera root.
pub fn set_root(&self, member: &str, root: Option<&str>) -> Result<(), Refused> {
if root.is_some_and(|r| !valid_root(r)) {
return Err(Refused("team.root"));
}
let _g = self.guard().map_err(|_| Refused("internal"))?;
let mut f = self.load().map_err(|_| Refused("internal"))?;
let m = f
.members
.iter_mut()
.find(|m| m.id == member)
.ok_or(Refused("team.not_found"))?;
m.tessera_root = root.map(|r| r.trim().to_owned());
self.save(&f).map_err(|_| Refused("internal"))
}
}
#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used)]
use super::*;
fn dir(n: &str) -> PathBuf {
let d = std::env::temp_dir().join(format!("ianitor-team-{n}-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&d);
d
}
#[test]
fn setup_then_invite_then_sessions() {
let d = dir("flow");
let t = Team::new(&d);
let (setup, _) = t.setup_code().unwrap();
assert!(t.redeem("isc_wrong", Some("Mark"), "Laptop").is_err());
let (mark, s1) = t.redeem(&setup, Some("Mark"), "Laptop").unwrap();
assert_eq!(mark.role, Role::Admin);
// One use only, and no second setup once there is a member.
assert_eq!(
t.redeem(&setup, Some("Eve"), "x").unwrap_err(),
Refused("session.code")
);
assert!(t.setup_code().is_err());
let (who, _) = t.check(&s1).unwrap();
assert_eq!(who.name, "Mark");
// Only hashes on disk.
let stored = std::fs::read_to_string(d.join("team.json")).unwrap();
assert!(!stored.contains(&s1) && !stored.contains(&setup));
let (_, inv) = t.invite("Petra", Role::Member, &mark.id).unwrap();
let (petra, s2) = t.redeem(&inv, Some("Someone else"), "Phone").unwrap();
assert_eq!((petra.name.as_str(), petra.role), ("Petra", Role::Member));
// The last admin cannot go; a member can, with their sessions.
assert_eq!(t.remove(&mark.id).unwrap_err(), Refused("team.last_admin"));
t.remove(&petra.id).unwrap();
assert!(t.check(&s2).is_none());
let (_, s) = t.check(&s1).unwrap();
t.end_session(&s.id).unwrap();
assert!(t.check(&s1).is_none());
let _ = std::fs::remove_dir_all(&d);
}
#[test]
fn tessera_roots_are_checked() {
assert!(valid_root(&URL_SAFE_NO_PAD.encode([7u8; 32])));
assert!(!valid_root("not base64!"));
assert!(!valid_root(&URL_SAFE_NO_PAD.encode([7u8; 31])));
// Fundamentum's vector (crates/tessera/tests/mandatory.rs, MATCH_SEVENS = "016810").
assert_eq!(
match_code(&URL_SAFE_NO_PAD.encode([7u8; 32])).unwrap(),
"016 810"
);
}
}
+34 -2
View File
@@ -23,6 +23,34 @@ use serde::{Deserialize, Serialize};
use crate::util::{ct_eq, hex, now, random, read_json, sha256_hex, write_json};
/// What a token may do. `full` (the default, and every token made before T4) may do
/// everything the API offers; `previews` may only use `/api/v1/previews` (Fabrica's branch
/// previews), so a leaked preview token can never touch another host.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum Scope {
#[default]
Full,
Previews,
}
impl Scope {
pub fn as_str(self) -> &'static str {
match self {
Scope::Full => "full",
Scope::Previews => "previews",
}
}
pub fn parse(s: &str) -> Option<Scope> {
match s {
"full" => Some(Scope::Full),
"previews" => Some(Scope::Previews),
_ => None,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct TokenRecord {
@@ -33,6 +61,8 @@ pub struct TokenRecord {
pub expires_at: Option<u64>,
pub last_used_at: Option<u64>,
pub revoked_at: Option<u64>,
#[serde(default)]
pub scope: Scope,
}
#[derive(Debug, Default, Serialize, Deserialize)]
@@ -117,6 +147,7 @@ impl Tokens {
&self,
name: &str,
expires_at: Option<u64>,
scope: Scope,
) -> Result<(TokenRecord, String), String> {
let _g = self.guard()?;
if !valid_name(name) {
@@ -137,6 +168,7 @@ impl Tokens {
expires_at,
last_used_at: None,
revoked_at: None,
scope,
};
f.tokens.push(rec.clone());
self.save(&f)?;
@@ -231,7 +263,7 @@ mod tests {
fn create_check_revoke() {
let d = std::env::temp_dir().join(format!("ianitor-tokens-{}", std::process::id()));
let t = Tokens::new(&d);
let (rec, value) = t.create("laptop", None).unwrap();
let (rec, value) = t.create("laptop", None, Scope::Full).unwrap();
assert!(value.starts_with("ian_"));
let stored = std::fs::read_to_string(d.join("tokens.json")).unwrap();
assert!(!stored.contains(&value[21..]), "only the hash is stored");
@@ -253,7 +285,7 @@ mod tests {
t.check(Some(&format!("Bearer {value}"))).unwrap_err(),
Refusal::Revoked(_)
));
let (_, v2) = t.create("old", Some(1)).unwrap();
let (_, v2) = t.create("old", Some(1), Scope::Full).unwrap();
assert_eq!(
t.check(Some(&format!("Bearer {v2}"))).unwrap_err(),
Refusal::Expired(1)
+109
View File
@@ -0,0 +1,109 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Windows Server, Caddy mode (Fabrica docs/32_coherence.md §2.5, T4): what the service
//! control manager starts. `ianitor-control service control --config <c>` is the control
//! plane, `ianitor-control service caddy-guard --config <c>` the Caddy trial deadline guard
//! (its own service, so a hung or crashed control cannot leave Caddy on an unconfirmed
//! trial). Both stop cleanly on the SCM's Stop. `deploy/windows/install.ps1` registers them.
//! Logs go to the file given with `--log-file` (stderr goes nowhere under the SCM).
use std::ffi::OsString;
use std::sync::OnceLock;
use std::time::Duration;
use windows_service::service::{
ServiceControl, ServiceControlAccept, ServiceExitCode, ServiceState, ServiceStatus, ServiceType,
};
use windows_service::service_control_handler::{self, ServiceControlHandlerResult};
use windows_service::{define_windows_service, service_dispatcher};
static ARGS: OnceLock<Vec<String>> = OnceLock::new();
define_windows_service!(ffi_service_main, service_main);
/// Hand this process to the service control manager (blocks until the service stops).
pub fn run(args: &[String]) -> Result<(), String> {
let _ = ARGS.set(args.to_vec());
// The name is ignored for a service in its own process.
service_dispatcher::start("IanitorControl", ffi_service_main)
.map_err(|e| format!("not started by the service control manager ({e}); run it as a service, or use --config to run it in a console"))
}
fn status(state: ServiceState, code: u32) -> ServiceStatus {
ServiceStatus {
service_type: ServiceType::OWN_PROCESS,
current_state: state,
controls_accepted: if state == ServiceState::Running {
ServiceControlAccept::STOP | ServiceControlAccept::SHUTDOWN
} else {
ServiceControlAccept::empty()
},
exit_code: ServiceExitCode::Win32(code),
checkpoint: 0,
wait_hint: Duration::from_secs(10),
process_id: None,
}
}
fn service_main(_: Vec<OsString>) {
let args = ARGS.get().cloned().unwrap_or_default();
let (tx, rx) = tokio::sync::oneshot::channel::<()>();
let tx = std::sync::Mutex::new(Some(tx));
let handler = move |c| match c {
ServiceControl::Stop | ServiceControl::Shutdown => {
if let Ok(mut t) = tx.lock()
&& let Some(t) = t.take()
{
let _ = t.send(());
}
ServiceControlHandlerResult::NoError
}
ServiceControl::Interrogate => ServiceControlHandlerResult::NoError,
_ => ServiceControlHandlerResult::NotImplemented,
};
let Ok(h) = service_control_handler::register("IanitorControl", handler) else {
return;
};
let _ = h.set_service_status(status(ServiceState::Running, 0));
let result = serve(&args, rx);
if let Err(e) = &result {
log::error!(target: "ianitor::service", "{e}");
}
let _ = h.set_service_status(status(ServiceState::Stopped, u32::from(result.is_err())));
}
fn serve(args: &[String], stop: tokio::sync::oneshot::Receiver<()>) -> Result<(), String> {
let what = args.first().map(String::as_str).unwrap_or("control");
let config = args
.iter()
.position(|a| a == "--config")
.and_then(|i| args.get(i + 1))
.ok_or("service: --config <control.toml> is required")?;
let cfg =
ianitor_control::Config::load(std::path::Path::new(config)).map_err(|e| e.to_string())?;
let rt = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.map_err(|e| e.to_string())?;
rt.block_on(async move {
match what {
"control" => {
ianitor_control::serve(cfg, async {
let _ = stop.await;
})
.await
}
"caddy-guard" => {
tokio::select! {
r = ianitor_control::caddy_guard::run(cfg) => r,
_ = stop => Ok(()),
}
}
other => Err(format!(
"service: unknown part {other:?} (control or caddy-guard)"
)),
}
})
}
+6 -4
View File
@@ -12,12 +12,14 @@
#[cfg(unix)]
mod common;
// On Windows this target has nothing to run: it shows as one *ignored* test, never as a
// pass (ROADMAP §8.3; run it in WSL2, see CLAUDE.md).
#[cfg(not(unix))]
#[test]
#[ignore = "needs Linux (edge admin socket): run it in WSL2, see CLAUDE.md"]
fn needs_linux() {}
fn skipped_on_windows() {
eprintln!(
"SKIPPED on Windows: {} needs Linux (edge admin socket); run it in WSL2",
file!()
);
}
#[cfg(unix)]
mod unix {
+6 -4
View File
@@ -13,12 +13,14 @@
#[cfg(unix)]
mod common;
// On Windows this target has nothing to run: it shows as one *ignored* test, never as a
// pass (ROADMAP §8.3; run it in WSL2, see CLAUDE.md).
#[cfg(not(unix))]
#[test]
#[ignore = "needs Linux (edge admin socket): run it in WSL2, see CLAUDE.md"]
fn needs_linux() {}
fn skipped_on_windows() {
eprintln!(
"SKIPPED on Windows: {} needs Linux (edge admin socket); run it in WSL2",
file!()
);
}
#[cfg(unix)]
mod unix {
+280
View File
@@ -0,0 +1,280 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Caddy mode end to end (T4: Windows Server runs control with Caddy as the data plane, no
//! edge). Control runs with `engine = caddy`, Caddy's admin API on loopback TCP (as on
//! Windows), and the Domi CA. A previews-only token opens a branch preview; the apply goes
//! through Caddy (trial, watch, confirm); the preview's address then answers through Caddy
//! with a Domi certificate; closing it takes it away again. Runs on Windows and on Linux.
//! Needs `caddy` on PATH or `$IANITOR_CADDY_BIN` (else it fails, unless IANITOR_ALLOW_SKIP=1).
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
use std::net::SocketAddr;
use std::process::{Command, Stdio};
use std::sync::Arc;
use std::time::{Duration, Instant};
use ianitor_control::Config;
use ianitor_control::tokens::{Scope, Tokens};
use ianitor_testkit::client::{self, Req};
use ianitor_testkit::more::{JsonResp, tcp_json};
use ianitor_testkit::proc::{ChildGuard, TempDir, free_port, local, require_binary, wait_for_port};
use ianitor_testkit::upstream::Echo;
use serde_json::{Value, json};
fn s(p: &std::path::Path) -> String {
p.to_string_lossy().replace('\\', "/")
}
async fn call(
api: SocketAddr,
token: &str,
method: &str,
path: &str,
body: Option<Value>,
) -> JsonResp {
let auth = format!("Bearer {token}");
tcp_json(
api,
method,
path,
&[("Authorization", &auth)],
body.as_ref(),
)
.await
.unwrap()
}
async fn settle(api: SocketAddr, token: &str, apply: &Value) -> Value {
let id = apply["id"].as_str().unwrap().to_owned();
let t = Instant::now();
loop {
let r = call(api, token, "GET", &format!("/api/v1/applies/{id}"), None).await;
if ["kept", "reverted", "failed"].contains(&r.json["state"].as_str().unwrap_or("")) {
return r.json;
}
assert!(
t.elapsed() < Duration::from_secs(90),
"apply stuck: {}",
r.text
);
tokio::time::sleep(Duration::from_millis(700)).await;
}
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn a_branch_preview_answers_through_caddy_without_an_edge() {
let Some(caddy) = require_binary("caddy") else {
return;
};
let dir = TempDir::new("caddy-mode");
for d in [
"state",
"edge",
"caddy",
"certs",
"creds",
"caddy-state",
"root",
"xdg",
] {
std::fs::create_dir_all(dir.join(d)).unwrap();
}
// The offline root (a test one) and the intermediate's password.
let now = ianitor_control::util::now();
let (root_pem, root_key) = ianitor_core::pki::create_root(now as i64).unwrap();
std::fs::write(dir.join("root/domi-root.crt"), &root_pem).unwrap();
std::fs::write(
dir.join("creds/pki-password"),
"caddy-mode-test-password-0123456789",
)
.unwrap();
let api = local(free_port());
let admin = local(free_port());
let (http, https) = (free_port(), free_port());
// Caddy starts with only its admin API, as the installer starts it; control loads the rest.
let boot = json!({"admin": {"listen": admin.to_string()}}).to_string();
std::fs::write(dir.join("caddy/boot.json"), &boot).unwrap();
let log = std::fs::File::create(dir.join("caddy.log")).unwrap();
let _caddy = ChildGuard(
Command::new(&caddy)
.args(["run", "--config"])
.arg(dir.join("caddy/boot.json"))
.env("HOME", dir.join("xdg"))
.env("XDG_CONFIG_HOME", dir.join("xdg"))
.env("XDG_DATA_HOME", dir.join("xdg"))
.env("APPDATA", dir.join("xdg"))
.stdout(Stdio::from(log.try_clone().unwrap()))
.stderr(Stdio::from(log))
.spawn()
.unwrap(),
);
assert!(
wait_for_port(admin, Duration::from_secs(60)),
"Caddy's admin API did not start"
);
std::fs::write(dir.join("state/engine"), "caddy\n").unwrap();
let text = format!(
r#"listen = "{api}"
state_dir = "{state}"
credentials_dir = "{creds}"
watch_secs = 2
watch_every_secs = 1
trial_margin_secs = 5
[routes]
repo = "{repo}"
[edge]
config = "{edge}/edge.json"
share_revocations = "{edge}/share-revocations.json"
[caddy]
config = "{caddy_dir}/caddy.json"
[compile]
http_listen = "127.0.0.1:{http}"
https_listen = "127.0.0.1:{https}"
cert_dir = "{certs}"
state_dir = "{caddy_state}"
access_log = "{caddy_state}/access.log"
caddy_credentials_dir = "{creds}"
caddy_admin = "{admin}"
[pki]
root_cert = "{root}/domi-root.crt"
kdf_iterations = 10000
[engine]
file = "{state}/engine"
units = "none"
[previews]
domain = "pv.test"
tls = "domi"
upstreams = ["127.0.0.1:1024-65535"]
min_ttl_secs = 60
"#,
state = s(&dir.join("state")),
creds = s(&dir.join("creds")),
repo = s(&dir.join("routes.git")),
edge = s(&dir.join("edge")),
caddy_dir = s(&dir.join("caddy")),
certs = s(&dir.join("certs")),
caddy_state = s(&dir.join("caddy-state")),
root = s(&dir.join("root")),
);
std::fs::write(dir.join("control.toml"), text).unwrap();
let cfg = Config::load(&dir.join("control.toml")).unwrap();
// The intermediate, signed by the test root (the offline step of docs/pki.md).
{
let c = ianitor_control::Control::open(cfg.clone()).await.unwrap();
let p = c.pki.as_ref().unwrap();
let r = p.request_renewal(now, "test").unwrap();
let signed = ianitor_core::pki::sign_intermediate(
&root_pem,
&root_key,
r.csr_pem.as_deref().unwrap(),
now as i64,
)
.unwrap();
p.install_intermediate(&r.id, &signed, now).unwrap();
}
let tokens = Tokens::new(&dir.join("state"));
let (_, admin_tok) = tokens.create("admin", None, Scope::Full).unwrap();
let (_, fabrica) = tokens.create("fabrica", None, Scope::Previews).unwrap();
let (tx, rx) = tokio::sync::oneshot::channel::<()>();
tokio::spawn(ianitor_control::serve(cfg, async {
let _ = rx.await;
}));
assert!(wait_for_port(api, Duration::from_secs(20)));
let r = call(api, &admin_tok, "GET", "/api/v1/overview", None).await;
assert_eq!(r.json["engine"]["running"], "caddy", "{}", r.text);
assert_eq!(r.json["engine"]["switchable"], false, "{}", r.text);
// Fabrica opens the branch's preview.
let app = Echo::start("preview-app").await;
let r = call(
api,
&fabrica,
"POST",
"/api/v1/previews",
Some(json!({"project": "shop", "branch": "fix-42", "upstream": app.url(), "ttl": 3600})),
)
.await;
assert_eq!(r.status, 202, "{}", r.text);
let host = r.json["preview"]["hostname"].as_str().unwrap().to_owned();
assert_eq!(host, "fix-42--shop.pv.test");
let done = settle(api, &admin_tok, &r.json["apply"]).await;
assert_eq!(done["state"], "kept", "{done}");
let steps: Vec<String> = done["steps"]
.as_array()
.unwrap()
.iter()
.map(|s| {
format!(
"{}={}",
s["key"].as_str().unwrap(),
s["state"].as_str().unwrap()
)
})
.collect();
assert!(
steps.contains(&"watch=done".to_owned()),
"watched through Caddy: {steps:?}"
);
// The preview answers through Caddy, with a certificate from the Domi CA.
let mut roots = rustls::RootCertStore::empty();
for der in ianitor_core::pki::chain_der(&root_pem).unwrap() {
roots
.add(rustls_pki_types::CertificateDer::from(der))
.unwrap();
}
let roots = Arc::new(roots);
let https_addr = local(https);
let resp = client::https(https_addr, &host, roots.clone(), &Req::get(&host, "/hello"))
.await
.unwrap();
assert_eq!(resp.status, 200);
assert_eq!(resp.header("x-robots-tag"), Some("noindex, nofollow"));
assert!(String::from_utf8_lossy(&resp.body).contains("preview-app"));
let r = call(
api,
&fabrica,
"GET",
&format!("/api/v1/previews/{host}"),
None,
)
.await;
assert_eq!(r.json["preview"]["state"], "live", "{}", r.text);
// Closed on merge: Caddy stops serving it.
let r = call(
api,
&fabrica,
"POST",
"/api/v1/previews/close",
Some(json!({"project": "shop", "branch": "fix-42"})),
)
.await;
assert_eq!(r.status, 202, "{}", r.text);
assert_eq!(
settle(api, &admin_tok, &r.json["apply"]).await["state"],
"kept"
);
let gone = client::https(https_addr, &host, roots, &Req::get(&host, "/hello")).await;
assert!(
gone.as_ref()
.map_or(true, |r| r.status == 404 || r.status == 421),
"{:?}",
gone.map(|r| r.status)
);
let _ = tx.send(());
}
-1
View File
@@ -116,7 +116,6 @@ impl Env {
caddy_admin: None,
caddy_admin_socket: None,
trusted_proxies: Vec::new(),
proxy_socket: None,
};
// Edge starts from an empty config; control brings it in line on its first start.
let empty = load(
+29 -14
View File
@@ -11,12 +11,14 @@
#[cfg(unix)]
mod common;
// On Windows this target has nothing to run: it shows as one *ignored* test, never as a
// pass (ROADMAP §8.3; run it in WSL2, see CLAUDE.md).
#[cfg(not(unix))]
#[test]
#[ignore = "needs Linux: run it in WSL2, see CLAUDE.md"]
fn needs_linux() {}
fn skipped_on_windows() {
eprintln!(
"SKIPPED on Windows: {} needs Linux; run it in WSL2",
file!()
);
}
#[cfg(unix)]
mod unix {
@@ -531,7 +533,11 @@ esac
std::fs::write(env.dir.join("certs/a.test.crt"), &leaf.chain_pem).unwrap();
// What control does in devices_changed / reload_serving_engine under Caddy.
let text = std::fs::read(env.dir.join("caddy/caddy.json")).unwrap();
let r = ianitor_control::caddy_link::load(&env.dir.join("caddy/admin.sock"), &text).await;
let r = ianitor_control::caddy_link::load(
&ianitor_control::caddy_link::Admin::Unix(env.dir.join("caddy/admin.sock")),
&text,
)
.await;
assert!(r.is_ok(), "{r:?}");
let after = visit(env, ce.https, "a.test").await;
eprintln!(
@@ -688,9 +694,12 @@ esac
);
// What a device change or a Caddy restart does: Caddy gets the last good config.
let good = std::fs::read(env.dir.join("caddy/caddy.json")).unwrap();
ianitor_control::caddy_link::load(&env.dir.join("caddy/admin.sock"), &good)
.await
.unwrap();
ianitor_control::caddy_link::load(
&ianitor_control::caddy_link::Admin::Unix(env.dir.join("caddy/admin.sock")),
&good,
)
.await
.unwrap();
let rec = env.wait_apply(&id).await;
assert_ne!(rec["state"], "kept", "{rec}");
assert_eq!(rec["reason"]["code"], "apply.reverted.edge_lost", "{rec}");
@@ -839,13 +848,19 @@ esac
std::fs::write(env.dir.join("certs/domi-devices.pem"), &laptop.cert_pem).unwrap();
let sock = env.dir.join("caddy/admin.sock");
let text = std::fs::read(env.dir.join("caddy/caddy.json")).unwrap();
ianitor_control::caddy_link::load(&sock, &text)
.await
.unwrap();
ianitor_control::caddy_link::load(
&ianitor_control::caddy_link::Admin::Unix(sock.clone()),
&text,
)
.await
.unwrap();
assert!(
ianitor_control::caddy_link::runs(&sock, &text)
.await
.unwrap()
ianitor_control::caddy_link::runs(
&ianitor_control::caddy_link::Admin::Unix(sock.clone()),
&text
)
.await
.unwrap()
);
let phone_after = visit_as(&phone).await;
let laptop_after = visit_as(&laptop).await;
+6 -4
View File
@@ -13,12 +13,14 @@
#[cfg(unix)]
mod common;
// On Windows this target has nothing to run: it shows as one *ignored* test, never as a
// pass (ROADMAP §8.3; run it in WSL2, see CLAUDE.md).
#[cfg(not(unix))]
#[test]
#[ignore = "needs Linux: run it in WSL2, see CLAUDE.md"]
fn needs_linux() {}
fn skipped_on_windows() {
eprintln!(
"SKIPPED on Windows: {} needs Linux; run it in WSL2",
file!()
);
}
#[cfg(unix)]
mod unix {
+539
View File
@@ -0,0 +1,539 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Branch previews for Fabrica (T4, tests first). `POST /api/v1/previews {project, branch,
//! upstream, ttl}` gives the branch the host `<branch>--<project>.<preview domain>`; a token
//! scoped to previews may do that and nothing else. These tests run control in this process
//! without an edge (applies are kept at once), so they run on Windows too; the end-to-end
//! runs through Pingora and Caddy are in tests/diff and scripts/preview-smoke.*.
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
use std::net::SocketAddr;
use std::time::{Duration, Instant};
use ianitor_control::Config;
use ianitor_control::tokens::{Scope, Tokens};
use ianitor_testkit::more::{JsonResp, tcp_json};
use ianitor_testkit::proc::{TempDir, free_port, local, wait_for_port};
use serde_json::{Value, json};
const DOMAIN: &str = "pv.example.test";
struct Ctl {
_dir: TempDir,
api: SocketAddr,
admin: String,
preview: String,
stop: Option<tokio::sync::oneshot::Sender<()>>,
}
impl Drop for Ctl {
fn drop(&mut self) {
if let Some(s) = self.stop.take() {
let _ = s.send(());
}
}
}
fn s(p: &std::path::Path) -> String {
p.to_string_lossy().replace('\\', "/")
}
impl Ctl {
async fn start(extra: &str) -> Ctl {
let dir = TempDir::new("pv");
for d in ["state", "edge", "caddy", "certs", "creds", "edge-state"] {
std::fs::create_dir_all(dir.join(d)).unwrap();
}
let api = local(free_port());
let text = format!(
r#"listen = "{api}"
state_dir = "{state}"
credentials_dir = "{creds}"
[routes]
repo = "{repo}"
[edge]
config = "{edge}/edge.json"
share_revocations = "{edge}/share-revocations.json"
[caddy]
config = "{caddy}/caddy.json"
[compile]
http_listen = "127.0.0.1:{http}"
https_listen = "127.0.0.1:{https}"
cert_dir = "{certs}"
state_dir = "{edge_state}"
access_log = "{edge_state}/access.log"
caddy_credentials_dir = "{creds}"
[previews]
domain = "{DOMAIN}"
tls = "letsencrypt"
upstreams = ["10.0.0.0/8", "127.0.0.1:20000-29999", "app.internal"]
min_ttl_secs = 1
sweep_secs = 1
{extra}
"#,
state = s(&dir.join("state")),
creds = s(&dir.join("creds")),
repo = s(&dir.join("routes.git")),
edge = s(&dir.join("edge")),
caddy = s(&dir.join("caddy")),
certs = s(&dir.join("certs")),
edge_state = s(&dir.join("edge-state")),
http = free_port(),
https = free_port(),
);
let path = dir.join("control.toml");
std::fs::write(&path, text).unwrap();
let cfg = Config::load(&path).unwrap();
let tokens = Tokens::new(&dir.join("state"));
let (_, admin) = tokens.create("admin", None, Scope::Full).unwrap();
let (_, preview) = tokens
.create("fabrica previews", None, Scope::Previews)
.unwrap();
let (tx, rx) = tokio::sync::oneshot::channel::<()>();
tokio::spawn(async move {
if let Err(e) = ianitor_control::serve(cfg, async {
let _ = rx.await;
})
.await
{
panic!("control stopped: {e}");
}
});
assert!(
wait_for_port(api, Duration::from_secs(20)),
"control did not listen"
);
Ctl {
_dir: dir,
api,
admin,
preview,
stop: Some(tx),
}
}
async fn call(&self, token: &str, method: &str, path: &str, body: Option<Value>) -> JsonResp {
let auth = format!("Bearer {token}");
tcp_json(
self.api,
method,
path,
&[("Authorization", &auth)],
body.as_ref(),
)
.await
.unwrap()
}
async fn admin(&self, method: &str, path: &str, body: Option<Value>) -> JsonResp {
self.call(&self.admin, method, path, body).await
}
async fn fabrica(&self, method: &str, path: &str, body: Option<Value>) -> JsonResp {
self.call(&self.preview, method, path, body).await
}
/// Wait for an apply to end; returns its final state.
async fn settle(&self, apply: &Value) -> String {
let id = apply["id"].as_str().expect("an apply id").to_owned();
let t = Instant::now();
loop {
let r = self
.admin("GET", &format!("/api/v1/applies/{id}"), None)
.await;
let state = r.json["state"].as_str().unwrap_or("").to_owned();
if ["kept", "reverted", "failed"].contains(&state.as_str()) {
return state;
}
assert!(
t.elapsed() < Duration::from_secs(30),
"apply {id} stuck: {}",
r.text
);
tokio::time::sleep(Duration::from_millis(700)).await;
}
}
async fn host_names(&self) -> Vec<String> {
let r = self.admin("GET", "/api/v1/hosts", None).await;
assert_eq!(r.status, 200, "{}", r.text);
r.json["hosts"]
.as_array()
.unwrap()
.iter()
.map(|h| h["hostname"].as_str().unwrap().to_owned())
.collect()
}
async fn add_plain_host(&self, hostname: &str) {
let r = self
.admin(
"POST",
"/api/v1/hosts",
Some(json!({"host": {"hostname": hostname, "upstreams": ["http://10.0.0.9:80"]}})),
)
.await;
assert_eq!(r.status, 202, "{}", r.text);
assert_eq!(self.settle(&r.json["apply"]).await, "kept");
}
async fn open_preview(&self, project: &str, branch: &str, upstream: &str) -> JsonResp {
self.fabrica(
"POST",
"/api/v1/previews",
Some(json!({"project": project, "branch": branch, "upstream": upstream, "ttl": 3600})),
)
.await
}
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn a_preview_token_cannot_touch_non_preview_hosts() {
let c = Ctl::start("").await;
c.add_plain_host("www.example.test").await;
let www =
json!({"host": {"hostname": "www.example.test", "upstreams": ["http://10.6.6.6:80"]}});
// Everything outside /api/v1/previews is refused, reads included.
let refused: Vec<(&str, &str, Option<Value>)> = vec![
("GET", "/api/v1/overview", None),
("GET", "/api/v1/hosts", None),
("GET", "/api/v1/hosts/www.example.test", None),
(
"POST",
"/api/v1/hosts",
Some(
json!({"host": {"hostname": "evil.example.test", "upstreams": ["http://10.6.6.6:80"]}}),
),
),
("PUT", "/api/v1/hosts/www.example.test", Some(www.clone())),
(
"PATCH",
"/api/v1/hosts/www.example.test",
Some(json!({"share_links": true})),
),
("DELETE", "/api/v1/hosts/www.example.test", None),
("POST", "/api/v1/hosts/validate", Some(www["host"].clone())),
("POST", "/api/v1/undo", Some(json!({}))),
("POST", "/api/v1/restore", Some(json!({"change_id": "x"}))),
("GET", "/api/v1/history", None),
("GET", "/api/v1/applies", None),
("GET", "/api/v1/tokens", None),
("POST", "/api/v1/tokens", Some(json!({"name": "escalate"}))),
(
"POST",
"/api/v1/hosts/www.example.test/share-links",
Some(json!({})),
),
("POST", "/api/v1/share-links/stop-all", None),
("GET", "/api/v1/certs", None),
("POST", "/api/v1/engine", Some(json!({"target": "caddy"}))),
("POST", "/api/v1/repo/push", None),
("GET", "/api/v1/settings", None),
("GET", "/api/v1/team", None),
];
for (m, p, b) in refused {
let r = c.fabrica(m, p, b).await;
assert_eq!(r.status, 403, "{m} {p}: {}", r.text);
assert_eq!(
r.json["error"]["code"], "token.scope",
"{m} {p}: {}",
r.text
);
}
// The previews API refuses a host that is not a preview.
let r = c
.fabrica("DELETE", "/api/v1/previews/www.example.test", None)
.await;
assert_eq!(r.status, 404, "{}", r.text);
assert_eq!(r.json["error"]["code"], "preview.not_found");
let r = c
.fabrica("GET", "/api/v1/previews/www.example.test", None)
.await;
assert_eq!(r.status, 404, "{}", r.text);
// A non-preview host at exactly the name a preview would get is not taken over.
let taken = format!("main--shop.{DOMAIN}");
c.add_plain_host(&taken).await;
let r = c.open_preview("shop", "main", "http://10.0.0.5:8080").await;
assert_eq!(r.status, 409, "{}", r.text);
assert_eq!(r.json["error"]["code"], "preview.taken");
let r = c
.admin("GET", &format!("/api/v1/hosts/{taken}"), None)
.await;
assert_eq!(
r.json["host"]["upstreams"][0], "http://10.0.0.9:80",
"{}",
r.text
);
let r = c
.fabrica(
"POST",
"/api/v1/previews/close",
Some(json!({"project": "shop", "branch": "main"})),
)
.await;
assert_eq!(r.status, 404, "{}", r.text);
// A preview the token made touches only its own file, and the list holds only previews.
let r = c
.open_preview("shop", "fix-1", "http://10.0.0.5:8080")
.await;
assert_eq!(r.status, 202, "{}", r.text);
assert_eq!(c.settle(&r.json["apply"]).await, "kept");
let hosts = r.json["apply"]["hosts"].as_array().unwrap().clone();
assert_eq!(hosts, vec![json!(format!("fix-1--shop.{DOMAIN}"))]);
let r = c.fabrica("GET", "/api/v1/previews", None).await;
assert_eq!(r.status, 200, "{}", r.text);
let listed: Vec<&str> = r.json["items"]
.as_array()
.unwrap()
.iter()
.map(|p| p["hostname"].as_str().unwrap())
.collect();
assert_eq!(listed, vec![format!("fix-1--shop.{DOMAIN}").as_str()]);
let mut names = c.host_names().await;
names.sort();
assert_eq!(
names,
vec![
format!("fix-1--shop.{DOMAIN}"),
taken.clone(),
"www.example.test".into()
]
);
// An admin can still kill a preview; the scoped token was never needed for that.
let r = c
.admin(
"DELETE",
&format!("/api/v1/previews/fix-1--shop.{DOMAIN}"),
None,
)
.await;
assert_eq!(r.status, 202, "{}", r.text);
assert_eq!(c.settle(&r.json["apply"]).await, "kept");
assert!(
!c.host_names()
.await
.iter()
.any(|h| h.starts_with("fix-1--"))
);
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn a_preview_token_cannot_point_a_preview_at_this_machine_s_admin_ports() {
let c = Ctl::start("").await;
let control_port = c.api.port();
for upstream in [
// control itself, Caddy's admin API, anything on loopback outside the allowed range
format!("http://127.0.0.1:{control_port}"),
"http://127.0.0.1:2019".to_owned(),
"http://localhost:20001".to_owned(),
"http://[::1]:20001".to_owned(),
"http://0.0.0.0:20001".to_owned(),
"http://169.254.169.254:80".to_owned(),
// not in the allow list
"http://192.168.1.10:8080".to_owned(),
"http://other.internal:8080".to_owned(),
// not an upstream at all
"http://user:pw@10.0.0.5:8080".to_owned(),
"http://10.0.0.5:8080/path".to_owned(),
"file:///etc/passwd".to_owned(),
"".to_owned(),
] {
let r = c.open_preview("shop", "main", &upstream).await;
assert!(
r.status == 422 || r.status == 403,
"{upstream}: {} {}",
r.status,
r.text
);
assert!(
r.json["error"]["code"].as_str().is_some_and(
|c| c.starts_with("preview.upstream") || c.starts_with("host.upstream")
),
"{upstream}: {}",
r.text
);
}
assert!(c.host_names().await.is_empty());
// Allowed: the private range, the loopback port range, the listed name.
for (b, u) in [
("a", "http://10.1.2.3:8080"),
("b", "http://127.0.0.1:20001"),
("c", "http://app.internal:3000"),
] {
let r = c.open_preview("shop", b, u).await;
assert_eq!(r.status, 202, "{u}: {}", r.text);
assert_eq!(c.settle(&r.json["apply"]).await, "kept");
}
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn a_preview_lives_until_closed_or_expired() {
let c = Ctl::start("").await;
// Open, with a hostile branch name: the host is safe and the API says where it is.
let r = c
.open_preview(
"github:acme/Web.App",
"feature/Ünï ../../etc",
"http://10.0.0.5:8080",
)
.await;
assert_eq!(r.status, 202, "{}", r.text);
let host = r.json["preview"]["hostname"].as_str().unwrap().to_owned();
assert!(host.ends_with(&format!(".{DOMAIN}")), "{host}");
assert!(host.split('.').next().unwrap().contains("--"));
assert_eq!(r.json["preview"]["url"], format!("https://{host}/"));
assert_eq!(c.settle(&r.json["apply"]).await, "kept");
let r = c
.fabrica("GET", &format!("/api/v1/previews/{host}"), None)
.await;
assert_eq!(r.status, 200, "{}", r.text);
assert_eq!(r.json["preview"]["branch"], "feature/Ünï ../../etc");
assert_eq!(r.json["preview"]["state"], "live", "{}", r.text);
// A new deploy of the same branch moves the same host, it does not add one.
let r = c
.open_preview(
"github:acme/Web.App",
"feature/Ünï ../../etc",
"http://10.0.0.6:8080",
)
.await;
assert_eq!(r.status, 202, "{}", r.text);
assert_eq!(r.json["preview"]["hostname"], host.as_str());
assert_eq!(c.settle(&r.json["apply"]).await, "kept");
let r = c.admin("GET", &format!("/api/v1/hosts/{host}"), None).await;
assert_eq!(r.json["host"]["upstreams"][0], "http://10.0.0.6:8080");
assert_eq!(c.host_names().await.len(), 1);
// Closed on merge, by project and branch.
let r = c
.fabrica(
"POST",
"/api/v1/previews/close",
Some(json!({"project": "github:acme/Web.App", "branch": "feature/Ünï ../../etc"})),
)
.await;
assert_eq!(r.status, 202, "{}", r.text);
assert_eq!(c.settle(&r.json["apply"]).await, "kept");
assert!(c.host_names().await.is_empty());
// Expired: removed by control by itself.
let r = c
.fabrica(
"POST",
"/api/v1/previews",
Some(json!({"project": "shop", "branch": "short", "upstream": "http://10.0.0.5:80", "ttl": 2})),
)
.await;
assert_eq!(r.status, 202, "{}", r.text);
assert_eq!(c.settle(&r.json["apply"]).await, "kept");
let t = Instant::now();
while !c.host_names().await.is_empty() {
assert!(
t.elapsed() < Duration::from_secs(30),
"the expired preview stayed"
);
tokio::time::sleep(Duration::from_millis(700)).await;
}
let r = c.admin("GET", "/api/v1/history", None).await;
assert!(r.text.contains("expired"), "{}", r.text);
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn bad_preview_requests_are_refused_with_a_reason() {
let c = Ctl::start(
"max_ttl_secs = 86400
default_ttl_secs = 3600",
)
.await;
for (body, code) in [
(
json!({"project": "shop", "branch": "a\nb", "upstream": "http://10.0.0.5:80"}),
"preview.branch",
),
(
json!({"project": "shop", "branch": "", "upstream": "http://10.0.0.5:80"}),
"preview.branch",
),
(
json!({"project": "sh op", "branch": "main", "upstream": "http://10.0.0.5:80"}),
"preview.project",
),
(
json!({"project": "shop", "branch": "main", "upstream": "http://10.0.0.5:80", "ttl": 0}),
"preview.ttl",
),
(
json!({"project": "shop", "branch": "main", "upstream": "http://10.0.0.5:80", "ttl": 864000}),
"preview.ttl",
),
(
json!({"project": "shop", "branch": "main", "upstream": "http://10.0.0.5:80", "auth": "none"}),
"request.body_unknown_field",
),
] {
let r = c
.fabrica("POST", "/api/v1/previews", Some(body.clone()))
.await;
assert_eq!(r.json["error"]["code"], code, "{body}: {}", r.text);
assert!(r.status == 422 || r.status == 400, "{body}: {}", r.text);
}
assert!(c.host_names().await.is_empty());
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn without_a_preview_domain_the_api_says_previews_are_off() {
let c = Ctl::start("").await;
// Replace the config with one that has no [previews] section, then restart.
drop(c);
let c2 = {
let dir = TempDir::new("pv-off");
std::fs::create_dir_all(dir.join("state")).unwrap();
let api = local(free_port());
let text = format!(
"listen = \"{api}\"\nstate_dir = \"{st}\"\n\n[routes]\nrepo = \"{repo}\"\n\n[edge]\nconfig = \"{d}/edge.json\"\nshare_revocations = \"{d}/rev.json\"\n\n[caddy]\nconfig = \"{d}/caddy.json\"\n\n[compile]\nhttp_listen = \"127.0.0.1:{h}\"\nhttps_listen = \"127.0.0.1:{hs}\"\ncert_dir = \"{d}\"\nstate_dir = \"{d}\"\naccess_log = \"{d}/a.log\"\ncaddy_credentials_dir = \"{d}\"\n",
st = s(&dir.join("state")),
repo = s(&dir.join("routes.git")),
d = s(dir.path()),
h = free_port(),
hs = free_port(),
);
std::fs::write(dir.join("control.toml"), text).unwrap();
let cfg = Config::load(&dir.join("control.toml")).unwrap();
let (_, tok) = Tokens::new(&dir.join("state"))
.create("fabrica", None, Scope::Previews)
.unwrap();
let (tx, rx) = tokio::sync::oneshot::channel::<()>();
tokio::spawn(ianitor_control::serve(cfg, async {
let _ = rx.await;
}));
assert!(wait_for_port(api, Duration::from_secs(20)));
(dir, api, tok, tx)
};
let auth = format!("Bearer {}", c2.2);
let r = tcp_json(
c2.1,
"POST",
"/api/v1/previews",
&[("Authorization", &auth)],
Some(&json!({"project": "shop", "branch": "main", "upstream": "http://10.0.0.5:80"})),
)
.await
.unwrap();
assert_eq!(r.status, 409, "{}", r.text);
assert_eq!(r.json["error"]["code"], "preview.off");
let _ = c2.3.send(());
}
+8 -2
View File
@@ -27,7 +27,11 @@ fn a_cli_revoke_is_not_lost_while_the_server_records_token_use() {
let d = TempDir::new("tok-race");
let server = Tokens::new(d.path());
let values: Vec<_> = (0..150)
.map(|i| server.create(&format!("t{i}"), None).unwrap())
.map(|i| {
server
.create(&format!("t{i}"), None, Default::default())
.unwrap()
})
.collect();
let victim = values[75].0.id.clone();
let mut cli = std::process::Command::new(bin)
@@ -77,7 +81,9 @@ fn concurrent_creates_from_the_cli_and_the_server_all_survive() {
})
.collect();
for i in 0..40 {
server.create(&format!("srv{i}"), None).unwrap();
server
.create(&format!("srv{i}"), None, Default::default())
.unwrap();
}
for c in &mut clis {
assert!(c.wait().unwrap().success());
+257
View File
@@ -0,0 +1,257 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
//! Team sign-in without Authelia (T4): the setup link makes the founding admin, invites make
//! members, a session cookie identifies them, members cannot do admin things, and browser
//! writes need the UI header. Runs on Windows and Linux (control in this process, no edge).
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
use std::net::SocketAddr;
use std::time::Duration;
use ianitor_control::Config;
use ianitor_control::team::Team;
use ianitor_testkit::more::{JsonResp, tcp_json};
use ianitor_testkit::proc::{TempDir, free_port, local, wait_for_port};
use serde_json::{Value, json};
fn s(p: &std::path::Path) -> String {
p.to_string_lossy().replace('\\', "/")
}
async fn start() -> (TempDir, SocketAddr, tokio::sync::oneshot::Sender<()>) {
let dir = TempDir::new("team");
std::fs::create_dir_all(dir.join("state")).unwrap();
let api = local(free_port());
let text = format!(
"listen = \"{api}\"\nstate_dir = \"{st}\"\n\n[routes]\nrepo = \"{repo}\"\n\n[edge]\nconfig = \"{d}/edge.json\"\nshare_revocations = \"{d}/rev.json\"\n\n[caddy]\nconfig = \"{d}/caddy.json\"\n\n[compile]\nhttp_listen = \"127.0.0.1:{h}\"\nhttps_listen = \"127.0.0.1:{hs}\"\ncert_dir = \"{d}\"\nstate_dir = \"{d}\"\naccess_log = \"{d}/a.log\"\ncaddy_credentials_dir = \"{d}\"\n",
st = s(&dir.join("state")),
repo = s(&dir.join("routes.git")),
d = s(dir.path()),
h = free_port(),
hs = free_port(),
);
std::fs::write(dir.join("control.toml"), text).unwrap();
let cfg = Config::load(&dir.join("control.toml")).unwrap();
let (tx, rx) = tokio::sync::oneshot::channel::<()>();
tokio::spawn(ianitor_control::serve(cfg, async {
let _ = rx.await;
}));
assert!(wait_for_port(api, Duration::from_secs(20)));
(dir, api, tx)
}
async fn req(api: SocketAddr, m: &str, p: &str, h: &[(&str, &str)], b: Option<Value>) -> JsonResp {
tcp_json(api, m, p, h, b.as_ref()).await.unwrap()
}
fn cookie_of(r: &JsonResp) -> String {
let set = r
.headers
.iter()
.find(|(n, _)| n == "set-cookie")
.map(|(_, v)| v.clone())
.expect("a Set-Cookie");
for part in ["HttpOnly", "Secure", "SameSite=Strict", "Path=/"] {
assert!(set.contains(part), "{set}");
}
assert!(set.starts_with("__Host-ianitor=ise_"), "{set}");
set.split(';').next().unwrap().to_owned()
}
async fn sign_in(api: SocketAddr, code: &str, name: &str) -> (JsonResp, String) {
let r = req(
api,
"POST",
"/api/v1/session",
&[("X-Ianitor-UI", "1"), ("Sec-Fetch-Site", "same-origin")],
Some(json!({"code": code, "name": name, "device": "Laptop"})),
)
.await;
assert_eq!(r.status, 200, "{}", r.text);
let c = cookie_of(&r);
(r, c)
}
#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
async fn a_setup_link_then_invites_sign_a_team_in() {
let (dir, api, _stop) = start().await;
let (setup, _) = Team::new(&dir.join("state")).setup_code().unwrap();
// The door refuses bad codes, other sites and pages that are not the UI.
for (headers, code) in [
(vec![("X-Ianitor-UI", "1")], "isc_wrong"),
(vec![], setup.as_str()),
(
vec![("X-Ianitor-UI", "1"), ("Sec-Fetch-Site", "cross-site")],
setup.as_str(),
),
] {
let r = req(
api,
"POST",
"/api/v1/session",
&headers,
Some(json!({"code": code})),
)
.await;
assert!(
r.status == 401 || r.status == 403,
"{headers:?}: {}",
r.text
);
assert!(!r.headers.iter().any(|(n, _)| n == "set-cookie"));
}
let (r, mark) = sign_in(api, &setup, "Mark").await;
assert_eq!(r.json["member"]["role"], "admin");
let ov = req(api, "GET", "/api/v1/overview", &[("Cookie", &mark)], None).await;
assert_eq!(ov.status, 200, "{}", ov.text);
assert_eq!(ov.json["viewer"]["via"], "session");
assert_eq!(ov.json["viewer"]["name"], "Mark");
// The setup link worked once.
let r = req(
api,
"POST",
"/api/v1/session",
&[("X-Ianitor-UI", "1")],
Some(json!({"code": setup})),
)
.await;
assert_eq!(r.status, 401, "{}", r.text);
// A browser write without the UI header is refused (CSRF), with it it works.
let r = req(
api,
"POST",
"/api/v1/team/invites",
&[("Cookie", &mark)],
Some(json!({"name": "Petra"})),
)
.await;
assert_eq!(r.status, 403, "{}", r.text);
assert_eq!(r.json["error"]["code"], "request.csrf");
let r = req(
api,
"POST",
"/api/v1/team/invites",
&[("Cookie", &mark), ("X-Ianitor-UI", "1")],
Some(json!({"name": "Petra", "role": "member"})),
)
.await;
assert_eq!(r.status, 201, "{}", r.text);
let code = r.json["link_fragment"]
.as_str()
.unwrap()
.strip_prefix("#signin=")
.unwrap()
.to_owned();
// Petra is a member: hosts yes, tokens, the team and the engine no.
let (_, petra) = sign_in(api, &code, "Not Petra").await;
let team = req(api, "GET", "/api/v1/team", &[("Cookie", &petra)], None).await;
assert_eq!(team.json["me"]["name"], "Petra", "{}", team.text);
for (m, p, b) in [
("GET", "/api/v1/tokens", None),
("POST", "/api/v1/tokens", Some(json!({"name": "x"}))),
(
"POST",
"/api/v1/team/invites",
Some(json!({"name": "Eve", "role": "admin"})),
),
("POST", "/api/v1/engine", Some(json!({"target": "caddy"}))),
] {
let r = req(api, m, p, &[("Cookie", &petra), ("X-Ianitor-UI", "1")], b).await;
assert_eq!(r.status, 403, "{m} {p}: {}", r.text);
assert_eq!(r.json["error"]["code"], "team.admin_only", "{m} {p}");
}
let r = req(
api,
"POST",
"/api/v1/hosts",
&[("Cookie", &petra), ("X-Ianitor-UI", "1")],
Some(
json!({"host": {"hostname": "wiki.example.test", "upstreams": ["http://10.0.0.2:80"]}}),
),
)
.await;
assert_eq!(r.status, 202, "{}", r.text);
// A member records their Tessera root; the list shows its match code.
let root = "BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc";
let r = req(
api,
"PUT",
"/api/v1/team/me/root",
&[("Cookie", &petra), ("X-Ianitor-UI", "1")],
Some(json!({"tessera_root": root})),
)
.await;
assert_eq!(r.status, 200, "{}", r.text);
let team = req(api, "GET", "/api/v1/team", &[("Cookie", &mark)], None).await;
let p = team.json["members"]
.as_array()
.unwrap()
.iter()
.find(|m| m["name"] == "Petra")
.unwrap()
.clone();
assert_eq!(p["match_code"], "016 810");
// Removing Petra signs her out; a forged cookie gets nothing; the last admin stays.
let id = p["id"].as_str().unwrap();
let r = req(
api,
"DELETE",
&format!("/api/v1/team/members/{id}"),
&[("Cookie", &mark), ("X-Ianitor-UI", "1")],
None,
)
.await;
assert_eq!(r.status, 200, "{}", r.text);
let r = req(api, "GET", "/api/v1/overview", &[("Cookie", &petra)], None).await;
assert_eq!(r.status, 401, "{}", r.text);
let r = req(
api,
"GET",
"/api/v1/overview",
&[("Cookie", "__Host-ianitor=ise_forged")],
None,
)
.await;
assert_eq!(r.status, 401);
let me = team.json["members"]
.as_array()
.unwrap()
.iter()
.find(|m| m["name"] == "Mark")
.unwrap()["id"]
.as_str()
.unwrap()
.to_owned();
let r = req(
api,
"DELETE",
&format!("/api/v1/team/members/{me}"),
&[("Cookie", &mark), ("X-Ianitor-UI", "1")],
None,
)
.await;
assert_eq!(r.status, 409, "{}", r.text);
assert_eq!(r.json["error"]["code"], "team.last_admin");
// Signing out ends this browser's session.
let r = req(
api,
"POST",
"/api/v1/session/end",
&[("Cookie", &mark), ("X-Ianitor-UI", "1")],
None,
)
.await;
assert_eq!(r.status, 200, "{}", r.text);
let r = req(api, "GET", "/api/v1/overview", &[("Cookie", &mark)], None).await;
assert_eq!(r.status, 401);
}
+6 -151
View File
@@ -13,12 +13,14 @@
#[cfg(unix)]
mod common;
// On Windows this target has nothing to run: it shows as one *ignored* test, never as a
// pass (ROADMAP §8.3; run it in WSL2, see CLAUDE.md).
#[cfg(not(unix))]
#[test]
#[ignore = "needs Linux: run it in WSL2, see CLAUDE.md"]
fn needs_linux() {}
fn skipped_on_windows() {
eprintln!(
"SKIPPED on Windows: {} needs Linux; run it in WSL2",
file!()
);
}
#[cfg(unix)]
mod unix {
@@ -238,153 +240,6 @@ mod unix {
);
}
// ---------------------------------------------------------------- G14 option b (phase 4)
/// Control with `[ui] socket`: the UI comes in on a Unix socket in a directory only the
/// ianitor group can use; the loopback port stays for API tokens (scripts, the CLI).
async fn socket_env(site: String, ui_host: &str) -> (Env, std::path::PathBuf) {
let mut env = Env::new(EnvSpec {
site,
..Default::default()
})
.await;
std::fs::write(
env.dir.join("creds/ui-proof"),
format!(
"{PROOF}
"
),
)
.unwrap();
let sock = env.dir.join("ui.sock");
let text = std::fs::read_to_string(env.config_path()).unwrap()
+ &format!(
"
[ui]
hostname = \"{ui_host}\"
proof_credential = \"ui-proof\"
socket = \"{}\"
",
sock.display()
);
std::fs::write(env.config_path(), text).unwrap();
env.start_control(None);
for _ in 0..100 {
if sock.exists() {
break;
}
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
}
assert!(
sock.exists(),
"no UI socket:
{}",
env.control_log()
);
(env, sock)
}
async fn over_socket(sock: &std::path::Path, headers: &[(&str, &str)]) -> (u16, String) {
let mut req = Req::get("ui.test", "/api/v1/overview");
for (n, v) in headers {
req = req.header(n, v);
}
let r = client::unix(sock, &req).await.unwrap();
(r.status, r.text())
}
/// The per-boot proof alone no longer signs anyone in: off the socket it is refused even
/// when it is right, so a local process that learned it (say, by listening on control's
/// port while control restarted) gets nothing; on the socket, which only edge and Caddy
/// (group ianitor) can open, it works as before.
#[tokio::test(flavor = "multi_thread")]
async fn with_a_ui_socket_the_proof_counts_only_on_the_socket() {
use std::os::unix::fs::PermissionsExt;
let (env, sock) = socket_env(String::new(), "ui.test").await;
let mode = std::fs::metadata(&sock).unwrap().permissions().mode() & 0o777;
assert_eq!(mode, 0o660, "owner and group only");
let signed = [("Remote-User", "mark"), ("X-Ianitor-Proof", PROOF)];
let r = env
.call_with("GET", "/api/v1/overview", &signed, None)
.await;
assert_eq!(r.status, 401, "the right proof over TCP: {}", r.text);
assert_eq!(r.json["error"]["code"], "ui.no_proof", "{}", r.text);
assert!(!env.control_log().contains("by mark"));
let (status, text) = over_socket(&sock, &signed).await;
assert_eq!(status, 200, "{text}");
// The socket does not replace the proof: without it, a Remote-User is still refused.
let (status, text) = over_socket(&sock, &[("Remote-User", "mark")]).await;
assert_eq!(status, 401, "{text}");
let (status, text) = over_socket(
&sock,
&[("Remote-User", "mark"), ("X-Ianitor-Proof", "guess")],
)
.await;
assert_eq!(status, 401, "{text}");
// API tokens keep working on the loopback port.
let r = env.call("GET", "/api/v1/overview", None).await;
assert_eq!(r.status, 200, "{}", r.text);
}
/// A route file may name a socket only for the admin host, and only control's own.
#[tokio::test(flavor = "multi_thread")]
async fn a_socket_upstream_is_only_for_the_admin_host_and_controls_own_socket() {
let auth = MockAuthelia::start().await;
let site = format!(
"secrets = [\"ui-proof\"]
[forward_auth]
url = \"{}\"
",
auth.url()
);
let (env, sock) = socket_env(site, "a.test").await;
for (hostname, upstream) in [
("b.test", format!("unix:{}", sock.display())),
("a.test", "unix:/run/docker.sock".to_owned()),
] {
let host = json!({"host": {
"hostname": hostname, "upstreams": [upstream],
"tls": "domi", "auth": "forward-auth",
}});
let r = env.call("POST", "/api/v1/hosts", Some(host)).await;
assert_eq!(r.status, 422, "{hostname} {upstream}: {}", r.text);
assert_eq!(
r.json["errors"][0]["code"], "host.upstream.unix_socket",
"{}",
r.text
);
}
// The admin host on control's socket: through edge, Authelia decides, the UI gets in.
let host = json!({"host": {
"hostname": "a.test", "upstreams": [format!("unix:{}", sock.display())],
"tls": "domi", "auth": "forward-auth",
"request_headers": [{"action": "set", "name": "X-Ianitor-Proof", "secret": "ui-proof"}]
}});
let rec = env.apply("POST", "/api/v1/hosts", Some(host)).await;
assert_eq!(
rec["state"],
"kept",
"{rec}
{}",
env.control_log()
);
let edge = env.edge.as_ref().unwrap();
let r = client::https(
edge.https,
"a.test",
env.ca.roots(),
&Req::get("a.test", "/api/v1/overview").header("cookie", "authelia_session=good"),
)
.await
.unwrap();
assert_eq!(r.status, 200, "{}", r.text());
assert!(r.text().contains("\"hosts\""), "{}", r.text());
}
/// QC: signed in at Authelia (alice) but the client also sends a proof guess: edge must
/// replace, not append, the proof; and Remote-User must be Authelia's.
#[tokio::test(flavor = "multi_thread")]
+5 -31
View File
@@ -19,7 +19,6 @@ use crate::{
const ACCESS_LOGGER: &str = "ianitor_access";
const HTTPS_SERVER: &str = "ianitor_https";
const HTTP_SERVER: &str = "ianitor_http";
const PROXY_SERVER: &str = "ianitor_proxy";
pub(super) fn compile(model: &Model, o: &CompileOptions) -> Value {
let hosts = model.hosts();
@@ -78,23 +77,6 @@ pub(super) fn compile(model: &Model, o: &CompileOptions) -> Value {
.collect();
policies.push(json!({}));
// ---- The front proxy's socket: the same routes in plain HTTP, its peer trusted (edge:
// `client_ip` on the socket). No TLS here, so no certificates are managed for it.
let mut proxy = o.proxy_socket.as_ref().map(|sock| {
let mut p = Map::new();
p.insert(
"listen".into(),
json!([format!("unix//{}|0660", sock.trim_start_matches('/'))]),
);
p.insert("routes".into(), Value::Array(routes.clone()));
p.insert("automatic_https".into(), json!({ "disable": true }));
p.insert("protocols".into(), json!(["h1"]));
p.insert("trusted_proxies_unix".into(), json!(true));
p.insert("client_ip_headers".into(), json!(["X-Forwarded-For"]));
p.insert("trusted_proxies_strict".into(), json!(1));
p
});
let mut https = Map::new();
https.insert("listen".into(), json!([o.https_listen.to_string()]));
https.insert("routes".into(), Value::Array(routes));
@@ -124,11 +106,10 @@ pub(super) fn compile(model: &Model, o: &CompileOptions) -> Value {
.iter()
.map(|h| (h.hostname.to_string(), json!([ACCESS_LOGGER])))
.collect();
let logs = json!({ "logger_names": names, "skip_unmapped_hosts": true });
if let Some(p) = proxy.as_mut() {
p.insert("logs".into(), logs.clone());
}
https.insert("logs".into(), logs);
https.insert(
"logs".into(),
json!({ "logger_names": names, "skip_unmapped_hosts": true }),
);
}
// ---- HTTP server: redirect known hosts to HTTPS (ACME HTTP-01 is answered by Caddy itself).
@@ -161,9 +142,6 @@ pub(super) fn compile(model: &Model, o: &CompileOptions) -> Value {
let mut servers = Map::new();
servers.insert(HTTPS_SERVER.into(), Value::Object(https));
servers.insert(HTTP_SERVER.into(), http);
if let Some(p) = proxy {
servers.insert(PROXY_SERVER.into(), Value::Object(p));
}
let mut tls = Map::new();
if !domi.is_empty() {
@@ -281,11 +259,7 @@ fn host_route(h: &Host, fa: Option<&ForwardAuth>, o: &CompileOptions) -> Value {
fn upstreams(list: &[&Upstream]) -> Value {
Value::Array(
list.iter()
.map(|u| match u.unix_path() {
// Caddy's network address: `unix/` then the absolute path.
Some(p) => json!({ "dial": format!("unix/{p}") }),
None => json!({ "dial": u.authority() }),
})
.map(|u| json!({ "dial": u.authority() }))
.collect(),
)
}
-1
View File
@@ -35,7 +35,6 @@ pub(super) fn compile(model: &Model, o: &CompileOptions) -> EdgeConfig {
allow: join(&o.cert_dir, DEVICE_ALLOW_FILE),
}),
trusted_proxies: o.trusted_proxies.iter().map(ToString::to_string).collect(),
proxy_socket: o.proxy_socket.clone(),
forward_auth: site.forward_auth.as_ref().map(|fa| EdgeForwardAuth {
upstream: upstream(&fa.upstream),
path_and_query: fa.path_and_query.clone(),
+19 -19
View File
@@ -48,10 +48,6 @@ pub struct CompileOptions {
/// Ianitor on loopback): the share-link throttle and the access log then see the real
/// client. Empty (the default): only the connection's own address counts.
pub trusted_proxies: Vec<std::net::IpAddr>,
/// A Unix socket (mode 0660) on which the engine also serves the HTTPS hosts, in plain HTTP,
/// to a front proxy that terminated TLS (Caddy beside Ianitor). Only the socket's owner and
/// group can connect, so its peer is trusted and its `X-Forwarded-For` names the client.
pub proxy_socket: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
@@ -84,19 +80,6 @@ pub fn caddy(model: &Model, options: &CompileOptions) -> Result<String, CompileE
}
fn check_options(o: &CompileOptions) -> Result<(), CompileError> {
if let Some(s) = &o.proxy_socket {
check_path(s).map_err(|reason| CompileError::BadOption {
option: "proxy_socket",
reason,
})?;
// sun_path holds 108 bytes on Linux, the terminating NUL included.
if s.len() > 100 {
return Err(CompileError::BadOption {
option: "proxy_socket",
reason: "a socket path is at most 100 characters",
});
}
}
if let Some(s) = &o.caddy_admin_socket {
check_path(s).map_err(|reason| CompileError::BadOption {
option: "caddy_admin_socket",
@@ -126,9 +109,13 @@ fn check_options(o: &CompileOptions) -> Result<(), CompileError> {
Ok(())
}
/// Paths end up inside JSON strings and Caddy `{file.*}` placeholders.
/// Paths end up inside JSON strings and Caddy `{file.*}` placeholders. Absolute: `/…` on
/// Linux, or a drive path with forward slashes on Windows (`C:/ProgramData/Ianitor/…`, which
/// Caddy and Go read as is; control writes backslashes as `/`, see [`windows_path`]).
fn check_path(p: &str) -> Result<(), &'static str> {
if !p.starts_with('/') {
let drive =
p.len() >= 3 && p.as_bytes()[0].is_ascii_alphabetic() && &p.as_bytes()[1..3] == b":/";
if !p.starts_with('/') && !drive {
return Err("it must be an absolute path");
}
if p.len() > 1024 {
@@ -143,6 +130,19 @@ fn check_path(p: &str) -> Result<(), &'static str> {
Ok(())
}
/// A Windows path as the compilers take it: `C:\ProgramData\Ianitor` → `C:/ProgramData/Ianitor`.
/// Anything that is not a drive path is returned unchanged (and a Linux path with a backslash
/// is still refused by the option check).
pub fn windows_path(p: &str) -> String {
let b = p.as_bytes();
if b.len() >= 3 && b[0].is_ascii_alphabetic() && b[1] == b':' && (b[2] == b'\\' || b[2] == b'/')
{
p.replace('\\', "/")
} else {
p.to_owned()
}
}
/// Identity headers never accepted from clients on forward-auth hosts: Authelia's four, then
/// any other configured copy header (case-insensitive, no duplicates).
fn strip_headers(fa: &crate::ForwardAuth) -> Vec<String> {
-4
View File
@@ -34,10 +34,6 @@ pub struct EdgeConfig {
/// Peers whose `X-Forwarded-For` is believed (IP addresses); empty: none.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub trusted_proxies: Vec<String>,
/// A Unix socket (mode 0660) serving the HTTPS hosts in plain HTTP to a front proxy that
/// terminated TLS; its peer is trusted (`X-Forwarded-For` names the client).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub proxy_socket: Option<String>,
/// Sorted by hostname.
pub hosts: Vec<EdgeHost>,
}
+6 -3
View File
@@ -34,7 +34,6 @@ pub(crate) mod reason {
pub const URL_CREDENTIALS: &str = "credentials in the URL are not allowed";
pub const URL_FRAGMENT: &str = "a #fragment is not allowed";
pub const URL_NO_HOST: &str = "it has no host";
pub const URL_UNIX_PATH: &str = "a socket upstream is unix:/absolute/path: letters, digits, '.', '_', '-' and single '/' only, no '.' or '..' parts, at most 100 characters";
pub const URL_HOST_NAME: &str = "the host name is not valid";
pub const URL_NO_PORT: &str = "it has no port";
pub const URL_PORT_ZERO: &str = "port 0 is not usable";
@@ -179,6 +178,8 @@ pub enum ValidationError {
BadForwardAuth { file: String, reason: &'static str },
#[error("{file}: acme is not usable: {reason}")]
BadAcme { file: String, reason: &'static str },
#[error("{file}: the preview is not usable: {reason}")]
BadPreview { file: String, reason: String },
}
fn line_suffix(line: Option<usize>) -> String {
@@ -218,7 +219,8 @@ impl ValidationError {
| E::ForwardAuthNotConfigured { file }
| E::ProofWithoutSignIn { file }
| E::BadForwardAuth { file, .. }
| E::BadAcme { file, .. } => file,
| E::BadAcme { file, .. }
| E::BadPreview { file, .. } => file,
E::DuplicateHostname { second, .. } => second,
}
}
@@ -276,7 +278,6 @@ impl ValidationError {
x if x == r::URL_PATH => "host.upstream.path",
x if x == r::URL_QUERY => "host.upstream.query",
x if x == r::URL_MIXED => "host.upstream.mixed_schemes",
x if x == r::URL_UNIX_PATH => "host.upstream.unix_path",
_ => "host.upstream.not_url",
},
E::DuplicateUpstream { .. } => "host.upstream.duplicate",
@@ -306,6 +307,7 @@ impl ValidationError {
E::ProofWithoutSignIn { .. } => "host.header.proof",
E::BadForwardAuth { .. } => "site.forward_auth",
E::BadAcme { .. } => "site.acme",
E::BadPreview { .. } => "host.preview",
}
}
@@ -340,6 +342,7 @@ impl ValidationError {
E::BadHealthCheck { .. } => Some("health_check.path".into()),
E::ForwardAuthNotConfigured { .. } => Some("auth".into()),
E::ProofWithoutSignIn { .. } => Some("auth".into()),
E::BadPreview { .. } => Some("preview".into()),
_ => None,
}
}

Some files were not shown because too many files have changed in this diff Show More