A modern and elegant dashboard for network traffic visualization and analysis.
release: v1.3.10 — deep-review fixes (retention, rule naming, dark mode, perf)
luolei78168bc31a89
diff --git a/.env.example b/.env.exampleindex d14a944..704cc7d 100644--- a/.env.example+++ b/.env.example@@ -66,6 +66,11 @@ WS_EXTERNAL_PORT=3002# 采集器重连退避上限(指数退避 + 抖动,避免重连风暴)# WS_MAX_RECONNECT_INTERVAL_MS=60000+# WebSocket 推送背压阈值:出站缓冲超过该字节数的慢客户端跳过本轮推送+# WS_MAX_BUFFERED_BYTES=4194304+# 规则链路图 DAG 源数据行数上限(按流量取 Top-N)+# RULE_CHAIN_FLOW_MAX_ROWS=2000+# 数据库路径# DB_PATH=/app/data/stats.dbdiff --git a/CHANGELOG.en.md b/CHANGELOG.en.mdindex aee11a4..386f0c9 100644--- a/CHANGELOG.en.md+++ b/CHANGELOG.en.md@@ -5,6 +5,37 @@ All notable changes to this project will be documented in this file.The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).+## [1.3.10] - 2026-07-04++This release comes from a project-wide deep review (architecture / database / performance / frontend / UX) and fixes the high-risk findings. Full report: `docs/dev/deep-review-2026-07.md`.++### Fixed++- **RuleSet/IPCIDR type nodes appeared in the rule chain-flow entry column (v1.3.9 regression)** 🐛+ - The v1.3.9 rule-naming change (PR [#68]) switched mihomo's aggregation key from the top-level policy group to the raw rule type + payload, breaking the flow-graph entry column and the frontend's gateway-rule matching (both key on policy-group names). Multi-hop chains key on the last chain hop again; rule detail names remain only for single-hop DIRECT/REJECT chains. A one-time startup migration remaps the polluted rows back to policy-group names and merges totals+- **A 30-day range effectively contained only 7 days of dimension data** 🐛+ - `hourly_dim_stats` / `hourly_country_stats` (backing every >6h range query) were deleted with the 7-day minute-level retention cutoff. They now follow the hourly retention window (default 30 days)+- **Silent missing data when ClickHouse writes are enabled but reads stay on SQLite** 🐛+ - Reduced SQLite writes (skipping domain/IP/rule/dim tables) previously only checked ClickHouse write health; deployments with the default `STATS_QUERY_SOURCE=sqlite` kept reading from SQLite where those tables were never written. Reduction now requires reads to actually prefer ClickHouse (clickhouse/auto/CH_ONLY_MODE) and the misconfiguration warns at startup+- **Substring mismatches dropped values from CSV association columns** 🐛+ - Bare `INSTR` dedup treated `a.com` as already present when `aa.com` was in the list (same for IPs and rule/chain names). All columns now use the delimiter-aware `','||list||','` pattern+- **Non-atomic batch writes double-counted on retry** 🐛+ - The three sub-transactions of a batch flush committed independently; a mid-flush failure caused the retried buffer to double-count tables that had already committed. One outer transaction now wraps them (inner ones degrade to savepoints)+- **Cross-backend data bleed while switching backends** 🐛+ - WebSocket stats pushes now carry `backendId` and the client drops in-flight pushes that don't match the current subscription+- **Error surfaces**: added route-level and global error boundaries (a crashing visualization no longer blanks the whole dashboard); chain-flow load failures render a retry card instead of disappearing silently+- **Dark mode fixes** 🌓: the world map is now theme-aware (no-data fill / color ramp / stroke / legend — previously a glaring light-colored map on dark backgrounds); upload arrows in the rules list used blue in dark mode making up/down indistinguishable; health test button hover and unhealthy badge gained missing dark variants+- **Active Policy whitelist never updated**: the `UnifiedRuleChainFlow` memo comparator ignored `visibleRuleNames`++### Changed++- **Chain-flow query complexity**: realtime merge went from O(R×N) per-row `findIndex` to a Map merge; the DAG source rows are capped to the top-N by traffic (`RULE_CHAIN_FLOW_MAX_ROWS`, default 2000) instead of a full-table scan; the realtime rule-chain map is no longer deep-copied per broadcast+- **WebSocket broadcast concurrency + outbound backpressure**: broadcast payloads now fetch concurrently (previously serially awaited per client); clients whose outbound buffer exceeds `WS_MAX_BUFFERED_BYTES` (default 4MB) are skipped for the round so one slow reader can't grow the heap unboundedly; metrics line gains `backpressure_skips`+- **Dropped four expression indexes** on `(total_download + total_upload)` that the query planner never used, removing write amplification on the four hottest tables; existing databases drop them at startup+- **Single write implementation**: removed the drifted, caller-less single-update write path; `updateTrafficStats` now wraps the batch path++[#68]: https://github.com/foru17/neko-master/pull/68+## [1.3.9] - 2026-06-23### Fixeddiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8c3c28e..74dc017 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,37 @@格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/),并且本项目遵循 [语义化版本](https://semver.org/lang/zh-CN/spec/v2.0.0.html)。+## [1.3.10] - 2026-07-04++本版本源自一次全项目深度审查(架构 / 数据库 / 性能 / 前端 / 交互),集中修复其中的高危问题。完整审查报告见 `docs/dev/deep-review-2026-07.md`。++### 修复++- **规则链路图入口列出现 RuleSet/IPCIDR 类型节点(v1.3.9 回归)** 🐛+ - v1.3.9 的规则命名调整(PR [#68])把 mihomo 流量的聚合主键从顶层策略组改成了原始规则类型 + payload,破坏了链路图入口列与前端网关规则匹配(两者都以策略组名为键)。多跳链路恢复以最后一跳策略组为主键;规则明细名仅用于直连 DIRECT/REJECT 的单跳链路。启动时一次性迁移会把污染数据重映射回策略组名并合并累计值+- **30 天时间范围实际只有 7 天维度数据** 🐛+ - `hourly_dim_stats` / `hourly_country_stats`(支撑所有 >6 小时范围查询)被 7 天的分钟级 retention 一并删除。现改为跟随小时级 retention 窗口(默认 30 天)+- **ClickHouse 写启用但读源为 SQLite 时静默缺数据** 🐛+ - 精简 SQLite 写入(跳过 domain/IP/rule/dim 表)此前只看 ClickHouse 写健康状态;默认 `STATS_QUERY_SOURCE=sqlite` 的部署读的还是 SQLite,那些表却没写。现在只有读源确实偏向 ClickHouse(clickhouse/auto/CH_ONLY_MODE)时才精简写入,配置错位时启动告警+- **CSV 关联列子串误匹配丢数据** 🐛+ - 裸 `INSTR` 去重会把 `a.com` 误判为已存在于 `aa.com`(IP、规则名同理),导致 domain/ip 关联列表静默缺项。统一改为带分隔符的 `','||list||','` 匹配+- **批量写非原子导致重试双计** 🐛+ - 批量落库的三段子事务独立提交,中途失败后 buffer 重放会对已提交的表二次累加。现在由外层单事务包住(内层自动降级为 savepoint)+- **切换后端瞬间数据串台** 🐛+ - WebSocket 推送现在携带 `backendId`,前端丢弃与当前订阅不符的在飞推送,避免旧后端数据写入新后端缓存+- **前端错误处理补全**:新增路由级与全局错误边界(可视化组件异常不再白屏整页);链路图加载失败渲染带重试的占位卡片,不再静默消失+- **暗色模式修复** 🌓:世界地图整体适配暗色(无数据国家 / 色阶 / 描边 / 图例,此前是一块刺眼的亮色地图);规则列表上传箭头暗色误用蓝色致上下行不可分;后端健康按钮 hover 与异常徽标补齐 dark 变体+- **Active Policy 白名单不生效**:`UnifiedRuleChainFlow` 的 memo 比较器漏比 `visibleRuleNames`,首屏后白名单一直是旧值++### 优化++- **规则链路图查询降复杂度**:realtime 合并从 O(R×N) 的逐条 `findIndex` 改为 Map 合并;DAG 源数据按流量取 Top-N(`RULE_CHAIN_FLOW_MAX_ROWS`,默认 2000)而非全表扫描;去掉每次广播对 realtime 规则链路表的整表深拷贝+- **WebSocket 广播并发化 + 出站背压**:广播负载并发预取(此前逐客户端串行 await);出站缓冲超过 `WS_MAX_BUFFERED_BYTES`(默认 4MB)的慢客户端跳过本轮推送,防止内存被单个慢连接拖爆,指标行新增 `backpressure_skips`+- **删除四个从未被查询计划使用的表达式索引**(`total_download + total_upload`),消除四张最热表的无谓写放大;存量库启动时自动 DROP+- **写路径唯一化**:删除与批量实现漂移已久且无生产调用方的单条写路径,`updateTrafficStats` 现在是批量路径的一层包装++[#68]: https://github.com/foru17/neko-master/pull/68+## [1.3.9] - 2026-06-23### 修复diff --git a/package.json b/package.jsonindex d8cb888..0b222ba 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "neko-master",- "version": "1.3.9",+ "version": "1.3.10","description": "Modern traffic analytics for edge gateways","private": true,"workspaces": [