feat: P0 通知(邮件 + MeoW)与 TLS 证书监控,事件时间线与维护窗口

通知(P0-1):
- 邮件:自写 SMTP 客户端,零依赖。465 隐式 TLS / 587·25 STARTTLS、
  AUTH LOGIN+PLAIN、RFC2047 中文主题、base64 正文、多收件人;
  服务器不支持 STARTTLS 时默认拒绝明文(需显式 allowInsecure)
- MeoW:按官方文档实现,昵称寻址、msgType/htmlHeight 走查询参数、
  以响应体 status 判定成功(HTTP 恒 200)、429/404/403 可读化、
  本地限流器遵守 3s/15min/60h
- 告警:连续 N 次失败去抖 + 恢复通知 + 同轮合并 + 去抖状态持久化
  (data/notify-state.json,gitignore)+ 静默时段(跨零点)
- --test-notify 自检命令、--data-dir / SHIROKO_DATA_DIR

证书(P0-2):
- 独立 TLS 握手取 notAfter(不动既有 fetch 探测路径),默认 6 小时一次
- 面板徽标 ≤14 天黄 / ≤7 天红,阈值 14/7/3 各告一次、已过期只报最严重一档
- 单个目标可用 tls: false 关闭

事件与维护(P1-1 的后端部分):
- data/events.json 追加式事件流(最近 500 条)+ GET /api/events +
  快照内附最近 20 条;redactDetails 时脱敏
- 维护窗口:窗口内不计入可用率、不发告警、显示「维护中」徽标

测试抓到并修复的三个真 bug:
1. SMTP 空闲超时无人处理 → 服务器不响应会把探针循环挂死
2. MeoW 限流器把空历史当 0 → 第一条通知永远被自己拦掉
3. 去抖状态在无事轮次不落盘 → 连续失败计数丢失、永远达不到阈值

验证:新增 verify-notify.cjs 39 项(假 SMTP / 假 MeoW / 三轮集成 / 维护窗口 /
真实证书握手),六套合计 154 项全通过。
This commit is contained in:
tamakyi
2026-10-13 23:54:46 +08:00
parent ea846dee31
commit bdaa31f10c
17 changed files with 1545 additions and 291 deletions
+358 -280
View File
@@ -1,8 +1,8 @@
{
"prober": "shiroko-monitor-node/0.7.0",
"prober": "shiroko-monitor-node/0.10.0",
"demo": false,
"generatedAt": "2026-10-13T14:36:59.637Z",
"dataUpdatedAt": "2026-10-13T14:36:43.139Z",
"generatedAt": "2026-10-13T15:54:42.793Z",
"dataUpdatedAt": "2026-10-13T15:53:59.134Z",
"updateIntervalSec": 300,
"dataFilter": "uptimerobot",
"stats": {
@@ -10,12 +10,12 @@
"up": 5,
"down": 1,
"pending": 0,
"avgLatency": 874,
"avgLatency": 763,
"avgUptime90": 83.3,
"memory": {
"rssMB": 81.3,
"heapUsedMB": 13.8,
"heapTotalMB": 15.7
"rssMB": 67.4,
"heapUsedMB": 12.7,
"heapTotalMB": 14.2
}
},
"sources": {
@@ -23,30 +23,98 @@
"enabled": true,
"ok": true,
"error": null,
"lastSyncAt": "2026-10-13T14:36:16.338Z",
"lastSyncAt": "2026-10-13T15:51:29.877Z",
"count": 6,
"syncing": false,
"lastSyncMs": 1791902174992
"lastSyncMs": 1791906687760
}
},
"notify": {
"enabled": false,
"channels": [],
"quietHours": null,
"failureThreshold": 2,
"lastResult": {
"at": "2026-10-13T15:53:51.149Z",
"suppressed": false,
"skipped": "notify-disabled",
"results": []
}
},
"events": [
{
"t": "2026-10-13T15:53:51.142Z",
"id": "cloudflare-site",
"name": "Cloudflare 官网",
"type": "up",
"detail": "已恢复",
"maintenance": false
},
{
"t": "2026-10-13T15:52:51.476Z",
"id": "cloudflare-site",
"name": "Cloudflare 官网",
"type": "down",
"detail": "ETIMEDOUT",
"maintenance": false
},
{
"t": "2026-10-13T15:32:38.735Z",
"id": "google-dns-tcp",
"name": "Google DNS 53 端口",
"type": "down",
"detail": "TCP 连接超时",
"maintenance": false
},
{
"t": "2026-10-13T15:32:38.735Z",
"id": "cloudflare-dns-tcp",
"name": "Cloudflare 443 端口",
"type": "down",
"detail": "TCP 连接超时",
"maintenance": false
},
{
"t": "2026-10-13T15:32:34.170Z",
"id": "badssl-expired",
"name": "BadSSL 过期证书(演示离线)",
"type": "down",
"detail": "CERT_HAS_EXPIRED",
"maintenance": false
},
{
"t": "2026-10-13T15:32:34.129Z",
"id": "badssl-expired",
"name": "BadSSL 过期证书(演示离线)",
"type": "tls",
"detail": "证书剩余 -4202 天(阈值 3 天)",
"maintenance": false
},
{
"t": "2026-10-13T15:32:34.129Z",
"id": "badssl-expired",
"name": "BadSSL 过期证书(演示离线)",
"type": "tls",
"detail": "证书剩余 -4202 天(阈值 7 天)",
"maintenance": false
},
{
"t": "2026-10-13T15:32:34.129Z",
"id": "badssl-expired",
"name": "BadSSL 过期证书(演示离线)",
"type": "tls",
"detail": "证书剩余 -4202 天(阈值 14 天)",
"maintenance": false
}
],
"monitors": {
"ur-792059439": {
"status": "up",
"latency": 464,
"latency": 233,
"code": null,
"detail": "UptimeRobot:运行正常",
"lastCheck": "2026-10-13T14:34:00.000Z",
"lastCheck": "2026-10-13T15:50:00.000Z",
"history": [
{
"t": "2026-10-12T15:45:00.000Z",
"ok": true,
"ms": 392
},
{
"t": "2026-10-12T16:25:00.000Z",
"ok": true,
"ms": 288
},
{
"t": "2026-10-12T17:05:00.000Z",
"ok": true,
@@ -203,20 +271,30 @@
"ms": 271
},
{
"t": "2026-10-13T13:53:00.000Z",
"t": "2026-10-13T13:55:00.000Z",
"ok": true,
"ms": 294
"ms": 307
},
{
"t": "2026-10-13T14:34:00.000Z",
"ok": true,
"ms": 464
"ms": 463
},
{
"t": "2026-10-13T15:10:00.000Z",
"ok": true,
"ms": 260
},
{
"t": "2026-10-13T15:50:00.000Z",
"ok": true,
"ms": 233
}
],
"daily": {
"2026-10-13": {
"total": 46,
"up": 46
"total": 6,
"up": 6
}
},
"meta": {
@@ -243,186 +321,191 @@
},
"ur-795497022": {
"status": "up",
"latency": 704,
"latency": 772,
"code": null,
"detail": "UptimeRobot:运行正常",
"lastCheck": "2026-10-13T14:33:00.000Z",
"lastCheck": "2026-10-13T15:48:00.000Z",
"history": [
{
"t": "2026-10-12T15:40:00.000Z",
"ok": true,
"ms": 798
},
{
"t": "2026-10-12T16:20:00.000Z",
"ok": true,
"ms": 685
},
{
"t": "2026-10-12T17:00:00.000Z",
"t": "2026-10-12T16:35:00.000Z",
"ok": true,
"ms": 700
},
{
"t": "2026-10-12T17:40:00.000Z",
"t": "2026-10-12T17:15:00.000Z",
"ok": true,
"ms": 694
"ms": 689
},
{
"t": "2026-10-12T18:20:00.000Z",
"t": "2026-10-12T17:55:00.000Z",
"ok": true,
"ms": 703
"ms": 725
},
{
"t": "2026-10-12T19:00:00.000Z",
"t": "2026-10-12T18:35:00.000Z",
"ok": true,
"ms": 729
"ms": 744
},
{
"t": "2026-10-12T19:40:00.000Z",
"t": "2026-10-12T19:15:00.000Z",
"ok": true,
"ms": 713
"ms": 723
},
{
"t": "2026-10-12T20:20:00.000Z",
"t": "2026-10-12T19:55:00.000Z",
"ok": true,
"ms": 784
"ms": 698
},
{
"t": "2026-10-12T21:00:00.000Z",
"t": "2026-10-12T20:35:00.000Z",
"ok": true,
"ms": 628
"ms": 768
},
{
"t": "2026-10-12T21:40:00.000Z",
"t": "2026-10-12T21:15:00.000Z",
"ok": true,
"ms": 629
"ms": 616
},
{
"t": "2026-10-12T22:20:00.000Z",
"t": "2026-10-12T21:55:00.000Z",
"ok": true,
"ms": 751
"ms": 626
},
{
"t": "2026-10-12T23:00:00.000Z",
"t": "2026-10-12T22:35:00.000Z",
"ok": true,
"ms": 674
},
{
"t": "2026-10-12T23:15:00.000Z",
"ok": true,
"ms": 624
},
{
"t": "2026-10-12T23:40:00.000Z",
"t": "2026-10-12T23:55:00.000Z",
"ok": true,
"ms": 715
"ms": 640
},
{
"t": "2026-10-13T00:20:00.000Z",
"t": "2026-10-13T00:35:00.000Z",
"ok": true,
"ms": 683
"ms": 673
},
{
"t": "2026-10-13T01:00:00.000Z",
"ok": true,
"ms": 643
},
{
"t": "2026-10-13T01:40:00.000Z",
"ok": true,
"ms": 641
},
{
"t": "2026-10-13T02:20:00.000Z",
"t": "2026-10-13T01:15:00.000Z",
"ok": true,
"ms": 609
},
{
"t": "2026-10-13T03:00:00.000Z",
"t": "2026-10-13T01:55:00.000Z",
"ok": true,
"ms": 606
"ms": 759
},
{
"t": "2026-10-13T03:40:00.000Z",
"t": "2026-10-13T02:35:00.000Z",
"ok": true,
"ms": 720
"ms": 581
},
{
"t": "2026-10-13T04:20:00.000Z",
"t": "2026-10-13T03:15:00.000Z",
"ok": true,
"ms": 711
"ms": 666
},
{
"t": "2026-10-13T05:00:00.000Z",
"t": "2026-10-13T03:55:00.000Z",
"ok": true,
"ms": 598
"ms": 662
},
{
"t": "2026-10-13T05:40:00.000Z",
"t": "2026-10-13T04:35:00.000Z",
"ok": true,
"ms": 729
"ms": 685
},
{
"t": "2026-10-13T06:20:00.000Z",
"t": "2026-10-13T05:15:00.000Z",
"ok": true,
"ms": 676
"ms": 647
},
{
"t": "2026-10-13T07:00:00.000Z",
"t": "2026-10-13T05:55:00.000Z",
"ok": true,
"ms": 691
"ms": 588
},
{
"t": "2026-10-13T07:40:00.000Z",
"t": "2026-10-13T06:40:00.000Z",
"ok": true,
"ms": 696
"ms": 625
},
{
"t": "2026-10-13T08:20:00.000Z",
"t": "2026-10-13T07:20:00.000Z",
"ok": true,
"ms": 677
"ms": 673
},
{
"t": "2026-10-13T09:00:00.000Z",
"t": "2026-10-13T08:00:00.000Z",
"ok": true,
"ms": 969
"ms": 758
},
{
"t": "2026-10-13T09:40:00.000Z",
"t": "2026-10-13T08:40:00.000Z",
"ok": true,
"ms": 669
"ms": 826
},
{
"t": "2026-10-13T10:20:00.000Z",
"t": "2026-10-13T09:20:00.000Z",
"ok": true,
"ms": 840
"ms": 749
},
{
"t": "2026-10-13T11:00:00.000Z",
"t": "2026-10-13T10:00:00.000Z",
"ok": true,
"ms": 735
"ms": 791
},
{
"t": "2026-10-13T11:40:00.000Z",
"t": "2026-10-13T10:40:00.000Z",
"ok": true,
"ms": 693
"ms": 678
},
{
"t": "2026-10-13T12:20:00.000Z",
"t": "2026-10-13T11:20:00.000Z",
"ok": true,
"ms": 793
"ms": 740
},
{
"t": "2026-10-13T13:56:00.000Z",
"t": "2026-10-13T12:00:00.000Z",
"ok": true,
"ms": 1056
"ms": 828
},
{
"t": "2026-10-13T14:33:00.000Z",
"t": "2026-10-13T12:40:00.000Z",
"ok": true,
"ms": 704
"ms": 722
},
{
"t": "2026-10-13T13:20:00.000Z",
"ok": true,
"ms": 849
},
{
"t": "2026-10-13T14:43:00.000Z",
"ok": true,
"ms": 845
},
{
"t": "2026-10-13T15:15:00.000Z",
"ok": true,
"ms": 857
},
{
"t": "2026-10-13T15:48:00.000Z",
"ok": true,
"ms": 772
}
],
"daily": {
"2026-10-13": {
"total": 46,
"up": 46
"total": 6,
"up": 6
}
},
"meta": {
@@ -449,21 +532,11 @@
},
"ur-795556828": {
"status": "up",
"latency": 338,
"latency": 230,
"code": null,
"detail": "UptimeRobot:运行正常",
"lastCheck": "2026-10-13T14:34:00.000Z",
"lastCheck": "2026-10-13T15:50:00.000Z",
"history": [
{
"t": "2026-10-12T15:35:00.000Z",
"ok": true,
"ms": 275
},
{
"t": "2026-10-12T16:15:00.000Z",
"ok": true,
"ms": 450
},
{
"t": "2026-10-12T16:55:00.000Z",
"ok": true,
@@ -620,20 +693,30 @@
"ms": 413
},
{
"t": "2026-10-13T13:54:00.000Z",
"t": "2026-10-13T13:55:00.000Z",
"ok": true,
"ms": 187
"ms": 283
},
{
"t": "2026-10-13T14:34:00.000Z",
"ok": true,
"ms": 338
"ms": 333
},
{
"t": "2026-10-13T15:10:00.000Z",
"ok": true,
"ms": 510
},
{
"t": "2026-10-13T15:50:00.000Z",
"ok": true,
"ms": 230
}
],
"daily": {
"2026-10-13": {
"total": 46,
"up": 46
"total": 6,
"up": 6
}
},
"meta": {
@@ -660,21 +743,11 @@
},
"ur-792059414": {
"status": "up",
"latency": 2424,
"latency": 2238,
"code": null,
"detail": "UptimeRobot:运行正常",
"lastCheck": "2026-10-13T14:34:00.000Z",
"lastCheck": "2026-10-13T15:48:00.000Z",
"history": [
{
"t": "2026-10-12T15:40:00.000Z",
"ok": true,
"ms": 2901
},
{
"t": "2026-10-12T16:25:00.000Z",
"ok": true,
"ms": 2402
},
{
"t": "2026-10-12T17:10:00.000Z",
"ok": true,
@@ -796,45 +869,50 @@
"ms": 1597
},
{
"t": "2026-10-13T10:35:00.000Z",
"t": "2026-10-13T10:40:00.000Z",
"ok": true,
"ms": 3015
"ms": 2816
},
{
"t": "2026-10-13T11:15:00.000Z",
"t": "2026-10-13T11:25:00.000Z",
"ok": true,
"ms": 1965
"ms": 1912
},
{
"t": "2026-10-13T11:55:00.000Z",
"t": "2026-10-13T12:10:00.000Z",
"ok": true,
"ms": 2118
"ms": 2326
},
{
"t": "2026-10-13T12:35:00.000Z",
"t": "2026-10-13T12:55:00.000Z",
"ok": true,
"ms": 2557
"ms": 2938
},
{
"t": "2026-10-13T13:15:00.000Z",
"t": "2026-10-13T13:40:00.000Z",
"ok": true,
"ms": 1671
"ms": 3146
},
{
"t": "2026-10-13T13:55:00.000Z",
"t": "2026-10-13T14:25:00.000Z",
"ok": true,
"ms": 1908
"ms": 2125
},
{
"t": "2026-10-13T14:34:00.000Z",
"t": "2026-10-13T15:08:00.000Z",
"ok": true,
"ms": 2424
"ms": 2892
},
{
"t": "2026-10-13T15:48:00.000Z",
"ok": true,
"ms": 2238
}
],
"daily": {
"2026-10-13": {
"total": 46,
"up": 46
"total": 6,
"up": 6
}
},
"meta": {
@@ -861,191 +939,191 @@
},
"ur-798788113": {
"status": "up",
"latency": 438,
"latency": 340,
"code": null,
"detail": "UptimeRobot:运行正常",
"lastCheck": "2026-10-13T14:35:00.000Z",
"lastCheck": "2026-10-13T15:46:00.000Z",
"history": [
{
"t": "2026-10-12T15:45:00.000Z",
"t": "2026-10-12T16:50:00.000Z",
"ok": true,
"ms": 462
"ms": 463
},
{
"t": "2026-10-12T16:25:00.000Z",
"t": "2026-10-12T17:30:00.000Z",
"ok": true,
"ms": 288
"ms": 320
},
{
"t": "2026-10-12T17:05:00.000Z",
"t": "2026-10-12T18:10:00.000Z",
"ok": true,
"ms": 409
"ms": 404
},
{
"t": "2026-10-12T17:50:00.000Z",
"ok": true,
"ms": 312
},
{
"t": "2026-10-12T18:30:00.000Z",
"ok": true,
"ms": 472
},
{
"t": "2026-10-12T19:10:00.000Z",
"ok": true,
"ms": 421
},
{
"t": "2026-10-12T19:50:00.000Z",
"ok": true,
"ms": 332
},
{
"t": "2026-10-12T20:30:00.000Z",
"ok": true,
"ms": 310
},
{
"t": "2026-10-12T21:10:00.000Z",
"ok": true,
"ms": 436
},
{
"t": "2026-10-12T21:50:00.000Z",
"ok": true,
"ms": 338
},
{
"t": "2026-10-12T22:30:00.000Z",
"ok": true,
"ms": 423
},
{
"t": "2026-10-12T23:10:00.000Z",
"ok": true,
"ms": 247
},
{
"t": "2026-10-12T23:50:00.000Z",
"ok": true,
"ms": 296
},
{
"t": "2026-10-13T00:30:00.000Z",
"ok": true,
"ms": 239
},
{
"t": "2026-10-13T01:10:00.000Z",
"ok": true,
"ms": 393
},
{
"t": "2026-10-13T01:50:00.000Z",
"ok": true,
"ms": 346
},
{
"t": "2026-10-13T02:30:00.000Z",
"ok": true,
"ms": 441
},
{
"t": "2026-10-13T03:10:00.000Z",
"ok": true,
"ms": 443
},
{
"t": "2026-10-13T03:50:00.000Z",
"ok": true,
"ms": 382
},
{
"t": "2026-10-13T04:30:00.000Z",
"ok": true,
"ms": 355
},
{
"t": "2026-10-13T05:10:00.000Z",
"ok": true,
"ms": 414
},
{
"t": "2026-10-13T05:50:00.000Z",
"t": "2026-10-12T18:50:00.000Z",
"ok": true,
"ms": 343
},
{
"t": "2026-10-13T06:30:00.000Z",
"t": "2026-10-12T19:30:00.000Z",
"ok": true,
"ms": 434
"ms": 476
},
{
"t": "2026-10-13T07:10:00.000Z",
"t": "2026-10-12T20:10:00.000Z",
"ok": true,
"ms": 444
"ms": 285
},
{
"t": "2026-10-13T07:50:00.000Z",
"t": "2026-10-12T20:50:00.000Z",
"ok": true,
"ms": 281
"ms": 449
},
{
"t": "2026-10-13T08:30:00.000Z",
"t": "2026-10-12T21:30:00.000Z",
"ok": true,
"ms": 453
"ms": 332
},
{
"t": "2026-10-13T09:15:00.000Z",
"t": "2026-10-12T22:10:00.000Z",
"ok": true,
"ms": 333
"ms": 450
},
{
"t": "2026-10-13T09:55:00.000Z",
"t": "2026-10-12T22:50:00.000Z",
"ok": true,
"ms": 602
"ms": 231
},
{
"t": "2026-10-13T10:35:00.000Z",
"t": "2026-10-12T23:30:00.000Z",
"ok": true,
"ms": 519
"ms": 249
},
{
"t": "2026-10-13T11:15:00.000Z",
"t": "2026-10-13T00:10:00.000Z",
"ok": true,
"ms": 325
"ms": 286
},
{
"t": "2026-10-13T11:55:00.000Z",
"t": "2026-10-13T00:50:00.000Z",
"ok": true,
"ms": 933
"ms": 223
},
{
"t": "2026-10-13T12:35:00.000Z",
"t": "2026-10-13T01:30:00.000Z",
"ok": true,
"ms": 424
"ms": 386
},
{
"t": "2026-10-13T13:15:00.000Z",
"t": "2026-10-13T02:10:00.000Z",
"ok": true,
"ms": 460
"ms": 511
},
{
"t": "2026-10-13T13:55:00.000Z",
"t": "2026-10-13T02:50:00.000Z",
"ok": true,
"ms": 328
"ms": 292
},
{
"t": "2026-10-13T14:35:00.000Z",
"t": "2026-10-13T03:30:00.000Z",
"ok": true,
"ms": 438
"ms": 435
},
{
"t": "2026-10-13T04:15:00.000Z",
"ok": true,
"ms": 400
},
{
"t": "2026-10-13T04:55:00.000Z",
"ok": true,
"ms": 462
},
{
"t": "2026-10-13T05:35:00.000Z",
"ok": true,
"ms": 377
},
{
"t": "2026-10-13T06:15:00.000Z",
"ok": true,
"ms": 396
},
{
"t": "2026-10-13T06:55:00.000Z",
"ok": true,
"ms": 310
},
{
"t": "2026-10-13T07:35:00.000Z",
"ok": true,
"ms": 336
},
{
"t": "2026-10-13T08:15:00.000Z",
"ok": true,
"ms": 379
},
{
"t": "2026-10-13T08:55:00.000Z",
"ok": true,
"ms": 476
},
{
"t": "2026-10-13T09:35:00.000Z",
"ok": true,
"ms": 605
},
{
"t": "2026-10-13T10:15:00.000Z",
"ok": true,
"ms": 456
},
{
"t": "2026-10-13T10:55:00.000Z",
"ok": true,
"ms": 420
},
{
"t": "2026-10-13T11:35:00.000Z",
"ok": true,
"ms": 878
},
{
"t": "2026-10-13T12:15:00.000Z",
"ok": true,
"ms": 530
},
{
"t": "2026-10-13T12:55:00.000Z",
"ok": true,
"ms": 517
},
{
"t": "2026-10-13T13:35:00.000Z",
"ok": true,
"ms": 491
},
{
"t": "2026-10-13T14:20:00.000Z",
"ok": true,
"ms": 429
},
{
"t": "2026-10-13T15:06:00.000Z",
"ok": true,
"ms": 443
},
{
"t": "2026-10-13T15:46:00.000Z",
"ok": true,
"ms": 340
}
],
"daily": {
"2026-10-13": {
"total": 46,
"up": 46
"total": 6,
"up": 6
}
},
"meta": {
@@ -1085,7 +1163,7 @@
],
"daily": {
"2026-10-13": {
"total": 46,
"total": 6,
"up": 0
}
},