From 29a7a5bc2219bddfc3de4634ec995f278857aaf3 Mon Sep 17 00:00:00 2001 From: MemRelay Date: Sat, 7 Nov 2026 05:10:42 +0800 Subject: [PATCH] =?UTF-8?q?create:=20=E5=AE=BF=E4=B8=BB=E6=9C=BA=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E4=B8=8E=E6=97=B6=E9=97=B4=E5=90=8C=E6=AD=A5=E6=9E=B6?= =?UTF-8?q?=E6=9E=84=EF=BC=88=E4=B8=8A=E6=B8=B8=E9=80=82=E9=85=8D=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=20+=20=E7=BB=9F=E4=B8=80=20NTP=20=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=20+=20=E9=9D=99=E9=BB=98=E9=9D=9E=E9=98=BB?= =?UTF-8?q?=E5=A1=9E=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MemRelay-Operation: memory-save:host-agent-architecture-decision-2026-11-07 MemRelay-Resource: 2cf03f75-7e7f-43d3-8329-29ac06849d42 --- ...插件 + 统一 NTP 服务模型 + 静默非阻塞).md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 projects/d5a7f581-c442-4554-87b9-ee723b8b0258/宿主机代理与时间同步架构(上游适配插件 + 统一 NTP 服务模型 + 静默非阻塞).md diff --git a/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/宿主机代理与时间同步架构(上游适配插件 + 统一 NTP 服务模型 + 静默非阻塞).md b/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/宿主机代理与时间同步架构(上游适配插件 + 统一 NTP 服务模型 + 静默非阻塞).md new file mode 100644 index 0000000..1e8962d --- /dev/null +++ b/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/宿主机代理与时间同步架构(上游适配插件 + 统一 NTP 服务模型 + 静默非阻塞).md @@ -0,0 +1,30 @@ +--- +title: 宿主机代理与时间同步架构(上游适配插件 + 统一 NTP 服务模型 + 静默非阻塞) +type: decision +permalink: main/projects/d5a7f581-c442-4554-87b9-ee723b8b0258/宿主机代理与时间同步架构上游适配插件-统一-ntp-服务模型-静默非阻塞 +stable_id: 2cf03f75-7e7f-43d3-8329-29ac06849d42 +scope: project +memory_type: decision +project_id: d5a7f581-c442-4554-87b9-ee723b8b0258 +usage_profile_id: 0c9feb46-d06e-43cd-9ef0-c5813c84a998 +status: active +revision: 1 +request_id: host-agent-architecture-decision-2026-11-07 +created_at: '2026-11-06T21:10:38.893838+00:00' +updated_at: '2026-11-06T21:10:38.893838+00:00' +tags: +- host-agent +- time-sync +- architecture +- ikuai +- ntp +--- + +2026-11-07 用户确认的设计(分支 feat/host-agent,计划文件 宿主机代理与首页优化_ba77e127.plan.md,接口约定 Temp/host-agent/CONTRACT.md): +- MetrixHostAgent 用 Go 编写,放在 plugins/MetrixHostAgent,主动以 WebSocket 连接 ws://127.0.0.1:8000/api/host-agent/connect(Bearer 令牌 mha_ 开头)。 +- 统一 NTP 服务模型:代理把 chrony/timesyncd/ntpd/ntpsec/openntpd/busybox/none 统一成 NtpStatus 和 ntp.status/configure/service/sync_now/query 任务,网页只显示「NTP 服务」加类型标签,按 capabilities 启用按钮;设置里的 NTP 服务器由代理写入宿主机配置(托管块或 drop-in,先备份,未变不动)。 +- 上游适配插件化:同步方式为自动识别 / 指定适配器 / 直接修改宿主机时间(可选停止 NTP 对时)。iKuai 为内置插件,靠未登录响应头 X-Timestamp/X-Sysbit/X-Enterprise 识别;另有自定义多步 HTTP 流程插件,占位符如 {{time.unix}}、{{secret.password | md5}}、{{ntp.host}}。适配器方式:改上游时间 -> 复核 -> 代理 ntp.sync_now 让宿主机立即对时。 +- 精度秒级,偏差不到 1 秒不改,全局 30 秒冷却(单调时钟,只有真正改过才计)。 +- 首页同步完全静默:不显示任何结果、原因或提示,按钮只在进行中旋转;打开首页空闲时自动同步(同浏览器 10 分钟一次,只用网络时间),手动按钮在不要求网络时间时可回落电脑时间。 +- 不卡 web:前端按需加载、低优先级请求、超时与取消;后端 POST /api/host/time/sync 立即返回 job_id,后台 asyncio 任务执行,全异步不阻塞单进程 uvicorn 的事件循环。 +- 2026-11-07 已验证生产容器可直接访问 iKuai 192.127.115.1 的 HTTP 80(响应头齐全)和 UDP 123(延迟 0.3ms),不需要代理转发 HTTP。 \ No newline at end of file