A modern and elegant dashboard for network traffic visualization and analysis.
release: v1.4.0 — data-correctness, security defaults, error visibility
luolei6f72cfd0db69
diff --git a/.env.example b/.env.exampleindex 704cc7d..7c910e2 100644--- a/.env.example+++ b/.env.example@@ -40,6 +40,13 @@ WS_EXTERNAL_PORT=3002# 可使用 openssl rand -hex 32 生成# COOKIE_SECRET=+# 跨源访问白名单(逗号分隔的 Origin 列表)+# 默认(不设置)拒绝一切跨源请求——同源部署(默认 Docker 形态,前端与 API 同源)无需设置。+# 仅当仪表盘与 collector 部署在不同源(不同域名/端口)时才需要设置,+# 例如:CORS_ORIGIN=https://dashboard.example.com,https://admin.example.com+# 设置后这些源的跨源请求将被允许携带凭证。+# CORS_ORIGIN=+# -----------------------------------------------------------------------------# IP 地理查询配置(可选)# -----------------------------------------------------------------------------diff --git a/CHANGELOG.en.md b/CHANGELOG.en.mdindex 386f0c9..794eb7a 100644--- a/CHANGELOG.en.md+++ b/CHANGELOG.en.md@@ -5,6 +5,22 @@ 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.4.0] - 2026-07-19++This release comes from a second external deep code review. Each finding was independently verified before fixing; the high-priority ones — data correctness, security defaults, error visibility, and a live install failure — are addressed here.++### Fixed++- **Agent install/upgrade 404**: `install.sh` and `nekoagent` resolved download URLs via GitHub `releases/latest`, which points at whatever release GitHub marks latest — including main-app `v*` releases that carry no agent binaries, so every fresh install and upgrade 404'd. They now list releases, pick the newest `agent-v*` tag, and download from that concrete tag.+- **Silent data loss in agent CH_ONLY mode**: when SQLite writes were skipped (ClickHouse considered healthy) and the ClickHouse write then failed, the buffer was already cleared and data vanished from both memory and disk. A SQLite fallback (traffic + country) now persists the snapshot, matching the gateway/surge collectors.+- **Unbounded realtime store growth in agent mode**: the agent path never called `pruneIfNeeded`, so the in-memory store grew without bound while ClickHouse kept failing — OOM on long-lived router/gateway deployments. It is now pruned each flush.+- **Missing query error state**: on a collector failure the dashboard silently showed "no data" — the worst failure mode for a monitoring tool. KPI cards now render an error alert when a query fails.++### Security++- **CORS denies cross-origin by default**: with `CORS_ORIGIN` unset, the server previously reflected any Origin with `credentials: true`, letting any website read a logged-in user's traffic data cross-site. Cross-origin is now denied by default; same-origin deployments (the default Docker setup) are unaffected. **Upgrade note**: if your dashboard and collector run on different origins, set `CORS_ORIGIN` explicitly (see `.env.example`) or cross-origin requests will be rejected.+- **`GET /api/backends` no longer returns plaintext tokens**: the list/read endpoints returned the stored upstream/agent token verbatim. It is now stripped; the edit form treats an empty token as "unchanged", so editing still works.+## [1.3.10] - 2026-07-04This 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`.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 74dc017..4cc750d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,22 @@格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/),并且本项目遵循 [语义化版本](https://semver.org/lang/zh-CN/spec/v2.0.0.html)。+## [1.4.0] - 2026-07-19++本版本源自第二次外部深度代码评审,逐条证伪核验后修复其中的高优先级问题:数据正确性、安全默认值、错误可见性,以及一处当前正在发生的安装故障。++### 修复++- **Agent 安装/升级 404**:`install.sh` 与 `nekoagent` 此前用 GitHub `releases/latest` 解析下载地址,而该端点会命中不带 agent 二进制的主应用 `v*` release,导致新装和升级全部 404。改为列出 releases 并筛选最新的 `agent-v*` tag,再从该具体 tag 下载。+- **Agent 模式 CH_ONLY 静默丢数据**:当 ClickHouse 被判定健康而跳过 SQLite 写入、随后 ClickHouse 写入失败时,缓冲区已清空、数据从内存与磁盘同时消失。现补齐与 gateway/surge 一致的 SQLite 兜底回写(流量与国家维度)。+- **Agent 模式 realtime store 无界增长**:agent 路径此前从不调用 `pruneIfNeeded`,ClickHouse 持续故障时内存无限累积,长时间运行的软路由/网关部署会 OOM。现每次 flush 后修剪。+- **统计错误态缺失**:仪表盘 collector 请求失败时静默显示为"暂无数据"——对监控工具是最糟的失败模式。KPI 卡片现会在查询失败时显示错误提示。++### 安全++- **CORS 默认拒绝跨源**:未设置 `CORS_ORIGIN` 时,此前会反射任意 Origin 且携带凭证(`credentials: true`),任何网站都能借已登录用户的浏览器跨站读取流量数据。现默认拒绝跨源;同源部署(默认 Docker 形态)不受影响。**升级提示**:若你的仪表盘与 collector 部署在不同源,需显式设置 `CORS_ORIGIN`(见 `.env.example`),否则跨源请求将被拒绝。+- **`GET /api/backends` 不再返回明文 token**:列表/读取接口此前原样返回存储的上游/agent token。现已剥离;编辑表单将空 token 视为"不修改",编辑功能不受影响。+## [1.3.10] - 2026-07-04本版本源自一次全项目深度审查(架构 / 数据库 / 性能 / 前端 / 交互),集中修复其中的高危问题。完整审查报告见 `docs/dev/deep-review-2026-07.md`。diff --git a/package.json b/package.jsonindex 0b222ba..0e6aeaa 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "neko-master",- "version": "1.3.10",+ "version": "1.4.0","description": "Modern traffic analytics for edge gateways","private": true,"workspaces": [