Repository navigation
feat(lab): publish the season list as signed text - #167
Conversation
Serve a large ticket list, shrink the client's receive buffer, read only the response headers, then reset the connection during the body. The complete download should add one tickets/200 count, and the aborted download should add one tickets/incomplete count. Today both are counted as 200. CTest accepts this run only when it fails that way.
A body write that failed part-way still counted as 200, so aborted transfers never appeared in the ticket request metric. Count those replies, and replies whose headers could not be written, once as status="incomplete" on the tickets route. The header-write path is not covered by the test: headers are too small to make that write fail reliably.
…s heartbeat The hub could not tell which list each gate had installed. List age based on file time also kept growing through 304 confirmations. Keep the verified SHA-256 and monotonic confirmation time at each gate. Send the installed version and time since confirmation in CONFIG, then compare it with the list the hub currently serves. Gates reporting no version have unknown status, which is not an error. A gate retries an empty CONFIG on the same connection for a hub not yet upgraded. The hub trusts the reported list state as sent: CONFIG has no MAC, so whoever holds a gate's certificate can report a false state for that gate. Co-authored-by: Ben Carter <ben.carter@elsworne.example>
On-call staff could only read raw /metrics. Provision a dashboard for the existing hub series: incomplete ticket replies, TLS handshake failures, and per-gate list status. Use a separate Compose file so the venue lab and its drills need no Grafana password. Pin both images by tag and digest. Keep the earlier sync-metrics regression test for the existing sync accounting fix, and check dashboard metrics against the hub. Co-authored-by: Yuki Tanaka <yuki.tanaka@elsworne.example>
The hub recorded connections that had not identified themselves under the name "unknown". Writing list status for every record made that pseudo-gate look like a gate reporting no version. Write list status only for gates that identified themselves and sent a heartbeat. A CONFIG from an unidentified connection records nothing.
… the uplink watcher has stopped Cut both data-centre exits, restore them, then kill the hub's uplink watcher. Compare Mailpit message IDs across each separate fault. Each case expects exactly one mail to manager@elsworne.example from alerts@elsworne.example through the venue's own mail server, which remains available without the data-centre link. The subjects are "Data centre unreachable" and "Uplink watcher stopped". Allow 20 s: 5 s for the probe, 10 s for the alert threshold, 1 s for the alert loop, and 4 s for mail submission; the watcher checks every second. Today neither mail is sent, so both judgements fail. Exit 0 means both pass, 1 means a judgement fails, and 2 means an environment or cleanup failure.
…he uplink watcher stops The hub logged data-centre failures, and the uplink watcher could exit without notifying the venue. Submit mail after the shared alert threshold, once per incident. Keep sent incidents in the atomic state file across hub restarts, and re-arm each alert when its condition recovers without sending recovery mail. Have the watcher update a heartbeat file each loop. Its modification time uses the clock shared with the hub, since a shell cannot portably read a monotonic clock. Give restarted hubs a fresh threshold of grace. Add a CI test for transient and repeated faults, recovery, mail headers, restart persistence, and the watcher grace period. Co-authored-by: Yuki Tanaka <yuki.tanaka@elsworne.example>
A signed barcode of about 159 characters does not fit the binary list's 32-byte record. Publish a 20000-ticket signed text list at /season.txt from both data-centre services at lab scale. Keep the signing key in dc and dc2 only. Leave /tickets.gpb and the hub unchanged. Test publication with the gates' signature verifier, HTTP and TLS responses, caching, ranges, and tampering.
|
Ben Carter · reviewer Does the hub now hold the issuing secret to verify these tickets? hub 现在要持有签发私钥才能验证这些票吗? |
|
Wang Hao · author No. The secret is mounted only into 不用。私钥只挂载到 |
|
Mateo Rossi · reviewer Does the verifier also check the event, or only the signature? 这个验证工具也检查场次吗,还是只看签名? |
|
Wang Hao · author Both. 都检查。 |
Why
The data-centre stub only published the binary list, whose 32-byte records cannot hold a signed barcode of about 159 characters. Gates need a season-scale list in their signed text format.
What changed
lab/stub.pygains--season-key,--season-countand--season-signer: at startup it signsevent7tickets with key idseason1and serves them at/season.txton both ports withETag,If-None-Matchand byte ranges, logging the count, size and signing time./tickets.gpband the hub's sync are unchanged.lab/compose.yamlpublishes 20000 tickets fromdcanddc2and mounts the signing key into those two services only.tests/ticket_list_verify.c, a small verifier built on the gate'sgated/verify.c, andtests/test_season_publish.py(ctestseason_publish).How to verify
On Linux with the build dependencies listed in
Dockerfile.build, run from the repository root:cmake --preset debug cmake --build --preset debug ctest --preset debug -R '^(season_publish)$' --output-on-failureThe test publishes 2,000 tickets, verifies them all with the gate verifier, checks that the first line matches a direct signing of the first ticket, and expects
signature_invalidafter tampering with a signature, ticket id or event. It also checks 304, 206 and 416 replies, the TLS port, the unchanged binary endpoints, a stub without a key (404 on/season.txt) and a missing key file. The venue default is 20,000 tickets; publishing the list does not change hub admission.背景
数据中心测试服务原来只发布二进制票单,它每条记录只有 32 字节,放不下约 159 个字符的签名条码。闸机需要一份赛季规模、采用其签名文本格式的票单。
改动
lab/stub.py新增--season-key、--season-count和--season-signer:启动时用密钥编号season1签发event7门票,在两个端口的/season.txt上提供,支持ETag、If-None-Match和字节范围,并记录票数、大小和签名耗时。/tickets.gpb和 hub 的同步都不变。lab/compose.yaml让dc和dc2发布 20000 张票,签名密钥只挂载到这两个服务。gated/verify.c的小工具tests/ticket_list_verify.c,以及测试tests/test_season_publish.py(ctest 名season_publish)。怎么验证
在 Linux 环境安装
Dockerfile.build列出的构建依赖后,从仓库根目录运行:cmake --preset debug cmake --build --preset debug ctest --preset debug -R '^(season_publish)$' --output-on-failure测试发布 2,000 张票,用闸机的验证逻辑逐张核验,确认第一行与单独签发第一张票的结果相同;篡改签名、票号或场次后,都应得到
signature_invalid。测试还检查 304、206 和 416 响应、TLS 端口、未改动的二进制端点、未配置密钥时/season.txt返回 404,以及密钥文件缺失时启动失败。场馆默认规模是 20,000 张;仅发布这份票单不改变 hub 的入场判断。