carlos / platform Public

edge PPv2: count idle trusted connections apart from timeout

The dev IE cutover (2026-11-17) showed the NLB sends its PROXY header with
the client's first bytes. In S2 an idle client connection (a browser
preconnect) reached the 10 s header deadline and counted as timeout, a
counter every B step must keep still, so B steps could not converge on
real traffic.

- proxyproto: a trusted connection with no byte by the deadline counts
  idle; a started header still counts timeout. Absence is checked with a
  deadline-free MSG_PEEK (queuedBytes); when it cannot tell, it counts
  timeout. Non-unix builds never count idle.
- edge journal line and trust-status carry idle. trust-status prints it
  only when the running edge reports it; the wire wants it everywhere or
  nowhere.
- ppv2-step.py: idle is optional in a status line and never in STILL; a
  B step refuses a target whose edge does not report idle.
- Runbook and spec 4.5 (rev 5.2): idle, and reverify after a B step whose
  first probes fell inside the ~70 s propagation.

Astra rounds 1 (1 P1, 2 P2, fixed) and 2 (READY); census approved on #280.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from edge-ppv2-idle into main.
claude agent, operated by paul@keymail.dev 0acb276759d98d8a4256f18fa1567778c5d40289 parent 8c86134
24 files changed, +687 −51
  • docs/region-ha-runbook.md +4 −2
  • docs/superpowers/notes/census-claims-edge-ppv2-idle.tsv +2 −0
  • docs/superpowers/notes/census-proposal-edge-ppv2-idle.md +23 −0
  • docs/superpowers/reviews/ASTRA-FINDINGS-edge-ppv2-idle-R1.md +38 −0
  • docs/superpowers/reviews/ASTRA-FINDINGS-edge-ppv2-idle-R2.md +30 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-edge-ppv2-idle-R2.md +56 −0
  • docs/superpowers/reviews/CODEX-REVIEW-BRIEF-edge-ppv2-idle.md +46 −0
  • docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md +3 −1
  • internal/edge/proxyingress.go +3 −2
  • internal/edge/proxyingress_test.go +1 −1
  • internal/host/edgetrust.go +59 −6
  • internal/host/edgetrust_linux_test.go +4 −4
  • internal/host/edgetrust_test.go +87 −7
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-edge-ppv2-idle.tsv +10 −0
  • internal/proxyproto/conn.go +32 −1
  • internal/proxyproto/counters.go +10 −1
  • internal/proxyproto/listener_test.go +42 −5
  • internal/proxyproto/peek_other.go +9 −0
  • internal/proxyproto/peek_unix.go +46 −0
  • internal/proxyproto/peek_unix_test.go +68 −0
  • scripts/ppv2-step.py +28 −8
  • scripts/ppv2_step_test.py +72 −0
  • scripts/testdata/ppv2/trust-status.json +13 −13

CI cancelled — superseded by a newer push — run details

landed from edge-ppv2-idle

diff --git a/docs/region-ha-runbook.md b/docs/region-ha-runbook.md
index b36721505..083335413 100644
--- a/docs/region-ha-runbook.md
+++ b/docs/region-ha-runbook.md
@@ -422,6 +422,8 @@ Exit codes: 0 done or passed, 1 refused or failed, 2 invalid arguments, 130 inte
A B step converges only on its own port's traffic: every node's `proxied` count must rise on that listener (`by_listener` in trust-status). After B80, `:80` traffic does not count for B443.
+A B step takes about 70 s to reach every node, and the probe cannot tell S1 from S2, so probes started at once can pass while most of their connections still arrive in S1. Then a target may show no `proxied` rise from one node, and the step fails with "proxied on :<port> from node <address> did not rise". That is not a fault: run `reverify` for the step with fresh probes. On dev IE on 2026-11-17 both B80 and B443 passed this way on their first reverify.
+
A restart of any target's edge during the window fails the step. The tool sees it as a new `edge_instance` in trust-status, or as any counter lower than at the poll before. Counters start from zero after a restart, so the window cannot prove what happened in between. Run `reverify` once the box is back.
If the run is interrupted, or a convergence fails, or one `aws` call is slow enough to leave more than 15 s between health observations, the window fails. Use `reverify`, not `converge`. It opens a fresh window for a step already made (A steps cannot be undone) with new probes and new record paths:
@@ -438,7 +440,7 @@ python3 scripts/ppv2-step.py reverify --root <tofu root> --nlb-arn <nlb> \
B steps refuse while any barrier is up. A steps, R steps and `reverify` of an A step do not.
-Watch item for the dev window: if the NLB sends its PROXY header only with the client's first bytes, an idle connection (a browser preconnect that never sends a request) reaches the 10 s header deadline and moves `timeout`. `timeout` must not move during a step, so B steps would never converge. Row 2 of the dev witness shows which way the NLB behaves. If `timeout` moves on idle preconnects, stop and report before B80.
+The NLB sends its PROXY header with the client's first bytes, not when the connection opens (seen on dev IE on 2026-11-17). So in S2 a connection whose client never sends anything, such as a browser preconnect, is closed at the 10 s header deadline, just as an idle direct connection is closed by the server's own 10 s header timeout. The edge counts these as `idle`, not `timeout`. `idle` is ordinary traffic and may rise during any step; `timeout` counts only a header that started and did not finish, and must not move. An edge from before the `idle` counter counts these as `timeout` instead, so run B steps only once every target reports `idle`.
### Rollback
@@ -462,7 +464,7 @@ Run this if the trust-violation alarm fires, or the probe or a target's counters
7. Continue with the B steps, in a window.
8. Report to 8a3d302 with the alarm, the counters and the barrier's close counts.
-To read a target at any time, `carlos system edge trust-status` prints one JSON line with `armed`, `barrier`, `edge_instance` (a random id the edge sets when it starts), the counters and `proxied_by_node` for both listeners together, and `by_listener` with each listener's own, under `"80"` and `"443"`. The three verbs exit 0 on success, 1 when refused or failed, 2 for bad arguments or a box not armed.
+To read a target at any time, `carlos system edge trust-status` prints one JSON line with `armed`, `barrier`, `edge_instance` (a random id the edge sets when it starts), the counters (`proxied`, `no_client`, `no_client_refused`, `ignored`, `ignored_private`, `marker_trusted`, `malformed`, `timeout` and `idle`) and `proxied_by_node` for both listeners together, and `by_listener` with each listener's own, under `"80"` and `"443"`. The three verbs exit 0 on success, 1 when refused or failed, 2 for bad arguments or a box not armed.
Notes from the reviews:
diff --git a/docs/superpowers/notes/census-claims-edge-ppv2-idle.tsv b/docs/superpowers/notes/census-claims-edge-ppv2-idle.tsv
new file mode 100644
index 000000000..8952c4e9a
--- /dev/null
+++ b/docs/superpowers/notes/census-claims-edge-ppv2-idle.tsv
@@ -0,0 +1,2 @@
+internal/proxyproto/conn.go:Conn.parse A trusted connection whose header read times out with no byte read, and sentAnything finds no byte either, closes and counts idle instead of timeout. Same close, same state (failed); no new read beyond sentAnything. Edge (uid carlos), not root.
+internal/proxyproto/peek_unix.go:queuedBytes New. One recv(MSG_PEEK|MSG_DONTWAIT) of one byte on the already accepted socket through syscall.RawConn, never waiting; consumes nothing. No file, no path, nothing run; known=false on any unexpected error. Edge (uid carlos), not root.
diff --git a/docs/superpowers/notes/census-proposal-edge-ppv2-idle.md b/docs/superpowers/notes/census-proposal-edge-ppv2-idle.md
new file mode 100644
index 000000000..f4d6fac3f
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-edge-ppv2-idle.md
@@ -0,0 +1,23 @@
+# Census approval: edge-ppv2-idle
+
+Ruling `census-ruling-edge-ppv2-idle`. The independent reviewer approves or rejects every change below, 1 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+| unit | change | read sites | what changed |
+|---|---|---|---|
+| `internal/proxyproto/conn.go` `Conn.parse` | body | unchanged (1) | A trusted connection whose header read times out with no byte read, and sentAnything finds no byte either, closes and counts idle instead of timeout. Same close, same state (failed); no new read beyond sentAnything. Edge (uid carlos), not root. |
+
+Envelopes re-pinned: `internal/edge`, `internal/host`, `internal/proxyproto`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Recorded dispositions, which each change must still satisfy:
+
+- `internal/proxyproto/conn.go` `Conn.parse`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-edge-ppv2;basis=Edge (uid carlos), not root. Detects the signature, reads at most one header with ReadHeader (under the header deadline on a trusted peer), and resolves the connection's state (an untrusted peer: plain, or failed on a malformed header; a trusted one: proxied, no client or failed), consulting the barrier flag when it resolves. The scanner's +file:Command is the comparison h.Command != CommandProxy (the header's command nibble), not a process; no file, nothing run.
+
+New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
+
+- new `internal/proxyproto/peek_unix.go:queuedBytes`: reads +file:Read; written legacy, accepted-legacy, frozen
+
+Seal: `c6d366dcf2211b714977b7a69180289555b362dfe5f36a5780af90b5ece82998` → `5d4a5eea79394145fdd59aa5eb87115cc1ee396e02e0ab4b21decd2b3a10e3b4`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-edge-ppv2-idle.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/reviews/ASTRA-FINDINGS-edge-ppv2-idle-R1.md b/docs/superpowers/reviews/ASTRA-FINDINGS-edge-ppv2-idle-R1.md
new file mode 100644
index 000000000..224e99743
--- /dev/null
+++ b/docs/superpowers/reviews/ASTRA-FINDINGS-edge-ppv2-idle-R1.md
@@ -0,0 +1,38 @@
+Reviewed round 1 at `12671563b6c449b04149bc5c06a111a2b0254013`, against merge base `03ff5d17`.
+
+1. **P1 — Sections 3–4: the CLI defeats the old-edge B-step refusal.**
+ [`counters()`](internal/host/edgetrust.go:193) converts absent `idle` to zero. [`trustStatusLine()`](internal/host/edgetrust.go:573) then serializes it through the unconditional [`json:"idle"` field](internal/host/edgetrust.go:114). After binary adoption, while the older edge still runs, the CLI therefore advertises `idle: 0`. The [B-step check](scripts/ppv2-step.py:767) accepts that target for both apply and reverify, although idle connections still increment `timeout`.
+
+ **Fix:** preserve absence through CLI serialization, while continuing to accept older answers. Test an older socket response through the command’s actual JSON output and then the B-step check. The current tests exercise those halves separately and miss this conversion.
+ **Fault family:** capability evidence must describe the running edge, not the querying binary.
+
+2. **P2 — Sections 1 and 6: the 5 ms probe can misclassify queued header bytes as idle.**
+ [`sentAnything()`](internal/proxyproto/conn.go:361) installs another short deadline, then reads. If the goroutine is descheduled past that deadline, Go can return a timeout before inspecting the socket—even with header bytes queued. The local runtime checks the deadline [before its socket read](/home/paulca/.local/go-dist/src/internal/poll/fd_unix.go:154). `sentAnything()` discards that error and returns false, causing [`parse()`](internal/proxyproto/conn.go:257) to count `idle`.
+
+ This recreates the late-parse problem the helper intends to solve and makes `TestTrustedHeaderDeadlineFromAccept` vulnerable under load.
+ **Fix:** use a deadline-independent, nonblocking check for queued bytes, with conservative handling of errors. Add a deterministic test that pauses beyond the probe deadline with bytes already queued; increasing 5 ms only reduces the likelihood.
+ **Fault family:** absence of bytes must be established independently of scheduling delay.
+
+3. **P2 — Section 3: mixed idle presence passes Go validation.**
+ [`statusShape()`](internal/host/edgetrust.go:243) sums counters after missing values become zero. For example, total `idle: 5`, listener 443 `idle: 5`, and listener 80 with no `idle` passes. The CLI supplies the missing zero, hiding the inconsistency from Python’s stricter parser.
+
+ **Fix:** require `idle` everywhere or nowhere before conversion; retain acceptance of wholly older answers. Add mixed-presence cases, including zero-valued counters.
+ **Fault family:** counter presence and snapshot completeness.
+
+No P3 findings.
+
+Both timeout branches close the socket before the deferred deadline restoration. `Close` and `CloseTrusted` remain independent of the parse lock. Untrusted connections cannot enter the idle branch. The marker and no-client refusal paths, `STILL`, and the S3 metric remain unchanged. Restart detection includes idle decreases. The documentation’s old-edge refusal claim is not fulfilled because of finding 1.
+
+The three new Python test bodies passed through `unittest.FunctionTestCase`, bypassing their unused temporary-directory setup. Two failed against the base implementation; the idle-movement case preserves existing behavior. Standard Python execution and targeted Go tests were blocked by the read-only filesystem before test execution. No files changed.
+
+Census verdicts concern root authority; these approvals do not clear the functional findings above:
+
+| Unit or envelope | Verdict and evidence |
+|---|---|
+| `Conn.parse` | **Approve.** [Lines 243–313](internal/proxyproto/conn.go:243): classification changes; trust, marker and barrier checks remain. |
+| `Conn.sentAnything` | **Approve.** [Lines 354–378](internal/proxyproto/conn.go:354): reads one byte from the existing edge socket, then closes; no new root path or execution authority. `accepted-legacy` remains appropriate. |
+| `internal/edge` | **Approve.** [Sum](internal/edge/proxyingress.go:332) and [journal](internal/edge/proxyingress.go:407) only propagate the counter. |
+| `internal/host` | **Approve.** [Conversion and validation](internal/host/edgetrust.go:193), [root command handling](internal/host/edgetrust.go:534), and [serialization](internal/host/edgetrust.go:573) grant no root authority based on idle. Findings 1 and 3 remain required fixes. |
+| `internal/proxyproto` | **Approve.** [Parse and close paths](internal/proxyproto/conn.go:243) and [atomic snapshot](internal/proxyproto/counters.go:69) add no root-controlled resource access. Finding 2 remains required. |
+
+**NOT READY**
\ No newline at end of file
diff --git a/docs/superpowers/reviews/ASTRA-FINDINGS-edge-ppv2-idle-R2.md b/docs/superpowers/reviews/ASTRA-FINDINGS-edge-ppv2-idle-R2.md
new file mode 100644
index 000000000..f3b593c3f
--- /dev/null
+++ b/docs/superpowers/reviews/ASTRA-FINDINGS-edge-ppv2-idle-R2.md
@@ -0,0 +1,30 @@
+R1 findings:
+
+- **P1 — resolved:** missing `idle` remains absent through CLI serialization; B-step baselines reject older edges. [Conversion](internal/host/edgetrust.go:196), [serialization](internal/host/edgetrust.go:617), [refusal](scripts/ppv2-step.py:767).
+- **P2, late parse — resolved:** the 5 ms read is replaced with a nonblocking peek. Unknown results conservatively count as timeout. [Deadline handling](internal/proxyproto/conn.go:360), [peek](internal/proxyproto/peek_unix.go:19).
+- **P2, mixed presence — resolved:** validation requires `idle` everywhere or nowhere and compares sums by value, including presence. [Validation](internal/host/edgetrust.go:242).
+
+Reviewed `03ff5d17..23f5bdad079948cab4c99f4c227bfd1b1098bc1e`. No outstanding or new P1, P2 or P3 findings.
+
+The idle branch requires a trusted peer, zero consumed bytes, a timeout and confirmed absence of queued bytes. Started headers and queued late headers remain failures counted as timeout. Both probe outcomes close the connection before deferred deadline restoration. The peek consumes nothing, never waits for readiness, and safely handles concurrent closure. Untrusted connections cannot enter the idle branch; marker checks, the barrier and the S3 metric remain unchanged.
+
+The B-step refusal is reached by both [apply](scripts/ppv2-step.py:898) and [reverify](scripts/ppv2-step.py:848). A and R steps retain their exceptions. Restart detection includes idle decreases; `STILL` and S3 checks are unchanged. The runbook and spec amendments agree with these paths.
+
+The three new Python test bodies passed using `FunctionTestCase`, bypassing unused temporary-directory setup. Against the base implementation, the optional-counter and old-edge-refusal cases failed as expected; idle movement already passed. Additional checks passed for all eight presence combinations and idle reset/disappearance.
+
+Go tests and ordinary Python test setup were blocked before execution by the read-only filesystem. Static inspection confirms that the idle test distinguishes the new behavior; partial-header and untrusted-silence tests protect existing behavior. The 5 ms scheduling hazard is removed. The Go tests retain one-second completion bounds that can fail under extreme scheduling delays; runtime timing behavior remains unverified here.
+
+Census verdicts:
+
+| Unit or envelope | Verdict and evidence |
+|---|---|
+| `Conn.parse` | **Approve.** [Lines 243–313](internal/proxyproto/conn.go:243): classification changes only; trust, marker and barrier checks remain. |
+| `Conn.sentAnything` | **Approve.** [Lines 354–379](internal/proxyproto/conn.go:354): checks the existing socket, then closes; no new root path or execution authority. |
+| `queuedBytes` | **Approve, accepted-legacy.** [Lines 19–46](internal/proxyproto/peek_unix.go:19): peeks one byte from the accepted socket through `RawConn`; no path lookup or execution. |
+| `internal/edge` | **Approve.** [Sum](internal/edge/proxyingress.go:332) and [journal](internal/edge/proxyingress.go:407) propagate the counter without changing authority. |
+| `internal/host` | **Approve.** [Conversion and validation](internal/host/edgetrust.go:196), [snapshot](internal/host/edgetrust.go:378), and [root handling](internal/host/edgetrust.go:577): absence is preserved; idle grants no root authority. |
+| `internal/proxyproto` | **Approve.** The parse, peek and close paths above, plus the [atomic snapshot](internal/proxyproto/counters.go:69), introduce no new root-controlled resource access. |
+
+No files changed, subagents spawned or full suites run.
+
+**READY**
\ No newline at end of file
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-edge-ppv2-idle-R2.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-edge-ppv2-idle-R2.md
new file mode 100644
index 000000000..d8af07ee1
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-edge-ppv2-idle-R2.md
@@ -0,0 +1,56 @@
+# Review brief: branch edge-ppv2-idle (edge PPv2 idle counter), round 2 of 3
+
+Repo carlos/platform, branch `edge-ppv2-idle`, commit f007fe65 (tip; the round 1 fixes are commit f007fe65 on top of 12671563).
+Under review: the diff `origin/main..f007fe65` (base 03ff5d17).
+Authorities: `docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md` (rev 5.1 on main; this branch adds a rev 5.2 note in section 4.5), `docs/region-ha-runbook.md` section "PROXY protocol v2 on the region NLBs", both on main.
+
+You are an independent reviewer. Read the diff, then the code it touches, and check every claim against that code.
+
+## Background
+
+On 2026-11-17 the dev IE NLB cutover showed that the AWS NLB sends its PROXY protocol v2 header with the client's first bytes, not at connect. In S2 (preservation off, PPv2 on) an idle client connection (a browser preconnect) is trusted, waits for a header, reaches the 10 s header deadline and was counted `timeout`. Eight deliberate idle connections moved `timeout` by exactly 8. `timeout` is in `scripts/ppv2-step.py`'s STILL set, so B steps could not converge on a deployment with real browsers.
+
+The change: a trusted connection that sends no byte before the header deadline is counted `idle`, not `timeout`; a started header still counts `timeout`. `idle` is carried through the edge sum, the journal line, `trust-status` and its wire form (optional only for an older edge), and the step script (optional in a status line, never in STILL; a B step refuses a target whose edge does not report it).
+
+## Fixed: do not re-argue
+
+- 8a3d302's ruling (2026-11-17): an idle counter for "no bytes before the header deadline", outside the step script's must-stay-still set; `timeout` stays for a partial header; runbook updated.
+- The header deadline itself, the trust rule, the barrier and the S3 signals (`marker_trusted`, `no_client_refused`) are unchanged and out of scope except where this diff touches them.
+
+## What to check
+
+1. `internal/proxyproto/conn.go` `parse` and `sentAnything`: can anything that is a real header problem (a started header, a malformed one, a marker, a header that arrived after a late parse start, see `TestTrustedHeaderDeadlineFromAccept`) now be counted `idle` instead of `timeout`, `malformed` or `marker_trusted`? Can `sentAnything`'s extra 1-byte read with a 5 ms deadline block, race with `Close`, the barrier sweep (`CloseTrusted`), or the deferred `endHeaderDeadline`, or leave a deadline set on a connection that is handed back to the server? The connection is closed right after in both branches; verify that.
+2. Could an attacker on an untrusted path, or a client behind the NLB, use the idle path to hide anything the S3 detection (spec 6.4, 6.5) relies on? The trust-violation metric is `no_client_refused` + `marker_trusted` only.
+3. `internal/host/edgetrust.go`: `idle` is the one counter allowed absent on the wire (presence-aware parsing everywhere else). Check `counters()`, `add()`, `statusShape` and `validTrust` for any way an absent or inconsistent `idle` lets a malformed answer through, or makes a valid answer from an older edge refused. Root reads this answer through the drain call child; check that nothing root decides depends on `idle`.
+4. `scripts/ppv2-step.py`: `counter_keys`, `counts_ok`, `parse_trust`, `counts_of` and the new refusal in `collect_baseline`. Can a status line mixing idle-present and idle-absent parts pass? Does the restart detection (`restart_reasons`) still catch a reset? Is the B-step refusal reached for `apply` and for `reverify` of a B step, and not for A or R steps? Is anything in STILL or the S3 checks weakened?
+5. The census overlay (`internal/provision/testdata/plan14-root-reads-edge-ppv2-idle.tsv`, card `docs/superpowers/notes/census-proposal-edge-ppv2-idle.md`): give a verdict for `Conn.parse` (body) and the new `Conn.sentAnything`, and for the re-pinned envelopes `internal/edge`, `internal/host`, `internal/proxyproto`, under the rules in AGENTS.md "The census: the reviewer decides".
+6. Tests: do the new tests (`TestTrustedIdleBeforeHeader`, `TestTrustedHeaderTimeoutPartialSignature`, `TestUntrustedSilentIsNotIdle`, `TestTrustStatusIdleOptional`, the three new `ppv2_step_test.py` cases) actually fail without the change? Any timing flake risk under CI load (50 ms deadlines, the 5 ms read)?
+7. The runbook and spec text: anything wrong against the code.
+
+## Round 2
+
+Earlier rounds: round 1, `docs/superpowers/reviews/ASTRA-FINDINGS-edge-ppv2-idle-R1.md` (Astra, NOT READY: 1 P1, 2 P2).
+
+First give one line per P1 and P2 from round 1: resolved, partly, or not. Carry every unresolved or partly resolved finding forward at its current severity, then add new findings. The verdict covers everything outstanding, round 1 included. Check in particular:
+- R1 P1: `trustCounters.Idle` is now `*uint64` with omitempty; `trustCountersOf` (edge side, always present, unarmed included), `counters()` (wire side, nil when absent), `addIdle`, `equal` and `trustStatusLine`. Does an older edge's answer print no `idle` through the verb, and does `ppv2-step.py` then refuse a B step on it?
+- R1 P2 (mixed presence): `idleConsistent` in `statusShape`.
+- R1 P2 (late parse): `sentAnything` now clears the read deadline and calls `queuedBytes` (`internal/proxyproto/peek_unix.go`, recv MSG_PEEK|MSG_DONTWAIT through syscall.RawConn; `peek_other.go` answers unknown). Any way queued bytes can still read as absent, or the peek can block, race with Close or CloseTrusted, or leave state behind on a connection the server keeps?
+- The census overlay now has `queuedBytes` as new (legacy); `sentAnything` no longer reads directly.
+
+## Severity
+
+- **P1**: unsafe, would not compile, a test fails, or it would not work. Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review. (The census, and review of any newly changed security, root, termination or production-storage behaviour, still check the fix; see AGENTS.md, "Stopping rules".)
+- **P3**: clarity or polish. Goes on a follow-up list; never a reason for another round.
+
+A P1 states its failure scenario and the evidence (file:line). Do not raise a P2 to P1 to keep the review open.
+
+## Output
+
+Findings ranked P1, P2, P3. Each gives the section or task, the problem, the evidence (file:line, verified), the failure scenario, a concrete fix and the invariant or trust boundary it breaks (that is its fault family). Then the census verdicts (approve or reject per unit and envelope, citing the lines read). End with exactly one verdict:
+
+- **READY**: no P1 and no P2.
+- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another round.
+- **NOT READY**: one or more P1s, listed.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of your own. Do not run the full test suites; targeted `go test ./internal/proxyproto/ ./internal/host/ -run <name>` and `python3 -m unittest` in `scripts/` are fine.
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-edge-ppv2-idle.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-edge-ppv2-idle.md
new file mode 100644
index 000000000..b61bc5826
--- /dev/null
+++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-edge-ppv2-idle.md
@@ -0,0 +1,46 @@
+# Review brief: branch edge-ppv2-idle (edge PPv2 idle counter), round 1 of 3
+
+Repo carlos/platform, branch `edge-ppv2-idle`, commit 86e28db6f273b459a145514fc2419398de8cb980.
+Under review: the diff `origin/main..86e28db6` (base 03ff5d17).
+Authorities: `docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md` (rev 5.1 on main; this branch adds a rev 5.2 note in section 4.5), `docs/region-ha-runbook.md` section "PROXY protocol v2 on the region NLBs", both on main.
+
+You are an independent reviewer. Read the diff, then the code it touches, and check every claim against that code.
+
+## Background
+
+On 2026-11-17 the dev IE NLB cutover showed that the AWS NLB sends its PROXY protocol v2 header with the client's first bytes, not at connect. In S2 (preservation off, PPv2 on) an idle client connection (a browser preconnect) is trusted, waits for a header, reaches the 10 s header deadline and was counted `timeout`. Eight deliberate idle connections moved `timeout` by exactly 8. `timeout` is in `scripts/ppv2-step.py`'s STILL set, so B steps could not converge on a deployment with real browsers.
+
+The change: a trusted connection that sends no byte before the header deadline is counted `idle`, not `timeout`; a started header still counts `timeout`. `idle` is carried through the edge sum, the journal line, `trust-status` and its wire form (optional only for an older edge), and the step script (optional in a status line, never in STILL; a B step refuses a target whose edge does not report it).
+
+## Fixed: do not re-argue
+
+- 8a3d302's ruling (2026-11-17): an idle counter for "no bytes before the header deadline", outside the step script's must-stay-still set; `timeout` stays for a partial header; runbook updated.
+- The header deadline itself, the trust rule, the barrier and the S3 signals (`marker_trusted`, `no_client_refused`) are unchanged and out of scope except where this diff touches them.
+
+## What to check
+
+1. `internal/proxyproto/conn.go` `parse` and `sentAnything`: can anything that is a real header problem (a started header, a malformed one, a marker, a header that arrived after a late parse start, see `TestTrustedHeaderDeadlineFromAccept`) now be counted `idle` instead of `timeout`, `malformed` or `marker_trusted`? Can `sentAnything`'s extra 1-byte read with a 5 ms deadline block, race with `Close`, the barrier sweep (`CloseTrusted`), or the deferred `endHeaderDeadline`, or leave a deadline set on a connection that is handed back to the server? The connection is closed right after in both branches; verify that.
+2. Could an attacker on an untrusted path, or a client behind the NLB, use the idle path to hide anything the S3 detection (spec 6.4, 6.5) relies on? The trust-violation metric is `no_client_refused` + `marker_trusted` only.
+3. `internal/host/edgetrust.go`: `idle` is the one counter allowed absent on the wire (presence-aware parsing everywhere else). Check `counters()`, `add()`, `statusShape` and `validTrust` for any way an absent or inconsistent `idle` lets a malformed answer through, or makes a valid answer from an older edge refused. Root reads this answer through the drain call child; check that nothing root decides depends on `idle`.
+4. `scripts/ppv2-step.py`: `counter_keys`, `counts_ok`, `parse_trust`, `counts_of` and the new refusal in `collect_baseline`. Can a status line mixing idle-present and idle-absent parts pass? Does the restart detection (`restart_reasons`) still catch a reset? Is the B-step refusal reached for `apply` and for `reverify` of a B step, and not for A or R steps? Is anything in STILL or the S3 checks weakened?
+5. The census overlay (`internal/provision/testdata/plan14-root-reads-edge-ppv2-idle.tsv`, card `docs/superpowers/notes/census-proposal-edge-ppv2-idle.md`): give a verdict for `Conn.parse` (body) and the new `Conn.sentAnything`, and for the re-pinned envelopes `internal/edge`, `internal/host`, `internal/proxyproto`, under the rules in AGENTS.md "The census: the reviewer decides".
+6. Tests: do the new tests (`TestTrustedIdleBeforeHeader`, `TestTrustedHeaderTimeoutPartialSignature`, `TestUntrustedSilentIsNotIdle`, `TestTrustStatusIdleOptional`, the three new `ppv2_step_test.py` cases) actually fail without the change? Any timing flake risk under CI load (50 ms deadlines, the 5 ms read)?
+7. The runbook and spec text: anything wrong against the code.
+
+## Severity
+
+- **P1**: unsafe, would not compile, a test fails, or it would not work. Blocks merge.
+- **P2**: wrong or missing. Fixed without reopening this review. (The census, and review of any newly changed security, root, termination or production-storage behaviour, still check the fix; see AGENTS.md, "Stopping rules".)
+- **P3**: clarity or polish. Goes on a follow-up list; never a reason for another round.
+
+A P1 states its failure scenario and the evidence (file:line). Do not raise a P2 to P1 to keep the review open.
+
+## Output
+
+Findings ranked P1, P2, P3. Each gives the section or task, the problem, the evidence (file:line, verified), the failure scenario, a concrete fix and the invariant or trust boundary it breaks (that is its fault family). Then the census verdicts (approve or reject per unit and envelope, citing the lines read). End with exactly one verdict:
+
+- **READY**: no P1 and no P2.
+- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another round.
+- **NOT READY**: one or more P1s, listed.
+
+Do not edit files. Do not spawn Anthropic-model reviewers or subagents of your own. Do not run the full test suites; targeted `go test ./internal/proxyproto/ ./internal/host/ -run <name>` and `python3 -m unittest` in `scripts/` are fine.
diff --git a/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md b/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md
index 47eef47ba..29d2ead55 100644
--- a/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md
+++ b/docs/superpowers/specs/2026-11-12-edge-proxy-protocol-design.md
@@ -94,7 +94,9 @@ The header's destination address and port are not used.
### 4.5 Counters
-Per listener and, for trusted connections, per node address, since start: `proxied`, `no_client`, `no_client_refused` (§4.6), `ignored` (untrusted header consumed), `ignored_private` (untrusted header from a private address: almost certainly an NLB node missing from the key), `marker_trusted` (§6.4), `malformed`, `timeout`. One journal line at start (`edge: proxy protocol: armed on :80 and :443, trusting 172.31.29.110,172.31.11.189`), and one throttled line every minute while armed, naming every counter. `no_client_refused` and `ignored_private` above zero also log once a minute at warning level with the peer address. The cutover reads these lines over SSM (§6.4).
+Per listener and, for trusted connections, per node address, since start: `proxied`, `no_client`, `no_client_refused` (§4.6), `ignored` (untrusted header consumed), `ignored_private` (untrusted header from a private address: almost certainly an NLB node missing from the key), `marker_trusted` (§6.4), `malformed`, `timeout` (a trusted header started and not finished by its deadline), `idle` (a trusted connection that sent no byte by the deadline). One journal line at start (`edge: proxy protocol: armed on :80 and :443, trusting 172.31.29.110,172.31.11.189`), and one throttled line every minute while armed, naming every counter. `no_client_refused` and `ignored_private` above zero also log once a minute at warning level with the peer address. The cutover reads these lines over SSM (§6.4).
+
+**Rev 5.2 (2026-11-17, dev IE cutover): `idle`.** The NLB sends its PROXY header with the client's first bytes, not at connect, so in S2 an idle client connection (a browser preconnect) reaches the header deadline with nothing read. That is ordinary traffic, closed as the server's own header timeout closes an idle direct connection, so it is counted as `idle` and not as `timeout`, and `idle` is not among the counters a step keeps still (§6.4). `trust-status` may omit `idle` only when the edge predates it; the step script refuses a B step on such a target.
**Rev 5.1: what `trust-status` carries.** The counters and `proxied_by_node` summed over both listeners (the metric's view, below), and `by_listener` with each listener's own counters and per-node `proxied`, keyed `"80"` and `"443"`, all from one snapshot. And `edge_instance`, a random id the edge sets once when it arms at start: the counters live exactly as long as it, so a reader that sees it change knows they started again. Convergence (§6.4) uses both: a B step's evidence is its own port's listener, and a changed `edge_instance` or any count lower than at the previous poll is a restart that fails the window.
diff --git a/internal/edge/proxyingress.go b/internal/edge/proxyingress.go
index a58b87753..ef33cf3fb 100644
--- a/internal/edge/proxyingress.go
+++ b/internal/edge/proxyingress.go
@@ -340,6 +340,7 @@ func SumProxyCounters(listeners map[string]proxyproto.Counters) proxyproto.Count
sum.MarkerTrusted += c.MarkerTrusted
sum.Malformed += c.Malformed
sum.Timeout += c.Timeout
+ sum.Idle += c.Idle
for a, n := range c.ProxiedByNode {
sum.ProxiedByNode[a] += n
}
@@ -413,8 +414,8 @@ func (e *Edge) proxyJournalLines(prev *proxyproto.Counters) []string {
for _, a := range p.trusted {
nodes = append(nodes, fmt.Sprintf("%s:%d", a, c.ProxiedByNode[a]))
}
- lines := []string{fmt.Sprintf("edge: proxy protocol: proxied=%d no_client=%d no_client_refused=%d ignored=%d ignored_private=%d marker_trusted=%d malformed=%d timeout=%d proxied_by_node=%s barrier=%s",
- c.Proxied, c.NoClient, c.NoClientRefused, c.Ignored, c.IgnoredPrivate, c.MarkerTrusted, c.Malformed, c.Timeout,
+ lines := []string{fmt.Sprintf("edge: proxy protocol: proxied=%d no_client=%d no_client_refused=%d ignored=%d ignored_private=%d marker_trusted=%d malformed=%d timeout=%d idle=%d proxied_by_node=%s barrier=%s",
+ c.Proxied, c.NoClient, c.NoClientRefused, c.Ignored, c.IgnoredPrivate, c.MarkerTrusted, c.Malformed, c.Timeout, c.Idle,
strings.Join(nodes, ","), barrierWord(p.barrier.Load()))}
refused := c.NoClientRefused - prev.NoClientRefused
private := c.IgnoredPrivate - prev.IgnoredPrivate
diff --git a/internal/edge/proxyingress_test.go b/internal/edge/proxyingress_test.go
index f1a454efb..d69bb2c3a 100644
--- a/internal/edge/proxyingress_test.go
+++ b/internal/edge/proxyingress_test.go
@@ -751,7 +751,7 @@ func TestProxyJournalLines(t *testing.T) {
pe := newProxyEdge(t, e, proxyOpts{})
var prev proxyproto.Counters
lines := e.proxyJournalLines(&prev)
- want := "edge: proxy protocol: proxied=0 no_client=0 no_client_refused=0 ignored=0 ignored_private=0 marker_trusted=0 malformed=0 timeout=0 proxied_by_node=127.0.0.1:0 barrier=down"
+ want := "edge: proxy protocol: proxied=0 no_client=0 no_client_refused=0 ignored=0 ignored_private=0 marker_trusted=0 malformed=0 timeout=0 idle=0 proxied_by_node=127.0.0.1:0 barrier=down"
if len(lines) != 1 || lines[0] != want {
t.Fatalf("quiet minute: %q", lines)
}
diff --git a/internal/host/edgetrust.go b/internal/host/edgetrust.go
index b2b38612f..0b06fa2e6 100644
--- a/internal/host/edgetrust.go
+++ b/internal/host/edgetrust.go
@@ -111,6 +111,10 @@ type trustCounters struct {
MarkerTrusted uint64 `json:"marker_trusted"`
Malformed uint64 `json:"malformed"`
Timeout uint64 `json:"timeout"`
+ // Idle is nil when the running edge predates the counter: trust-status
+ // then prints no "idle", so a reader (ppv2-step.py refuses B steps on
+ // such a target) sees what the edge reports, not what this binary knows.
+ Idle *uint64 `json:"idle,omitempty"`
}
// trustStatus is GET /v1/edge/trust and trust-status's line. Counters and
@@ -182,6 +186,10 @@ type trustCountersWire struct {
MarkerTrusted *uint64 `json:"marker_trusted,omitempty"`
Malformed *uint64 `json:"malformed,omitempty"`
Timeout *uint64 `json:"timeout,omitempty"`
+ // Idle is the one counter that may be absent: an edge from before it
+ // existed (still running while a newer binary asks during an update)
+ // does not send it. It reads as zero; it is no trust evidence.
+ Idle *uint64 `json:"idle,omitempty"`
}
// counters is c with every counter present, ok false when one is absent.
@@ -194,10 +202,15 @@ func (c *trustCountersWire) counters() (trustCounters, bool) {
return trustCounters{}, false
}
}
- return trustCounters{
+ out := trustCounters{
Proxied: *c.Proxied, NoClient: *c.NoClient, NoClientRefused: *c.NoClientRefused, Ignored: *c.Ignored,
IgnoredPrivate: *c.IgnoredPrivate, MarkerTrusted: *c.MarkerTrusted, Malformed: *c.Malformed, Timeout: *c.Timeout,
- }, true
+ }
+ if c.Idle != nil {
+ idle := *c.Idle
+ out.Idle = &idle
+ }
+ return out, true
}
// add is c plus d, counter by counter.
@@ -205,8 +218,47 @@ func (c trustCounters) add(d trustCounters) trustCounters {
return trustCounters{
Proxied: c.Proxied + d.Proxied, NoClient: c.NoClient + d.NoClient, NoClientRefused: c.NoClientRefused + d.NoClientRefused,
Ignored: c.Ignored + d.Ignored, IgnoredPrivate: c.IgnoredPrivate + d.IgnoredPrivate, MarkerTrusted: c.MarkerTrusted + d.MarkerTrusted,
- Malformed: c.Malformed + d.Malformed, Timeout: c.Timeout + d.Timeout,
+ Malformed: c.Malformed + d.Malformed, Timeout: c.Timeout + d.Timeout, Idle: addIdle(c.Idle, d.Idle),
+ }
+}
+
+// addIdle sums two idle counts, nil when both are absent. Callers check
+// presence is consistent first (idleConsistent).
+func addIdle(a, b *uint64) *uint64 {
+ if a == nil && b == nil {
+ return nil
+ }
+ var v uint64
+ if a != nil {
+ v += *a
}
+ if b != nil {
+ v += *b
+ }
+ return &v
+}
+
+// equal is c == d by value, idle's presence included.
+func (c trustCounters) equal(d trustCounters) bool {
+ ci, di := c.Idle, d.Idle
+ c.Idle, d.Idle = nil, nil
+ if c != d || (ci == nil) != (di == nil) {
+ return false
+ }
+ return ci == nil || *ci == *di
+}
+
+// idleConsistent: an answer carries idle in its counters and in every
+// listener, or nowhere (an edge from before the counter). Anything else is
+// not one edge's snapshot.
+func (t *trustResult) idleConsistent() bool {
+ present := t.Counters != nil && t.Counters.Idle != nil
+ for _, l := range t.ByListener {
+ if l != nil && (l.Idle != nil) != present {
+ return false
+ }
+ }
+ return true
}
// statusShape is whether a status answer's instance and per-listener
@@ -221,7 +273,7 @@ func (t *trustResult) statusShape(armed bool, total trustCounters) bool {
if !armed {
return *t.EdgeInstance == "" && len(t.ByListener) == 0
}
- if *t.EdgeInstance == "" || len(t.ByListener) != len(trustListeners) {
+ if *t.EdgeInstance == "" || len(t.ByListener) != len(trustListeners) || !t.idleConsistent() {
return false
}
var sum trustCounters
@@ -240,7 +292,7 @@ func (t *trustResult) statusShape(armed bool, total trustCounters) bool {
byNode[a] += n
}
}
- if sum != total || len(byNode) != len(t.ProxiedByNode) {
+ if !sum.equal(total) || len(byNode) != len(t.ProxiedByNode) {
return false
}
for a, n := range byNode {
@@ -328,7 +380,7 @@ func trustCountersOf(c proxyproto.Counters) trustCounters {
return trustCounters{
Proxied: c.Proxied, NoClient: c.NoClient, NoClientRefused: c.NoClientRefused,
Ignored: c.Ignored, IgnoredPrivate: c.IgnoredPrivate, MarkerTrusted: c.MarkerTrusted,
- Malformed: c.Malformed, Timeout: c.Timeout,
+ Malformed: c.Malformed, Timeout: c.Timeout, Idle: &c.Idle,
}
}
@@ -348,6 +400,7 @@ func trustStatusOf(e trustEdge) trustStatus {
ByListener: map[string]trustListener{}}
if !armed {
s.EdgeInstance = ""
+ s.Counters = trustCountersOf(proxyproto.Counters{})
s.ProxiedByNode = map[string]uint64{}
return s
}
diff --git a/internal/host/edgetrust_linux_test.go b/internal/host/edgetrust_linux_test.go
index 9aac46c0e..b5034c0ca 100644
--- a/internal/host/edgetrust_linux_test.go
+++ b/internal/host/edgetrust_linux_test.go
@@ -106,10 +106,10 @@ func TestDrainCallTrustRefusesIncomplete(t *testing.T) {
go srv.Serve(l)
t.Cleanup(func() { srv.Close() })
call := socketDrainCall(newDrainClient(path))
- const counters = `{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0}`
- const zeroListener = `{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"proxied_by_node":{}}`
- const oneListener = `{"proxied":1,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"proxied_by_node":{"172.31.29.110":1}}`
- const one = `{"proxied":1,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0}`
+ const counters = `{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"idle":0}`
+ const zeroListener = `{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"idle":0,"proxied_by_node":{}}`
+ const oneListener = `{"proxied":1,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"idle":0,"proxied_by_node":{"172.31.29.110":1}}`
+ const one = `{"proxied":1,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"idle":0}`
const inst = `"edge_instance":"` + fakeEdgeInstance + `"`
listeners := `"by_listener":{"80":` + zeroListener + `,"443":` + zeroListener + `}`
status := func(fields ...string) string {
diff --git a/internal/host/edgetrust_test.go b/internal/host/edgetrust_test.go
index fe68f67ca..28a68d3ef 100644
--- a/internal/host/edgetrust_test.go
+++ b/internal/host/edgetrust_test.go
@@ -131,17 +131,17 @@ func trustCountersFixture() map[string]proxyproto.Counters {
}
const trustStatusFixtureJSON = `{"armed":true,"barrier":false,"edge_instance":"0123456789abcdef0123456789abcdef",` +
- `"counters":{"proxied":10,"no_client":2,"no_client_refused":1,"ignored":3,"ignored_private":4,"marker_trusted":5,"malformed":6,"timeout":7},` +
+ `"counters":{"proxied":10,"no_client":2,"no_client_refused":1,"ignored":3,"ignored_private":4,"marker_trusted":5,"malformed":6,"timeout":7,"idle":0},` +
`"proxied_by_node":{"172.31.11.189":4,"172.31.29.110":6},` +
- `"by_listener":{"443":{"proxied":7,"no_client":0,"no_client_refused":1,"ignored":2,"ignored_private":0,"marker_trusted":5,"malformed":4,"timeout":4,"proxied_by_node":{"172.31.11.189":3,"172.31.29.110":4}},` +
- `"80":{"proxied":3,"no_client":2,"no_client_refused":0,"ignored":1,"ignored_private":4,"marker_trusted":0,"malformed":2,"timeout":3,"proxied_by_node":{"172.31.11.189":1,"172.31.29.110":2}}}}`
+ `"by_listener":{"443":{"proxied":7,"no_client":0,"no_client_refused":1,"ignored":2,"ignored_private":0,"marker_trusted":5,"malformed":4,"timeout":4,"idle":0,"proxied_by_node":{"172.31.11.189":3,"172.31.29.110":4}},` +
+ `"80":{"proxied":3,"no_client":2,"no_client_refused":0,"ignored":1,"ignored_private":4,"marker_trusted":0,"malformed":2,"timeout":3,"idle":0,"proxied_by_node":{"172.31.11.189":1,"172.31.29.110":2}}}}`
// unarmedStatusJSON is an unarmed edge's status line.
-const unarmedStatusJSON = `{"armed":false,"barrier":false,"edge_instance":"","counters":{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0},"proxied_by_node":{},"by_listener":{}}`
+const unarmedStatusJSON = `{"armed":false,"barrier":false,"edge_instance":"","counters":{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"idle":0},"proxied_by_node":{},"by_listener":{}}`
// zeroStatusJSON is an armed edge's status line with nothing counted.
-const zeroStatusJSON = `{"armed":true,"barrier":false,"edge_instance":"0123456789abcdef0123456789abcdef","counters":{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0},"proxied_by_node":{},` +
- `"by_listener":{"443":{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"proxied_by_node":{}},"80":{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"proxied_by_node":{}}}}`
+const zeroStatusJSON = `{"armed":true,"barrier":false,"edge_instance":"0123456789abcdef0123456789abcdef","counters":{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"idle":0},"proxied_by_node":{},` +
+ `"by_listener":{"443":{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"idle":0,"proxied_by_node":{}},"80":{"proxied":0,"no_client":0,"no_client_refused":0,"ignored":0,"ignored_private":0,"marker_trusted":0,"malformed":0,"timeout":0,"idle":0,"proxied_by_node":{}}}}`
func serveTrust(t *testing.T, h http.Handler, method, target string) (int, string) {
t.Helper()
@@ -495,6 +495,15 @@ func TestEdgeTrustVerbAnswers(t *testing.T) {
{"status, a counter missing", drainCallResult{V: 1, Trust: &trustResult{Armed: &armed, Barrier: &down, Counters: &trustCountersWire{Proxied: new(uint64)}, ProxiedByNode: map[string]uint64{}}}, nil, "", 0, []string{"trust-status"}, 1, "", "edge: the agent answered nothing usable\n"},
{"barrier, no closed", drainCallResult{V: 1, Trust: &trustResult{Barrier: &up}}, nil, "", 0, []string{"trust-barrier"}, 1, "", "edge: the agent answered nothing usable\n"},
{"status", drainCallResult{V: 1, Trust: status}, nil, "", 0, []string{"trust-status"}, 0, zeroStatusJSON + "\n", ""},
+ // An older edge sends no idle; the line printed for ppv2-step.py must
+ // not invent one (it refuses B steps on such a target).
+ {"status, older edge", drainCallResult{V: 1, Trust: withoutIdle(zeroStatusWire(true))}, nil, "", 0, []string{"trust-status"}, 0,
+ strings.ReplaceAll(zeroStatusJSON, `,"idle":0`, "") + "\n", ""},
+ {"status, idle in some places only", drainCallResult{V: 1, Trust: func() *trustResult {
+ t := zeroStatusWire(true)
+ t.ByListener["80"].Idle = nil
+ return t
+ }()}, nil, "", 0, []string{"trust-status"}, 1, "", "edge: the agent answered nothing usable\n"},
{"status unarmed", drainCallResult{V: 1, Trust: unarmedStatus}, nil, "", 0, []string{"trust-status"}, 2, unarmedStatusJSON + "\n",
"edge: this box is not armed for PROXY protocol\n"},
{"barrier unarmed", drainCallResult{V: 1, Trust: &trustResult{Armed: &notArmed, Barrier: &down}}, nil, "", 0, []string{"trust-barrier"}, 2, "", "edge: this box is not armed for PROXY protocol\n"},
@@ -551,5 +560,76 @@ func zeroStatusWire(armed bool) *trustResult {
// zeroCountersWire is a status answer's counters, every one present.
func zeroCountersWire() *trustCountersWire {
z := func() *uint64 { return new(uint64) }
- return &trustCountersWire{Proxied: z(), NoClient: z(), NoClientRefused: z(), Ignored: z(), IgnoredPrivate: z(), MarkerTrusted: z(), Malformed: z(), Timeout: z()}
+ return &trustCountersWire{Proxied: z(), NoClient: z(), NoClientRefused: z(), Ignored: z(), IgnoredPrivate: z(), MarkerTrusted: z(), Malformed: z(), Timeout: z(), Idle: z()}
+}
+
+// withoutIdle is t as an edge from before the idle counter answers it.
+func withoutIdle(t *trustResult) *trustResult {
+ t.Counters.Idle = nil
+ for _, l := range t.ByListener {
+ l.Idle = nil
+ }
+ return t
+}
+
+// TestTrustStatusIdleOptional: an edge from before the idle counter (still
+// running while a newer binary asks during an update) sends no "idle"; its
+// status is accepted and printed without idle, so a reader sees what the
+// edge reports. Idle is in every place or none; every other counter stays
+// required.
+func TestTrustStatusIdleOptional(t *testing.T) {
+ old := strings.ReplaceAll(trustStatusFixtureJSON, `,"idle":0`, "")
+ if strings.Contains(old, "idle") {
+ t.Fatal("fixture still names idle")
+ }
+ var r trustResult
+ if err := json.Unmarshal([]byte(old), &r); err != nil {
+ t.Fatal(err)
+ }
+ if a, err := validTrust("trust-status", &r); err != nil || a != trustAnswerStatus {
+ t.Fatalf("old edge status: answer %v, err %v; want accepted", a, err)
+ }
+ if line := trustStatusLine(&r); line.Counters.Idle != nil || line.ByListener["80"].Idle != nil || line.Counters.Timeout != 7 {
+ t.Fatalf("old edge status line counters = %+v", line.Counters)
+ }
+ if b, err := json.Marshal(trustStatusLine(&r)); err != nil || strings.Contains(string(b), "idle") {
+ t.Fatalf("old edge status line prints idle: %s %v", b, err)
+ }
+
+ withIdle := strings.Replace(strings.Replace(strings.Replace(trustStatusFixtureJSON,
+ `"timeout":7,"idle":0`, `"timeout":7,"idle":5`, 1),
+ `"timeout":4,"idle":0`, `"timeout":4,"idle":2`, 1),
+ `"timeout":3,"idle":0`, `"timeout":3,"idle":3`, 1)
+ var n trustResult
+ if err := json.Unmarshal([]byte(withIdle), &n); err != nil {
+ t.Fatal(err)
+ }
+ if a, err := validTrust("trust-status", &n); err != nil || a != trustAnswerStatus {
+ t.Fatalf("status with idle: answer %v, err %v; want accepted", a, err)
+ }
+ if line := trustStatusLine(&n); line.Counters.Idle == nil || *line.Counters.Idle != 5 || *line.ByListener["80"].Idle != 3 {
+ t.Fatalf("status with idle counters = %+v", line.Counters)
+ }
+ for _, mixed := range []string{
+ strings.Replace(withIdle, `"timeout":3,"idle":3`, `"timeout":3`, 1), // a listener without it
+ strings.Replace(strings.Replace(withIdle, `"timeout":7,"idle":5`, `"timeout":7`, 1), `,"idle":2`, ``, 1), // the total without it
+ strings.Replace(trustStatusFixtureJSON, `"timeout":7,"idle":0`, `"timeout":7`, 1), // zeros, total missing
+ } {
+ var x trustResult
+ if err := json.Unmarshal([]byte(mixed), &x); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := validTrust("trust-status", &x); err == nil {
+ t.Fatalf("idle present in some places only accepted: %s", mixed)
+ }
+ }
+
+ noTimeout := strings.Replace(trustStatusFixtureJSON, `"timeout":7,`, "", 1)
+ var m trustResult
+ if err := json.Unmarshal([]byte(noTimeout), &m); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := validTrust("trust-status", &m); err == nil {
+ t.Fatal("status without timeout accepted; only idle may be absent")
+ }
}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 940f64fd6..33351eace 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -251,3 +251,4 @@ plan14-root-reads-fix-dbforward-reuse-1032.tsv ec3c40098ec0a652c735d54925f334b9b
plan14-root-reads-staticcheck-sa1012.tsv 5fcd060180e923773dad3faee7cc60ee250779a242b1dc14f4576f413dc8a774
plan14-root-reads-staticcheck-sa1019.tsv f9be26c06eb1c844b91a75f65faa51997048cb2900f3ed078be2ae28c65c0e98
plan14-root-reads-small-fixes-1246-1248.tsv c6d366dcf2211b714977b7a69180289555b362dfe5f36a5780af90b5ece82998
+plan14-root-reads-edge-ppv2-idle.tsv 5d4a5eea79394145fdd59aa5eb87115cc1ee396e02e0ab4b21decd2b3a10e3b4
diff --git a/internal/provision/testdata/plan14-root-reads-edge-ppv2-idle.tsv b/internal/provision/testdata/plan14-root-reads-edge-ppv2-idle.tsv
new file mode 100644
index 000000000..2d93ad8f9
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-edge-ppv2-idle.tsv
@@ -0,0 +1,10 @@
+# Census overlay edge-ppv2-idle, written by census-propose (#369). census-ruling-edge-ppv2-idle, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-edge-ppv2-idle.md.
+# 1 body, 0 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 1 new dispositions: 0 reads re-frozen at their disposition with the claim, 1 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
+@legacy 617bff46b6ba2741c56456fd1b5d9a0c31c779a4839831e81f7fb8919eff4a7a internal/proxyproto/conn.go Conn.parse legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-ppv2;basis=Edge (uid carlos), not root. Detects the signature, reads at most one header with ReadHeader (under the header deadline on a trusted peer), and resolves the connection's state (an untrusted peer: plain, or failed on a malformed header; a trusted one: proxied, no client or failed), consulting the barrier flag when it resolves. The scanner's +file:Command is the comparison h.Command != CommandProxy (the header's command nibble), not a process; no file, nothing run.;rev3=census-ruling-edge-ppv2-idle;basis=A trusted connection whose header read times out with no byte read, and sentAnything finds no byte either, closes and counts idle instead of timeout. Same close, same state (failed); no new read beyond sentAnything. Edge (uid carlos), not root. file:Command@1392 c113ea15ffb11367ee475f92010a612931fcce8d7fb37bfbc980dd6afa46e670
+@legacy 1ddf544181054206e69248a86d15ec7c4bc7e42e2533a417f577dc5858cadf09 internal/proxyproto/peek_unix.go queuedBytes legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-ppv2-idle;basis=New. One recv(MSG_PEEK|MSG_DONTWAIT) of one byte on the already accepted socket through syscall.RawConn, never waiting; consumes nothing. No file, no path, nothing run; known=false on any unexpected error. Edge (uid carlos), not root. file:Read@237 71030cc4f0df9764846ee6ccdcbc635503668998ca4623972bd485f92fa2a629
+internal/proxyproto/conn.go Conn.parse legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-ppv2;basis=Edge (uid carlos), not root. Detects the signature, reads at most one header with ReadHeader (under the header deadline on a trusted peer), and resolves the connection's state (an untrusted peer: plain, or failed on a malformed header; a trusted one: proxied, no client or failed), consulting the barrier flag when it resolves. The scanner's +file:Command is the comparison h.Command != CommandProxy (the header's command nibble), not a process; no file, nothing run.;rev3=census-ruling-edge-ppv2-idle;basis=A trusted connection whose header read times out with no byte read, and sentAnything finds no byte either, closes and counts idle instead of timeout. Same close, same state (failed); no new read beyond sentAnything. Edge (uid carlos), not root. file:Command@1392 c113ea15ffb11367ee475f92010a612931fcce8d7fb37bfbc980dd6afa46e670
+internal/proxyproto/peek_unix.go queuedBytes legacy accepted-legacy accepted-legacy;rev3=census-ruling-edge-ppv2-idle;basis=New. One recv(MSG_PEEK|MSG_DONTWAIT) of one byte on the already accepted socket through syscall.RawConn, never waiting; consumes nothing. No file, no path, nothing run; known=false on any unexpected error. Edge (uid carlos), not root. file:Read@237 71030cc4f0df9764846ee6ccdcbc635503668998ca4623972bd485f92fa2a629
+@coverage internal/edge 74bf68322ec2777195572f7173e3bc050cca11b61f87114eafa5d6d855b9bbdc
+@coverage internal/host 50d472568e446ef056546bd40805e0d500b41cf3aa69de41023e354f1368a070
+@coverage internal/proxyproto f39d92b91a54e98e9e5b47576a18e206a66cde4bcf8542b9c679b0b875a6803e
diff --git a/internal/proxyproto/conn.go b/internal/proxyproto/conn.go
index 85f70a1eb..457dc7a7e 100644
--- a/internal/proxyproto/conn.go
+++ b/internal/proxyproto/conn.go
@@ -251,7 +251,12 @@ func (c *Conn) parse() State {
if !full {
if c.trusted && !mismatched(sig[:n]) {
// The read failed (err is set) before the stream could be
- // told apart from a header: a trusted connection closes.
+ // told apart from a header: a trusted connection closes. With
+ // no byte at all by the deadline it was idle (the NLB sends its
+ // header with the client's first bytes), not a broken header.
+ if n == 0 && isTimeout(err) && !c.sentAnything() {
+ return c.failIdle(err)
+ }
return c.fail(err)
}
// Not a header (or, untrusted, a read error before it could be
@@ -343,6 +348,32 @@ func (c *Conn) fail(cause error) State {
case errors.Is(cause, ErrMalformed):
c.l.c.malformed.Add(1)
}
+ return c.close(cause)
+}
+
+// sentAnything reports whether the peer had sent a byte that the header
+// read never saw: a read whose deadline had already passed when the parse
+// began (it starts on the first Read, not at accept) fails without reading.
+// It peeks without a deadline (queuedBytes), so scheduling delay cannot make
+// queued bytes look absent, and when it cannot tell it answers true: such a
+// connection counts as timeout, never idle.
+func (c *Conn) sentAnything() bool {
+ // The header deadline has passed; RawConn.Read would refuse before the
+ // peek. The connection is closed right after, and endHeaderDeadline
+ // restores the caller's deadline in any case.
+ c.inner.SetReadDeadline(time.Time{})
+ queued, known := queuedBytes(c.inner)
+ return queued || !known
+}
+
+// failIdle closes a trusted connection that sent nothing before its header
+// deadline and counts it as idle, not as a timeout.
+func (c *Conn) failIdle(cause error) State {
+ c.l.c.idle.Add(1)
+ return c.close(cause)
+}
+
+func (c *Conn) close(cause error) State {
c.failErr = fmt.Errorf("proxyproto: connection closed: %w", cause)
c.closeInner()
return StateFailed
diff --git a/internal/proxyproto/counters.go b/internal/proxyproto/counters.go
index ef885901f..53a763a09 100644
--- a/internal/proxyproto/counters.go
+++ b/internal/proxyproto/counters.go
@@ -28,8 +28,15 @@ type Counters struct {
// Malformed: headers refused (bad header, or an unusable source on a
// trusted connection).
Malformed uint64
- // Timeout: headers not complete by their deadline.
+ // Timeout: trusted connections that started a header (sent at least
+ // one byte) but did not complete it by the deadline.
Timeout uint64
+ // Idle: trusted connections that sent no byte at all before the header
+ // deadline. A load balancer sends its PROXY header with the client's
+ // first bytes, so an idle client connection (a browser preconnect) is
+ // closed here, exactly as ReadHeaderTimeout closes an idle direct one.
+ // Counted apart from Timeout because it is ordinary traffic, not a fault.
+ Idle uint64
// ProxiedByNode splits Proxied by the trusted peer address.
ProxiedByNode map[netip.Addr]uint64
}
@@ -43,6 +50,7 @@ type counters struct {
markerTrusted atomic.Uint64
malformed atomic.Uint64
timeout atomic.Uint64
+ idle atomic.Uint64
mu sync.Mutex
byNode map[netip.Addr]uint64
@@ -68,6 +76,7 @@ func (c *counters) snapshot() Counters {
MarkerTrusted: c.markerTrusted.Load(),
Malformed: c.malformed.Load(),
Timeout: c.timeout.Load(),
+ Idle: c.idle.Load(),
}
c.mu.Lock()
s.ProxiedByNode = make(map[netip.Addr]uint64, len(c.byNode))
diff --git a/internal/proxyproto/listener_test.go b/internal/proxyproto/listener_test.go
index bbe243cef..95b26d380 100644
--- a/internal/proxyproto/listener_test.go
+++ b/internal/proxyproto/listener_test.go
@@ -319,7 +319,10 @@ func TestTrustedUnusableSourceClosed(t *testing.T) {
}
}
-func TestTrustedHeaderTimeout(t *testing.T) {
+// TestTrustedIdleBeforeHeader: a trusted connection that sends nothing (an
+// NLB connection whose client never sent a byte) closes at the deadline and
+// counts as idle, not as a timeout.
+func TestTrustedIdleBeforeHeader(t *testing.T) {
l := listen(t, Config{Trusted: loopback, HeaderTimeout: 50 * time.Millisecond})
client, c := pair(t, l)
@@ -327,8 +330,42 @@ func TestTrustedHeaderTimeout(t *testing.T) {
t.Fatalf("State = %v, want failed", s)
}
expectClosed(t, client)
- if n := l.Counters().Timeout; n != 1 {
- t.Fatalf("Timeout = %d, want 1", n)
+ cn := l.Counters()
+ if cn.Idle != 1 || cn.Timeout != 0 || cn.Malformed != 0 {
+ t.Fatalf("Idle = %d, Timeout = %d, Malformed = %d, want 1, 0 and 0", cn.Idle, cn.Timeout, cn.Malformed)
+ }
+}
+
+// TestTrustedHeaderTimeoutPartialSignature: a few signature bytes, then
+// silence. A started header is a timeout, never idle.
+func TestTrustedHeaderTimeoutPartialSignature(t *testing.T) {
+ l := listen(t, Config{Trusted: loopback, HeaderTimeout: 50 * time.Millisecond})
+ client, c := pair(t, l)
+ write(t, client, proxyHeader("203.0.113.7:51000")[:3])
+
+ if s := stateWithin(t, c, time.Second); s != StateFailed {
+ t.Fatalf("State = %v, want failed", s)
+ }
+ expectClosed(t, client)
+ cn := l.Counters()
+ if cn.Timeout != 1 || cn.Idle != 0 {
+ t.Fatalf("Timeout = %d, Idle = %d, want 1 and 0", cn.Timeout, cn.Idle)
+ }
+}
+
+// TestUntrustedSilentIsNotIdle: idle counts trusted connections only; an
+// untrusted one has no header deadline and is left to the server.
+func TestUntrustedSilentIsNotIdle(t *testing.T) {
+ l := listen(t, Config{HeaderTimeout: 50 * time.Millisecond})
+ _, c := pair(t, l)
+ c.SetReadDeadline(time.Now().Add(100 * time.Millisecond))
+ buf := make([]byte, 1)
+ if _, err := c.Read(buf); err == nil {
+ t.Fatal("Read returned no error on a silent connection")
+ }
+ cn := l.Counters()
+ if cn.Idle != 0 || cn.Timeout != 0 {
+ t.Fatalf("Idle = %d, Timeout = %d, want 0 and 0", cn.Idle, cn.Timeout)
}
}
@@ -343,8 +380,8 @@ func TestTrustedHeaderTimeoutPartial(t *testing.T) {
}
expectClosed(t, client)
cn := l.Counters()
- if cn.Timeout != 1 || cn.Malformed != 0 {
- t.Fatalf("Timeout = %d, Malformed = %d, want 1 and 0", cn.Timeout, cn.Malformed)
+ if cn.Timeout != 1 || cn.Malformed != 0 || cn.Idle != 0 {
+ t.Fatalf("Timeout = %d, Malformed = %d, Idle = %d, want 1, 0 and 0", cn.Timeout, cn.Malformed, cn.Idle)
}
}
diff --git a/internal/proxyproto/peek_other.go b/internal/proxyproto/peek_other.go
new file mode 100644
index 000000000..911ba6762
--- /dev/null
+++ b/internal/proxyproto/peek_other.go
@@ -0,0 +1,9 @@
+//go:build !unix
+
+package proxyproto
+
+import "net"
+
+// queuedBytes cannot tell on this system; callers treat that as bytes
+// present, so nothing is counted idle.
+func queuedBytes(net.Conn) (queued, known bool) { return false, false }
diff --git a/internal/proxyproto/peek_unix.go b/internal/proxyproto/peek_unix.go
new file mode 100644
index 000000000..332fb3f6f
--- /dev/null
+++ b/internal/proxyproto/peek_unix.go
@@ -0,0 +1,46 @@
+//go:build unix
+
+package proxyproto
+
+import (
+ "errors"
+ "net"
+ "syscall"
+
+ "golang.org/x/sys/unix"
+)
+
+// queuedBytes reports whether conn's socket holds unread bytes, without
+// reading them and without waiting: one recv with MSG_PEEK|MSG_DONTWAIT on
+// the raw descriptor. No read deadline takes part, so how late the caller
+// runs cannot hide bytes already queued. known is false when it cannot
+// tell (not a socket, or an unexpected error); callers treat that as bytes
+// present.
+func queuedBytes(conn net.Conn) (queued, known bool) {
+ sc, ok := conn.(syscall.Conn)
+ if !ok {
+ return false, false
+ }
+ rc, err := sc.SyscallConn()
+ if err != nil {
+ return false, false
+ }
+ var (
+ n int
+ rerr error
+ )
+ if err := rc.Read(func(fd uintptr) bool {
+ var b [1]byte
+ n, _, rerr = unix.Recvfrom(int(fd), b[:], unix.MSG_PEEK|unix.MSG_DONTWAIT)
+ return true // never wait for readiness
+ }); err != nil {
+ return false, false
+ }
+ switch {
+ case rerr == nil:
+ return n > 0, true // n == 0: the peer closed having sent nothing
+ case errors.Is(rerr, unix.EAGAIN), errors.Is(rerr, unix.EWOULDBLOCK):
+ return false, true
+ }
+ return false, false
+}
diff --git a/internal/proxyproto/peek_unix_test.go b/internal/proxyproto/peek_unix_test.go
new file mode 100644
index 000000000..2ba2b7406
--- /dev/null
+++ b/internal/proxyproto/peek_unix_test.go
@@ -0,0 +1,68 @@
+//go:build unix
+
+package proxyproto
+
+import (
+ "net"
+ "runtime"
+ "testing"
+ "time"
+)
+
+// TestQueuedBytes: the peek sees queued bytes without consuming them and
+// none on a silent connection. With an expired read deadline still on the
+// socket it cannot peek and says so (known false, which callers count as
+// bytes present); sentAnything clears the deadline first.
+func TestQueuedBytes(t *testing.T) {
+ inner, err := net.Listen("tcp", "127.0.0.1:0")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer inner.Close()
+ client, err := net.Dial("tcp", inner.Addr().String())
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer client.Close()
+ server, err := inner.Accept()
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer server.Close()
+
+ if queued, known := queuedBytes(server); queued || !known {
+ t.Fatalf("silent: queued %v known %v, want false true", queued, known)
+ }
+ if _, err := client.Write([]byte("x")); err != nil {
+ t.Fatal(err)
+ }
+ server.SetReadDeadline(time.Now().Add(-time.Second))
+ if _, known := queuedBytes(server); known {
+ t.Fatal("known true under an expired read deadline")
+ }
+ server.SetReadDeadline(time.Time{})
+ deadline := time.Now().Add(time.Second)
+ for {
+ queued, known := queuedBytes(server)
+ if !known {
+ t.Fatal("known false on a TCP socket")
+ }
+ if queued {
+ break
+ }
+ if time.Now().After(deadline) {
+ t.Fatal("written byte never seen")
+ }
+ runtime.Gosched() // loopback delivery is immediate; this only yields
+ }
+ b := make([]byte, 1)
+ if n, err := server.Read(b); n != 1 || b[0] != 'x' || err != nil {
+ t.Fatalf("peek consumed the byte: %d %q %v", n, b[:n], err)
+ }
+ // After the peer closes, whether its FIN has landed yet or not, nothing
+ // is queued and the answer is known.
+ client.Close()
+ if queued, known := queuedBytes(server); queued || !known {
+ t.Fatalf("closed by peer: queued %v known %v, want false true", queued, known)
+ }
+}
diff --git a/scripts/ppv2-step.py b/scripts/ppv2-step.py
index 5173f320e..c9a8a80e3 100755
--- a/scripts/ppv2-step.py
+++ b/scripts/ppv2-step.py
@@ -112,7 +112,14 @@ TFVARS_KEY = {'preserve_client_ip': 'ppv2_preserve_client_ip', 'proxy_protocol_v
LOCK_FILE = '.ppv2-step.lock'
COUNTERS = ('proxied', 'no_client', 'no_client_refused', 'ignored', 'ignored_private',
'marker_trusted', 'malformed', 'timeout')
+# idle: trusted connections that sent no byte before the header deadline. The
+# NLB sends its header with the client's first bytes, so a browser preconnect
+# that never sends a request lands here. Ordinary traffic, never in STILL; an
+# edge from before the counter does not report it, so it is optional, but a
+# line has it everywhere or nowhere.
+OPTIONAL = ('idle',)
# Counters that must not move from the apply's baseline until convergence.
+# timeout is a header started and not finished, never an idle connection.
STILL = ('malformed', 'timeout', 'ignored_private', 'marker_trusted', 'no_client_refused')
PROBE_EXPECT = {'A': 's1', 'B': 's2', 'R': 's1'}
TRUST_STATUS = '/opt/carlos/carlos system edge trust-status'
@@ -292,8 +299,14 @@ def plan_refusal(plan, address, attribute, before, after):
return None
-def counts_ok(counters, nodes):
- if not isinstance(counters, dict) or set(counters) != set(COUNTERS):
+def counter_keys(status):
+ """The counters a status line carries: COUNTERS, plus idle when the edge reports it."""
+ counters = status.get('counters') if isinstance(status, dict) else None
+ return COUNTERS + OPTIONAL if isinstance(counters, dict) and 'idle' in counters else COUNTERS
+
+
+def counts_ok(counters, nodes, keys=COUNTERS):
+ if not isinstance(counters, dict) or set(counters) != set(keys):
return False
if not all(type(v) is int and v >= 0 for v in counters.values()):
return False
@@ -315,7 +328,8 @@ def parse_trust(text):
return None
if not isinstance(doc['armed'], bool) or not isinstance(doc['barrier'], bool):
return None
- if not counts_ok(doc['counters'], doc['proxied_by_node']):
+ keys = counter_keys(doc)
+ if not counts_ok(doc['counters'], doc['proxied_by_node'], keys):
return None
instance, listeners = doc['edge_instance'], doc['by_listener']
if not isinstance(instance, str) or not isinstance(listeners, dict):
@@ -326,11 +340,11 @@ def parse_trust(text):
return None
for port in LISTENERS:
l = listeners[port]
- if not isinstance(l, dict) or set(l) != set(COUNTERS) | {'proxied_by_node'}:
+ if not isinstance(l, dict) or set(l) != set(keys) | {'proxied_by_node'}:
return None
- if not counts_ok({c: l[c] for c in COUNTERS}, l['proxied_by_node']):
+ if not counts_ok({c: l[c] for c in keys}, l['proxied_by_node'], keys):
return None
- if any(doc['counters'][c] != sum(listeners[p][c] for p in LISTENERS) for c in COUNTERS):
+ if any(doc['counters'][c] != sum(listeners[p][c] for p in LISTENERS) for c in keys):
return None
nodes = set(doc['proxied_by_node']).union(*(listeners[p]['proxied_by_node'] for p in LISTENERS))
if any(doc['proxied_by_node'].get(n, 0) != sum(listeners[p]['proxied_by_node'].get(n, 0) for p in LISTENERS)
@@ -748,6 +762,11 @@ def collect_baseline(cloud, step, targets):
# barrier: it is the way forward again after an S3 incident (spec 6.5).
if status['barrier'] and step.attribute == 'preserve_client_ip':
raise Refused(f'the trust barrier is up on {iid}; no B step while it is up (spec 4.7)')
+ # An edge from before the idle counter counts an idle preconnect as
+ # timeout, which a B step must keep still: it could never converge.
+ if step.attribute == 'preserve_client_ip' and 'idle' not in status['counters']:
+ raise Refused(f'{iid} does not report the idle counter: its edge predates it and would count '
+ 'idle connections as timeout; roll it to a release with idle before a B step')
return baseline_at, baseline
@@ -1318,10 +1337,11 @@ def continuous_reasons(times, start, end, gap, what, start_label):
def counts_of(status):
"""Every count in a status line that only rises while one edge runs: the
sums, each listener's, and each node's proxied count, sum and per listener."""
- out = {(None, c): status['counters'][c] for c in COUNTERS}
+ keys = counter_keys(status)
+ out = {(None, c): status['counters'][c] for c in keys}
out.update({(None, 'node ' + n): v for n, v in status['proxied_by_node'].items()})
for port, listener in (status.get('by_listener') or {}).items():
- out.update({(port, c): listener[c] for c in COUNTERS})
+ out.update({(port, c): listener[c] for c in keys})
out.update({(port, 'node ' + n): v for n, v in listener['proxied_by_node'].items()})
return out
diff --git a/scripts/ppv2_step_test.py b/scripts/ppv2_step_test.py
index 56c100761..c1d4a1034 100644
--- a/scripts/ppv2_step_test.py
+++ b/scripts/ppv2_step_test.py
@@ -1758,6 +1758,78 @@ class ListenerAndRestartTests(ConvergeTests):
'proxied_by_node': {}, 'by_listener': {}}
self.assertIsNotNone(gate.parse_trust(json.dumps(unarmed)))
+ @staticmethod
+ def with_idle(status, on80=0, on443=0):
+ d = copy.deepcopy(status)
+ d['by_listener']['80']['idle'] = on80
+ d['by_listener']['443']['idle'] = on443
+ d['counters']['idle'] = on80 + on443
+ return d
+
+ def test_status_line_idle_optional(self):
+ """An edge with the idle counter reports it everywhere; one from before
+ it reports it nowhere. Both parse; a line with it in some places only,
+ or whose listeners do not sum to it, does not."""
+ good = trust('after_a')
+ self.assertIsNotNone(gate.parse_trust(json.dumps(good)))
+ self.assertIsNotNone(gate.parse_trust(json.dumps(self.with_idle(good, 3, 4))))
+ for mutate in (lambda d: d['by_listener']['80'].pop('idle'),
+ lambda d: d['counters'].pop('idle'),
+ lambda d: d['counters'].update(idle=8),
+ lambda d: d['by_listener']['443'].update(idle=-1)):
+ d = self.with_idle(good, 3, 4)
+ mutate(d)
+ self.assertIsNone(gate.parse_trust(json.dumps(d)))
+
+ def test_idle_moving_is_not_a_finding(self):
+ """Idle preconnects in S2 (the NLB sends its header with the client's
+ first bytes) move idle, never timeout; idle is not in STILL, so a B step
+ still converges. timeout, a header started and not finished, still fails it."""
+ self.assertNotIn('idle', gate.STILL)
+ self.assertIn('timeout', gate.STILL)
+ base = self.with_idle(trust('after_a'))
+ moved = self.with_idle(trust('after_a'), on80=8)
+ self.assertEqual([], gate.trust_findings(moved, base, None, TARGETS[0], 'B80'))
+ timed_out = copy.deepcopy(base)
+ timed_out['by_listener']['80']['timeout'] += 1
+ timed_out['counters']['timeout'] += 1
+ reasons = gate.trust_findings(timed_out, base, None, TARGETS[0], 'B80')
+ self.assertTrue(any('timeout' in r for r in reasons), reasons)
+
+ @staticmethod
+ def without_idle(status):
+ d = copy.deepcopy(status)
+ d['counters'].pop('idle', None)
+ for listener in d['by_listener'].values():
+ listener.pop('idle', None)
+ return d
+
+ def test_old_edge_line_parses_and_refuses_b_steps(self):
+ """An edge from before the idle counter: its line parses, an A step may
+ run on it, a B step (forward or its reverify baseline) is refused before
+ anything changes, and a reverse step is not."""
+ old = self.without_idle(trust('after_a'))
+ self.assertIsNotNone(gate.parse_trust(json.dumps(old)))
+
+ class Clock:
+ @staticmethod
+ def time():
+ return 1794900000.0
+
+ class Cloud:
+ clock = Clock()
+
+ @staticmethod
+ def trust(targets):
+ return {iid: copy.deepcopy(old) for iid in targets}
+
+ gate.collect_baseline(Cloud(), gate.STEPS['A443'], TARGETS)
+ gate.collect_baseline(Cloud(), gate.STEPS['R80'], TARGETS)
+ for step in ('B80', 'B443'):
+ with self.assertRaises(gate.Refused) as caught:
+ gate.collect_baseline(Cloud(), gate.STEPS[step], TARGETS)
+ self.assertIn('does not report the idle counter', str(caught.exception))
+
class SyncTfvarsTests(Harness):
"""W13: after the incident's direct preservation-on command, sync-tfvars
diff --git a/scripts/testdata/ppv2/trust-status.json b/scripts/testdata/ppv2/trust-status.json
index a25b041bf..422f5befd 100644
--- a/scripts/testdata/ppv2/trust-status.json
+++ b/scripts/testdata/ppv2/trust-status.json
@@ -1,17 +1,17 @@
{
"_comment": "Recorded `carlos system edge trust-status` lines (one JSON line each on the box), keyed by situation. Shapes follow internal/host/edgetrust.go trustStatus: counters and proxied_by_node sum by_listener (keyed \"80\" and \"443\"); edge_instance is set once per edge start.",
- "baseline": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5120, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
- "after_a": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
- "before_b": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 6010, "no_client_refused": 0, "ignored": 1830, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 3005, "no_client_refused": 0, "ignored": 915, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 3005, "no_client_refused": 0, "ignored": 915, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
- "b_both_nodes": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 377, "no_client": 6070, "no_client_refused": 0, "ignored": 1902, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {"172.31.11.189": 181, "172.31.29.110": 196}, "by_listener": {"80": {"proxied": 188, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {"172.31.11.189": 90, "172.31.29.110": 98}}, "443": {"proxied": 189, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {"172.31.11.189": 91, "172.31.29.110": 98}}}},
- "b_one_node": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 196, "no_client": 6070, "no_client_refused": 0, "ignored": 1902, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {"172.31.29.110": 196}, "by_listener": {"80": {"proxied": 98, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {"172.31.29.110": 98}}, "443": {"proxied": 98, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {"172.31.29.110": 98}}}},
- "b_port80_only": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 377, "no_client": 6070, "no_client_refused": 0, "ignored": 1902, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {"172.31.11.189": 181, "172.31.29.110": 196}, "by_listener": {"80": {"proxied": 377, "no_client": 3065, "no_client_refused": 0, "ignored": 987, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {"172.31.11.189": 181, "172.31.29.110": 196}}, "443": {"proxied": 0, "no_client": 3005, "no_client_refused": 0, "ignored": 915, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
- "malformed_moved": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 1, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 1, "timeout": 0, "proxied_by_node": {}}}},
- "marker_trusted_moved": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 2, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 2, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
- "no_client_refused_moved": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 7, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 7, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
- "restarted": {"armed": true, "barrier": false, "edge_instance": "b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2", "counters": {"proxied": 0, "no_client": 12, "no_client_refused": 0, "ignored": 3, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 6, "no_client_refused": 0, "ignored": 1, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 6, "no_client_refused": 0, "ignored": 2, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
- "restarted_counts_higher": {"armed": true, "barrier": false, "edge_instance": "b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2", "counters": {"proxied": 0, "no_client": 6180, "no_client_refused": 0, "ignored": 1412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 3590, "no_client_refused": 0, "ignored": 1206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
- "fell_since_last_poll": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5150, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
- "barrier_up": {"armed": true, "barrier": true, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5120, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "proxied_by_node": {}}}},
+ "baseline": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5120, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}}},
+ "after_a": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}}},
+ "before_b": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 6010, "no_client_refused": 0, "ignored": 1830, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 3005, "no_client_refused": 0, "ignored": 915, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 3005, "no_client_refused": 0, "ignored": 915, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}}},
+ "b_both_nodes": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 377, "no_client": 6070, "no_client_refused": 0, "ignored": 1902, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {"172.31.11.189": 181, "172.31.29.110": 196}, "by_listener": {"80": {"proxied": 188, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {"172.31.11.189": 90, "172.31.29.110": 98}}, "443": {"proxied": 189, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {"172.31.11.189": 91, "172.31.29.110": 98}}}},
+ "b_one_node": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 196, "no_client": 6070, "no_client_refused": 0, "ignored": 1902, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {"172.31.29.110": 196}, "by_listener": {"80": {"proxied": 98, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {"172.31.29.110": 98}}, "443": {"proxied": 98, "no_client": 3035, "no_client_refused": 0, "ignored": 951, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {"172.31.29.110": 98}}}},
+ "b_port80_only": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 377, "no_client": 6070, "no_client_refused": 0, "ignored": 1902, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {"172.31.11.189": 181, "172.31.29.110": 196}, "by_listener": {"80": {"proxied": 377, "no_client": 3065, "no_client_refused": 0, "ignored": 987, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {"172.31.11.189": 181, "172.31.29.110": 196}}, "443": {"proxied": 0, "no_client": 3005, "no_client_refused": 0, "ignored": 915, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}}},
+ "malformed_moved": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 1, "timeout": 0, "idle": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 1, "timeout": 0, "idle": 0, "proxied_by_node": {}}}},
+ "marker_trusted_moved": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 2, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 2, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}}},
+ "no_client_refused_moved": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5180, "no_client_refused": 7, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2590, "no_client_refused": 7, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}}},
+ "restarted": {"armed": true, "barrier": false, "edge_instance": "b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2", "counters": {"proxied": 0, "no_client": 12, "no_client_refused": 0, "ignored": 3, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 6, "no_client_refused": 0, "ignored": 1, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 6, "no_client_refused": 0, "ignored": 2, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}}},
+ "restarted_counts_higher": {"armed": true, "barrier": false, "edge_instance": "b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2", "counters": {"proxied": 0, "no_client": 6180, "no_client_refused": 0, "ignored": 1412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 3590, "no_client_refused": 0, "ignored": 1206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}}},
+ "fell_since_last_poll": {"armed": true, "barrier": false, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5150, "no_client_refused": 0, "ignored": 412, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2590, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 206, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}}},
+ "barrier_up": {"armed": true, "barrier": true, "edge_instance": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1", "counters": {"proxied": 0, "no_client": 5120, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0}, "proxied_by_node": {}, "by_listener": {"80": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}, "443": {"proxied": 0, "no_client": 2560, "no_client_refused": 0, "ignored": 0, "ignored_private": 0, "marker_trusted": 0, "malformed": 0, "timeout": 0, "idle": 0, "proxied_by_node": {}}}},
"not_armed": {"rc": 2, "stderr": "edge: this box is not armed for PROXY protocol\n"}
}