feat: v0.12.0 —— 表格每行绝对等高 + 管理 WebUI(2FA 绑定才能进入)

① 每行绝对等高
- 行高与内容长度彻底解耦:新增 --row-h: 72px 作为唯一基准
- 名称列改为「文本区限两行 + 徽标区固定单行」两段式;文本区用 .clamp2
- 关键点:必须用 height 而非 max-height —— 后者会让短内容缩成一行、
  长内容撑到两行,反而产生 66px/71px 两种行高(实测踩过)
- 分组标题行用 :not(.group-row) 排除在数据行规则之外
- 事件表与监控表格共用同一个 --row-h,两张表视觉上也严格对齐
- 完整值仍可通过悬停 title 查看(已加断言强制所有截断单元格带 title)
- 卡片视图同样等高(13 视口 × 250px 全一致)

② 管理 WebUI + 2FA
- 新增 /admin 与 /api/admin/*;未绑定 2FA 时除绑定流程外一律 403
- 零依赖实现 TOTP(RFC 6238),用 RFC 4226/6238 官方测试向量验证(16 个向量)
- 内置 QR 码生成器(byte 模式 / ECC L / 版本 1-10,GF(256) RS 纠错 + 掩码评分),
  用独立解码器实测:版本 1 与版本 6 均能读出逐字节一致的内容
- 绑定流程:口令 → 生成密钥(扫码/手输/otpauth 链接)→ 验证 6 位码 → 10 枚恢复码;
  完成后凭本次验证码直接换取会话
- 安全:会话 id 32 字节随机数且服务端只存哈希;HttpOnly+SameSite=Strict;
  30 分钟空闲/2 小时最长;同时间步的码防重放;恢复码一次性;
  登录失败按 IP 指数退避锁定;不解析 X-Forwarded-For
- 管理功能:运行状态、探测范围、展示口径、维护窗口增删、立即重探、通知自检、
  目标只读列表、最近事件
- 所有写操作只落 local.monitors.json(私有不入库),绝不改 public/monitors.json

过程中修掉三个真 bug:
1. 会话 cookie 的 Path=/admin 覆盖不到 /api/admin/*,登录 200 但后续全部 401
2. 恢复码登录被 verifyTotp 的 invalid-format 提前挡掉(恢复码非 6 位数字)
3. 超大请求体用 req.destroy() 硬断连接,客户端只看到 fetch failed 拿不到状态码

测试:新增 scripts/verify-admin.cjs(102 项),全项目共 7 套 274 项全部通过
This commit is contained in:
tamakyi
2026-10-14 12:37:07 +08:00
parent a3a683ff0e
commit 752fad412b
20 changed files with 2631 additions and 339 deletions
+303 -303
View File
@@ -1,22 +1,22 @@
{
"prober": "shiroko-monitor-node/0.11.1",
"prober": "shiroko-monitor-node/0.12.0",
"demo": false,
"generatedAt": "2026-10-14T02:48:57.258Z",
"dataUpdatedAt": "2026-10-14T02:45:46.268Z",
"generatedAt": "2026-10-14T04:36:38.881Z",
"dataUpdatedAt": "2026-10-14T04:36:26.361Z",
"updateIntervalSec": 300,
"dataFilter": "uptimerobot",
"probeScope": "uptimerobot",
"probeScope": "all",
"stats": {
"total": 6,
"up": 5,
"down": 1,
"pending": 0,
"avgLatency": 735,
"avgLatency": 755,
"avgUptime90": 83.3,
"memory": {
"rssMB": 64.5,
"heapUsedMB": 11.2,
"heapTotalMB": 14.2
"rssMB": 80.2,
"heapUsedMB": 10.8,
"heapTotalMB": 15
}
},
"sources": {
@@ -24,10 +24,10 @@
"enabled": true,
"ok": true,
"error": null,
"lastSyncAt": "2026-10-14T02:45:46.268Z",
"lastSyncAt": "2026-10-14T04:33:06.976Z",
"count": 6,
"syncing": false,
"lastSyncMs": 1791945944983
"lastSyncMs": 1791952385563
}
},
"notify": {
@@ -55,21 +55,11 @@
"monitors": {
"ur-792059439": {
"status": "up",
"latency": 190,
"latency": 99,
"code": null,
"detail": "UptimeRobot:运行正常",
"lastCheck": "2026-10-14T02:41:00.000Z",
"lastCheck": "2026-10-14T04:33:00.000Z",
"history": [
{
"t": "2026-10-13T03:50:00.000Z",
"ok": true,
"ms": 104
},
{
"t": "2026-10-13T04:35:00.000Z",
"ok": true,
"ms": 478
},
{
"t": "2026-10-13T05:15:00.000Z",
"ok": true,
@@ -226,23 +216,38 @@
"ms": 421
},
{
"t": "2026-10-14T02:05:00.000Z",
"t": "2026-10-14T02:00:00.000Z",
"ok": true,
"ms": 272
"ms": 191
},
{
"t": "2026-10-14T02:41:00.000Z",
"t": "2026-10-14T02:40:00.000Z",
"ok": true,
"ms": 190
"ms": 187
},
{
"t": "2026-10-14T03:20:00.000Z",
"ok": true,
"ms": 282
},
{
"t": "2026-10-14T03:57:00.000Z",
"ok": true,
"ms": 321
},
{
"t": "2026-10-14T04:33:00.000Z",
"ok": true,
"ms": 99
}
],
"daily": {
"2026-10-14": {
"total": 7,
"up": 7,
"latSum": 1758,
"latCount": 7,
"latMax": 326
"total": 4,
"up": 4,
"latSum": 690,
"latCount": 4,
"latMax": 197
}
},
"meta": {
@@ -267,38 +272,23 @@
"90": 0
},
"lat": {
"avg": 251,
"max": 326,
"avg": 173,
"max": 197,
"days": [
{
"key": "2026-10-14",
"avg": 251
"avg": 173
}
]
}
},
"ur-795497022": {
"status": "up",
"latency": 811,
"latency": 619,
"code": null,
"detail": "UptimeRobot:运行正常",
"lastCheck": "2026-10-14T02:45:00.000Z",
"lastCheck": "2026-10-14T04:32:00.000Z",
"history": [
{
"t": "2026-10-13T03:35:00.000Z",
"ok": true,
"ms": 726
},
{
"t": "2026-10-13T04:15:00.000Z",
"ok": true,
"ms": 690
},
{
"t": "2026-10-13T04:55:00.000Z",
"ok": true,
"ms": 653
},
{
"t": "2026-10-13T05:35:00.000Z",
"ok": true,
@@ -445,28 +435,38 @@
"ms": 676
},
{
"t": "2026-10-14T01:31:00.000Z",
"t": "2026-10-14T01:00:00.000Z",
"ok": true,
"ms": 802
"ms": 755
},
{
"t": "2026-10-14T02:08:00.000Z",
"t": "2026-10-14T01:40:00.000Z",
"ok": true,
"ms": 634
"ms": 658
},
{
"t": "2026-10-14T02:45:00.000Z",
"t": "2026-10-14T02:20:00.000Z",
"ok": true,
"ms": 811
"ms": 740
},
{
"t": "2026-10-14T03:55:00.000Z",
"ok": true,
"ms": 631
},
{
"t": "2026-10-14T04:32:00.000Z",
"ok": true,
"ms": 619
}
],
"daily": {
"2026-10-14": {
"total": 7,
"up": 7,
"latSum": 5767,
"latCount": 7,
"latMax": 845
"total": 4,
"up": 4,
"latSum": 2484,
"latCount": 4,
"latMax": 627
}
},
"meta": {
@@ -491,33 +491,23 @@
"90": 5432
},
"lat": {
"avg": 824,
"max": 845,
"avg": 621,
"max": 627,
"days": [
{
"key": "2026-10-14",
"avg": 824
"avg": 621
}
]
}
},
"ur-795556828": {
"status": "up",
"latency": 448,
"latency": 335,
"code": null,
"detail": "UptimeRobot:运行正常",
"lastCheck": "2026-10-14T02:41:00.000Z",
"lastCheck": "2026-10-14T04:28:00.000Z",
"history": [
{
"t": "2026-10-13T03:45:00.000Z",
"ok": true,
"ms": 229
},
{
"t": "2026-10-13T04:30:00.000Z",
"ok": true,
"ms": 234
},
{
"t": "2026-10-13T05:10:00.000Z",
"ok": true,
@@ -554,143 +544,158 @@
"ms": 256
},
{
"t": "2026-10-13T09:55:00.000Z",
"t": "2026-10-13T09:50:00.000Z",
"ok": true,
"ms": 455
"ms": 500
},
{
"t": "2026-10-13T10:35:00.000Z",
"t": "2026-10-13T10:30:00.000Z",
"ok": true,
"ms": 372
"ms": 337
},
{
"t": "2026-10-13T11:15:00.000Z",
"t": "2026-10-13T11:10:00.000Z",
"ok": true,
"ms": 240
"ms": 197
},
{
"t": "2026-10-13T11:55:00.000Z",
"t": "2026-10-13T11:50:00.000Z",
"ok": true,
"ms": 261
"ms": 344
},
{
"t": "2026-10-13T12:35:00.000Z",
"t": "2026-10-13T12:30:00.000Z",
"ok": true,
"ms": 335
"ms": 341
},
{
"t": "2026-10-13T13:15:00.000Z",
"t": "2026-10-13T13:10:00.000Z",
"ok": true,
"ms": 413
"ms": 347
},
{
"t": "2026-10-13T13:55:00.000Z",
"t": "2026-10-13T13:50:00.000Z",
"ok": true,
"ms": 283
"ms": 220
},
{
"t": "2026-10-13T14:35:00.000Z",
"ok": true,
"ms": 309
},
{
"t": "2026-10-13T15:20:00.000Z",
"ok": true,
"ms": 451
},
{
"t": "2026-10-13T16:00:00.000Z",
"ok": true,
"ms": 248
},
{
"t": "2026-10-13T16:40:00.000Z",
"ok": true,
"ms": 378
},
{
"t": "2026-10-13T17:20:00.000Z",
"ok": true,
"ms": 293
},
{
"t": "2026-10-13T18:00:00.000Z",
"ok": true,
"ms": 495
},
{
"t": "2026-10-13T18:40:00.000Z",
"ok": true,
"ms": 391
},
{
"t": "2026-10-13T19:20:00.000Z",
"t": "2026-10-13T14:30:00.000Z",
"ok": true,
"ms": 338
},
{
"t": "2026-10-13T20:00:00.000Z",
"t": "2026-10-13T15:10:00.000Z",
"ok": true,
"ms": 363
"ms": 510
},
{
"t": "2026-10-13T20:40:00.000Z",
"t": "2026-10-13T15:50:00.000Z",
"ok": true,
"ms": 499
"ms": 230
},
{
"t": "2026-10-13T21:20:00.000Z",
"t": "2026-10-13T16:30:00.000Z",
"ok": true,
"ms": 372
"ms": 401
},
{
"t": "2026-10-13T22:00:00.000Z",
"t": "2026-10-13T17:10:00.000Z",
"ok": true,
"ms": 194
"ms": 302
},
{
"t": "2026-10-13T22:40:00.000Z",
"t": "2026-10-13T17:50:00.000Z",
"ok": true,
"ms": 225
"ms": 495
},
{
"t": "2026-10-13T23:20:00.000Z",
"t": "2026-10-13T18:30:00.000Z",
"ok": true,
"ms": 237
"ms": 389
},
{
"t": "2026-10-14T00:00:00.000Z",
"t": "2026-10-13T19:10:00.000Z",
"ok": true,
"ms": 328
},
{
"t": "2026-10-13T19:50:00.000Z",
"ok": true,
"ms": 338
},
{
"t": "2026-10-13T20:35:00.000Z",
"ok": true,
"ms": 423
},
{
"t": "2026-10-13T21:15:00.000Z",
"ok": true,
"ms": 394
},
{
"t": "2026-10-13T21:55:00.000Z",
"ok": true,
"ms": 214
},
{
"t": "2026-10-13T22:35:00.000Z",
"ok": true,
"ms": 240
},
{
"t": "2026-10-13T23:15:00.000Z",
"ok": true,
"ms": 215
},
{
"t": "2026-10-14T00:40:00.000Z",
"t": "2026-10-13T23:55:00.000Z",
"ok": true,
"ms": 298
"ms": 240
},
{
"t": "2026-10-14T01:20:00.000Z",
"t": "2026-10-14T00:35:00.000Z",
"ok": true,
"ms": 450
"ms": 329
},
{
"t": "2026-10-14T02:05:00.000Z",
"t": "2026-10-14T01:15:00.000Z",
"ok": true,
"ms": 229
"ms": 387
},
{
"t": "2026-10-14T02:41:00.000Z",
"t": "2026-10-14T01:55:00.000Z",
"ok": true,
"ms": 448
"ms": 337
},
{
"t": "2026-10-14T02:35:00.000Z",
"ok": true,
"ms": 381
},
{
"t": "2026-10-14T03:15:00.000Z",
"ok": true,
"ms": 355
},
{
"t": "2026-10-14T03:52:00.000Z",
"ok": true,
"ms": 538
},
{
"t": "2026-10-14T04:28:00.000Z",
"ok": true,
"ms": 335
}
],
"daily": {
"2026-10-14": {
"total": 7,
"up": 7,
"latSum": 2113,
"latCount": 7,
"latMax": 448
"total": 4,
"up": 4,
"latSum": 1352,
"latCount": 4,
"latMax": 339
}
},
"meta": {
@@ -715,33 +720,23 @@
"90": 0
},
"lat": {
"avg": 302,
"max": 448,
"avg": 338,
"max": 339,
"days": [
{
"key": "2026-10-14",
"avg": 302
"avg": 338
}
]
}
},
"ur-792059414": {
"status": "up",
"latency": 1795,
"latency": 2408,
"code": null,
"detail": "UptimeRobot:运行正常",
"lastCheck": "2026-10-14T02:40:00.000Z",
"lastCheck": "2026-10-14T04:27:00.000Z",
"history": [
{
"t": "2026-10-13T03:55:00.000Z",
"ok": true,
"ms": 2124
},
{
"t": "2026-10-13T04:40:00.000Z",
"ok": true,
"ms": 2623
},
{
"t": "2026-10-13T05:25:00.000Z",
"ok": true,
@@ -868,38 +863,48 @@
"ms": 2418
},
{
"t": "2026-10-14T00:00:00.000Z",
"t": "2026-10-14T00:05:00.000Z",
"ok": true,
"ms": 1947
"ms": 2098
},
{
"t": "2026-10-14T00:40:00.000Z",
"t": "2026-10-14T00:50:00.000Z",
"ok": true,
"ms": 2257
"ms": 1921
},
{
"t": "2026-10-14T01:20:00.000Z",
"t": "2026-10-14T01:35:00.000Z",
"ok": true,
"ms": 2605
"ms": 3110
},
{
"t": "2026-10-14T02:01:00.000Z",
"t": "2026-10-14T02:20:00.000Z",
"ok": true,
"ms": 2591
"ms": 1719
},
{
"t": "2026-10-14T02:40:00.000Z",
"t": "2026-10-14T03:05:00.000Z",
"ok": true,
"ms": 1795
"ms": 1623
},
{
"t": "2026-10-14T03:48:00.000Z",
"ok": true,
"ms": 3512
},
{
"t": "2026-10-14T04:27:00.000Z",
"ok": true,
"ms": 2408
}
],
"daily": {
"2026-10-14": {
"total": 7,
"up": 7,
"latSum": 12076,
"latCount": 7,
"latMax": 1795
"total": 4,
"up": 4,
"latSum": 10418,
"latCount": 4,
"latMax": 2670
}
},
"meta": {
@@ -924,206 +929,206 @@
"90": 7593
},
"lat": {
"avg": 1725,
"max": 1795,
"avg": 2605,
"max": 2670,
"days": [
{
"key": "2026-10-14",
"avg": 1725
"avg": 2605
}
]
}
},
"ur-798788113": {
"status": "up",
"latency": 433,
"latency": 312,
"code": null,
"detail": "UptimeRobot:运行正常",
"lastCheck": "2026-10-14T02:42:00.000Z",
"lastCheck": "2026-10-14T04:29:00.000Z",
"history": [
{
"t": "2026-10-13T04:00:00.000Z",
"ok": true,
"ms": 400
},
{
"t": "2026-10-13T04:40:00.000Z",
"ok": true,
"ms": 357
},
{
"t": "2026-10-13T05:20:00.000Z",
"ok": true,
"ms": 372
},
{
"t": "2026-10-13T06:00:00.000Z",
"ok": true,
"ms": 426
},
{
"t": "2026-10-13T06:40:00.000Z",
"ok": true,
"ms": 314
},
{
"t": "2026-10-13T07:20:00.000Z",
"t": "2026-10-13T05:30:00.000Z",
"ok": true,
"ms": 449
},
{
"t": "2026-10-13T08:00:00.000Z",
"t": "2026-10-13T06:10:00.000Z",
"ok": true,
"ms": 279
"ms": 386
},
{
"t": "2026-10-13T08:40:00.000Z",
"t": "2026-10-13T06:50:00.000Z",
"ok": true,
"ms": 407
"ms": 311
},
{
"t": "2026-10-13T09:20:00.000Z",
"t": "2026-10-13T07:30:00.000Z",
"ok": true,
"ms": 317
"ms": 384
},
{
"t": "2026-10-13T10:00:00.000Z",
"t": "2026-10-13T08:10:00.000Z",
"ok": true,
"ms": 627
"ms": 390
},
{
"t": "2026-10-13T10:40:00.000Z",
"t": "2026-10-13T08:50:00.000Z",
"ok": true,
"ms": 505
"ms": 461
},
{
"t": "2026-10-13T11:20:00.000Z",
"t": "2026-10-13T09:30:00.000Z",
"ok": true,
"ms": 424
"ms": 545
},
{
"t": "2026-10-13T12:00:00.000Z",
"t": "2026-10-13T10:10:00.000Z",
"ok": true,
"ms": 1135
"ms": 456
},
{
"t": "2026-10-13T12:40:00.000Z",
"t": "2026-10-13T10:50:00.000Z",
"ok": true,
"ms": 462
"ms": 394
},
{
"t": "2026-10-13T13:20:00.000Z",
"t": "2026-10-13T11:30:00.000Z",
"ok": true,
"ms": 436
"ms": 398
},
{
"t": "2026-10-13T14:00:00.000Z",
"t": "2026-10-13T12:10:00.000Z",
"ok": true,
"ms": 521
"ms": 588
},
{
"t": "2026-10-13T14:40:00.000Z",
"t": "2026-10-13T12:50:00.000Z",
"ok": true,
"ms": 480
"ms": 430
},
{
"t": "2026-10-13T15:20:00.000Z",
"t": "2026-10-13T13:30:00.000Z",
"ok": true,
"ms": 462
"ms": 502
},
{
"t": "2026-10-13T16:00:00.000Z",
"t": "2026-10-13T14:15:00.000Z",
"ok": true,
"ms": 331
"ms": 355
},
{
"t": "2026-10-13T16:40:00.000Z",
"t": "2026-10-13T14:55:00.000Z",
"ok": true,
"ms": 373
"ms": 358
},
{
"t": "2026-10-13T17:20:00.000Z",
"t": "2026-10-13T15:35:00.000Z",
"ok": true,
"ms": 429
"ms": 385
},
{
"t": "2026-10-13T18:00:00.000Z",
"t": "2026-10-13T16:15:00.000Z",
"ok": true,
"ms": 558
"ms": 342
},
{
"t": "2026-10-13T18:40:00.000Z",
"t": "2026-10-13T16:55:00.000Z",
"ok": true,
"ms": 370
"ms": 428
},
{
"t": "2026-10-13T19:20:00.000Z",
"t": "2026-10-13T17:35:00.000Z",
"ok": true,
"ms": 1519
"ms": 508
},
{
"t": "2026-10-13T20:00:00.000Z",
"t": "2026-10-13T18:15:00.000Z",
"ok": true,
"ms": 483
"ms": 602
},
{
"t": "2026-10-13T20:40:00.000Z",
"ok": true,
"ms": 388
},
{
"t": "2026-10-13T21:20:00.000Z",
"ok": true,
"ms": 367
},
{
"t": "2026-10-13T22:00:00.000Z",
"ok": true,
"ms": 273
},
{
"t": "2026-10-13T22:40:00.000Z",
"ok": true,
"ms": 261
},
{
"t": "2026-10-13T23:20:00.000Z",
"ok": true,
"ms": 263
},
{
"t": "2026-10-14T00:00:00.000Z",
"ok": true,
"ms": 229
},
{
"t": "2026-10-14T00:40:00.000Z",
"t": "2026-10-13T18:55:00.000Z",
"ok": true,
"ms": 363
},
{
"t": "2026-10-14T01:20:00.000Z",
"t": "2026-10-13T19:40:00.000Z",
"ok": true,
"ms": 329
"ms": 1380
},
{
"t": "2026-10-14T02:06:00.000Z",
"t": "2026-10-13T20:20:00.000Z",
"ok": true,
"ms": 234
"ms": 512
},
{
"t": "2026-10-14T02:42:00.000Z",
"t": "2026-10-13T21:00:00.000Z",
"ok": true,
"ms": 433
"ms": 394
},
{
"t": "2026-10-13T21:40:00.000Z",
"ok": true,
"ms": 238
},
{
"t": "2026-10-13T22:20:00.000Z",
"ok": true,
"ms": 323
},
{
"t": "2026-10-13T23:00:00.000Z",
"ok": true,
"ms": 353
},
{
"t": "2026-10-13T23:40:00.000Z",
"ok": true,
"ms": 179
},
{
"t": "2026-10-14T00:20:00.000Z",
"ok": true,
"ms": 263
},
{
"t": "2026-10-14T01:00:00.000Z",
"ok": true,
"ms": 381
},
{
"t": "2026-10-14T01:40:00.000Z",
"ok": true,
"ms": 378
},
{
"t": "2026-10-14T02:20:00.000Z",
"ok": true,
"ms": 278
},
{
"t": "2026-10-14T03:17:00.000Z",
"ok": true,
"ms": 345
},
{
"t": "2026-10-14T03:53:00.000Z",
"ok": true,
"ms": 259
},
{
"t": "2026-10-14T04:29:00.000Z",
"ok": true,
"ms": 312
}
],
"daily": {
"2026-10-14": {
"total": 7,
"up": 7,
"latSum": 2680,
"latCount": 7,
"latMax": 435
"total": 4,
"up": 4,
"latSum": 1245,
"latCount": 4,
"latMax": 323
}
},
"meta": {
@@ -1148,12 +1153,12 @@
"90": 0
},
"lat": {
"avg": 383,
"max": 435,
"avg": 311,
"max": 323,
"days": [
{
"key": "2026-10-14",
"avg": 383
"avg": 311
}
]
}
@@ -1165,11 +1170,6 @@
"detail": "UptimeRobot:403 Forbidden",
"lastCheck": "2026-05-07T07:54:09.000Z",
"history": [
{
"t": "2026-10-13T19:25:00.000Z",
"ok": true,
"ms": 185
},
{
"t": "2026-05-07T07:54:09.000Z",
"ok": false,
@@ -1178,7 +1178,7 @@
],
"daily": {
"2026-10-14": {
"total": 7,
"total": 4,
"up": 0
}
},