115 Commits

Author SHA1 Message Date
耗子 443516a2cf refactor!: 迁移至 samber/do 依赖注入与三层架构
依赖注入:
- 移除 google/wire(含 wire.go/wire_gen.go 与全部 ProviderSet),
  改用 samber/do v2 单注入器 + 双入口惰性构建
- 贡献模型替代命令式注册:路由 routes:、命令 commands:、
  任务 jobs: 前缀经 internal/registry 收集与校验
- 构造函数统一 func NewXxx(i do.Injector) (T, error)

三层架构:
- 补全用例层:每个 biz.XxxRepo 配 XxxUsecase,
  service/command/job 表现层只依赖用例,不再直接引用仓储

路由与文档:
- route/http.go 按域拆为声明式 Endpoint 贡献,
  Endpoint 承载登录白名单与端点限流语义
- 调试模式下提供 OpenAPI 3.1 文档:/openapi.json 与 /docs(Scalar),
  从 validate 标签生成

目录与依赖:
- internal/http/{middleware,request,rule} 拍平至 internal/*
- CLI 命令拆至 internal/command
- 日志轮转 timberjack 换为 libtnb/logrotate
- 升级 validator/cron/sessions/gormstore/sqlite/securecookie
- 数据库迁移保持 gormigrate 不变

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-09 21:54:22 +08:00
耗子 f024381660 feat(panel): 数据库故障降级、健康告警与检测
- 网站统计聚合器 flush 失败也 commit(丢弃已 drain 增量),防止 DB
  长期不可写时内存无界累积导致 OOM/CPU 100%
- 势态感知同样在 upsert 失败时上报健康问题
- 新增 internal/app.Health 全局健康状态注册表,通过 /home/health 暴露
- 前端 layout 顶部新增 HealthBanner,DB 故障时红色横幅提醒并给出修复引导
- acepanel fix 检测数据库损坏改用 PRAGMA quick_check,能识别 malformed
  等仅在查询时才暴露的静默损坏
- 主库与辅助库 DSN 一律设为 synchronous(FULL),减少宿主 write-back
  缓存丢失 fsync 导致的损坏概率
- 移除 debug.SetMemoryLimit(256MB):软上限在活对象超限时会驱动 GC 反复
  追赶不可回收对象,反而放大 CPU 打满

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-07-03 04:21:10 +08:00
耗子 00a5acbc45 feat(panel): 重写自升级流程并精简面板备份 (close #1674)
升级改为覆盖式:只替换程序文件,storage 原地不动,中断安全无需 fix;新增 WS 实时进度,前端等待重启自动刷新。面板备份改为仅打包核心文件(ace/panel.db/config.yml/cert/cli),排除统计/扫描大库,体积大幅下降。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-03 02:12:52 +08:00
耗子 f5ad988576 feat: 替换验证器实现 2026-07-03 00:22:23 +08:00
耗子 865f12c75b feat: 支持计划任务备份clickhouse和redis 2026-06-08 02:17:09 +08:00
耗子 568ce6b270 feat: 新增容器无极日志 2026-06-05 19:42:53 +08:00
fish 419cf50a37 Fix/postgresql port sync (#1636)
* refactor(postgresql): 优化配置处理并改进端口管理

- 引入 `configPath()` 方法,集中获取配置文件路径。
- 新增 `getPort()` 方法,用于从配置中动态获取 PostgreSQL 端口。
- 更新方法以使用新的配置处理机制,确保对 PostgreSQL 配置文件的访问一致性。
- 增强了配置更新期间端口变更时的错误处理和服务重启逻辑。

* fix(home): 修复数据库统计接口使用固定端口连接数据库的问题

- 更新了 HomeService,使其包含一个新的 databaseServerRepo,用于管理数据库服务器配置。
- 修改了 NewHomeService 构造函数,使其接受新的 databaseServerRepo 参数。
- 重构了数据库连接逻辑,使其利用数据库服务器存储库进行 PostgreSQL 连接。

* fix: optimize code

---------

Co-authored-by: 耗子 <haozi@loli.email>
2026-05-27 23:55:25 +08:00
耗子 c41dab89f8 refactor: 替换 robfig/cron/v3 为 libtnb/cron
robfig/cron 已停止维护,迁移到 libtnb/cron(零三方依赖,API 设计更现代)

主要变更:
- pkg/cron/logger.go 删除,libtnb/cron 直接吃 *slog.Logger
- bootstrap.NewCron 用 wrap.Recover() / wrap.SkipIfRunning() 替代旧 cron.Recover / SkipIfStillRunning
- app.Ace.Run 处理 c.Start() error 返回值;c.Stop(ctx) 接受 context
- 6 个 job (Monitoring/FirewallScan/CertRenew/PanelTask/WebsiteStat/WebsiteExpire) 的 Run 签名从 () 改为 (context.Context) error
- jobs.Register 用 c.Add 替代 c.AddJob
- 重新生成 wire 代码

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-08 18:55:39 +08:00
耗子 f08136242e feat: 已安装应用列表显示运行状态 2026-05-06 18:05:19 +08:00
Copilot 6a7c856fe8 feat: 网站到期自动关闭 (#1561)
* Initial plan

* feat: 网站到期自动关闭功能

- biz.Website 新增 ExpireAt 字段(*time.Time,可空,默认不限时)
- 新增数据库迁移自动添加 expire_at 列
- 新增 API 端点 POST /website/{id}/expire_at
- 新增定时任务每分钟检查到期网站并自动关闭
- 前端网站列表新增到期时间列(证书有效期与备注之间)

Agent-Logs-Url: https://github.com/acepanel/panel/sessions/af33abcf-bbcd-4306-a680-76307c699774

Co-authored-by: h2zi <5967335+h2zi@users.noreply.github.com>

* refactor: 优化到期任务查询和数据更新

- 到期检查任务直接查询已到期且运行中的网站,避免加载全量数据
- UpdateExpireAt 使用直接 UPDATE 避免不必要的 SELECT 查询

Agent-Logs-Url: https://github.com/acepanel/panel/sessions/af33abcf-bbcd-4306-a680-76307c699774

Co-authored-by: h2zi <5967335+h2zi@users.noreply.github.com>

* refactor: ExpireAt 改为 time.Time,日志使用英文

- ExpireAt 从 *time.Time 改为 time.Time,零值表示不限时
- 日志消息改为英文,与其他 job 文件风格保持一致
- 前端适配零值时间判断

Agent-Logs-Url: https://github.com/acepanel/panel/sessions/00c49c64-7614-48d1-98bb-0d742d5f10ad

Co-authored-by: h2zi <5967335+h2zi@users.noreply.github.com>

* Revert "refactor: ExpireAt 改为 time.Time,日志使用英文"

This reverts commit ac3dfdb7e4.

* fix: lint

* fix: lint

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: h2zi <5967335+h2zi@users.noreply.github.com>
Co-authored-by: 耗子 <haozi@loli.email>
2026-04-22 03:06:43 +08:00
耗子 a42f9f63d0 refactor: 重构证书签发实现 (#1543)
* refactor: 重构证书签发实现

* fix: address comments

* fix: optimize code
2026-04-07 02:19:22 +08:00
耗子 f66b094ec6 feat: 添加elasticsearch和opensearch 2026-03-27 16:59:24 +08:00
耗子 7c7d5b6ce1 feat: 添加clickhouse和mongodb 2026-03-27 06:03:55 +08:00
耗子 9216940d90 feat: 添加rocketmq和kafka 2026-03-25 03:12:18 +08:00
耗子 e00013f801 feat: 添加valkey、elasticsearch和opensearch 2026-03-25 02:58:15 +08:00
耗子 0ae7327105 feat: 添加prometheus和grafana支持 (#1508)
* feat: 阶段性提交

* feat: 完成开发

* feat: 阶段性提交

* feat: 阶段性提交
2026-03-24 22:45:22 +08:00
Copilot e9c1a946e9 feat: 支持从本地目录加载容器模板(兼容 acepanel/templates 仓库格式) (#1452)
* Initial plan

* feat: 支持从本地目录加载容器模板

从 {app.Root}/templates/ 目录加载 JSON 格式的本地模板文件,
本地模板可覆盖同 slug 的远端模板。
UI 上使用 warning 标签标识本地模板。
本地模板部署时跳过远端回调。

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* refactor: 为本地模板加载添加 slog 日志记录

目录读取失败时记录警告日志,
模板文件读取/解析/缺失 slug 时记录警告日志。

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* refactor: 本地模板改用与 acepanel/templates 仓库一致的目录格式

从 JSON 文件格式改为目录格式:每个模板是一个子目录,
包含 data.yml + docker-compose.yml + 可选 logo.svg/logo.png。
data.yml 支持 i18n 字段,环境变量使用 map 格式。
与 github.com/acepanel/templates 仓库格式完全一致。

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* chore: 改进 resolveLocale 注释

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* plan: address review feedback

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* refactor: 将模板数据类型移至 pkg/types 并清理注释括号

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* fix: 注入 slog.Logger、方法挂载到 templateRepo、简化注释

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* fix: lint

* fix: lint

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>
Co-authored-by: 耗子 <haozi@loli.email>
2026-03-08 00:51:51 +08:00
耗子 71e259ba32 feat: 支持通行密钥登录 (#1432)
* feat: 支持通行密钥登录

* fix: 修复AI评论

* Update pkg/passkey/passkey.go

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix: lint

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-02-26 23:50:18 +08:00
耗子 7fc0e0f4af fix: Docker socket 路径错误和 Redis 密码管理问题 (#1424)
1. Docker 默认 socket 路径不应拼接面板根目录前缀
2. Redis Load() 正则缺少多行标记导致无法提取密码
3. Redis 修改 requirepass 后未同步到数据库服务器记录

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 21:32:26 +08:00
耗子 12b8a4a03b chore: run go generate ./... 2026-02-25 18:08:32 +08:00
半岛的蒟蒻bddjr e947259b86 fix: go.mod module github.com/acepanel/panel/v3 (#1423) 2026-02-25 18:07:00 +08:00
耗子 3445d2396e feat: 数据库优化 2026-02-22 20:06:11 +08:00
耗子 b86645bd58 feat: 拆分统计数据库以优化性能 2026-02-21 23:52:16 +08:00
耗子 42055275ca feat: 优化网站统计数据压力 2026-02-21 23:01:01 +08:00
耗子 fa30728753 feat: 网站统计 2026-02-18 18:17:16 +08:00
耗子 9a1555c48a feat: 防火墙扫描感知功能 & 首页容器统计 & lint 修复
- 新增 eBPF 扫描感知:TC ingress 检测 SYN/UDP 扫描,端口白名单过滤
- 新增首页容器数量统计卡片,未安装容器环境时自动隐藏
- 扫描概览页:统计卡片、趋势图、Top IP/端口、事件列表
- 扫描设置页:启用开关、保留天数、网卡选择
- 统计对比改为同长度上一周期,替代固定昨日对比
- eBPF ports map MaxEntries 扩展至 65535 覆盖全端口
- 修复 WriteString(fmt.Sprintf()) lint 问题,改用 fmt.Fprintf
- 修复 database_redis.go 非常量格式字符串和 govet 警告

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 02:52:32 +08:00
耗子 1cf3218fde feat: 支持管理redis数据库 2026-02-17 23:30:42 +08:00
耗子 b541a56bf9 feat: 首页新增容器数显示 2026-02-17 22:30:24 +08:00
耗子 bb722ccf3d feat: 支持自定义容器socket路径 2026-02-17 22:13:26 +08:00
耗子 2f2f17b1c7 refactor: 重构任务队列 2026-02-17 17:47:25 +08:00
耗子 20a0080b1e fix: build 2026-02-11 23:03:45 +08:00
耗子 72c31a14b2 feat: 防火墙,SSH日志, close #1366 #1364 2026-02-11 19:28:51 +08:00
耗子 85f86f51db fix: 添加数据库用户迁移 2026-02-11 01:28:38 +08:00
耗子 f7bf8b01cc feat: 工具箱新增网络视图 2026-02-10 21:07:05 +08:00
耗子 10a816f7f7 feat: 支持dotnet 2026-02-10 20:08:26 +08:00
Copilot 7da411b2f3 feat: 工具箱-迁移功能 (Toolbox Migration) (#1358)
* Initial plan

* feat: add migration backend service, routes and Wire injection

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* feat: add migration frontend - API, WebSocket, MigrationView and tab integration

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* refactor: move migration types to pkg/types, fix code review issues

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* chore: final cleanup

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* feat: add refresh button on migration pre-check step

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* feat: add SSH key exchange for rsync authentication

Generate temporary ED25519 key pair before migration, deploy public
key to remote via POST /api/toolbox_migration/ssh_key, use -i flag
in all rsync/ssh commands, cleanup key from both sides after migration.

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* fix: lint

* fix: lint

* fix: align migration code with actual codebase patterns

- Project service name: use project name directly (not ace-project-xxx)
- MySQL dump: use MYSQL_PWD env var (not -p flag), remove --socket
- PostgreSQL dump: use PGPASSWORD env var with pg_dump -h 127.0.0.1 -U postgres
- PostgreSQL import: use PGPASSWORD with psql -h 127.0.0.1 -U postgres
- MySQL import: use MYSQL_PWD on remote
- Website create API: use correct listens/domains/type fields
- Project create API: use root_dir/exec_start/user fields
- Database create API: pass server_id properly
- Site directory: use filepath.Join(app.Root, "sites") instead of hardcoded path
- maskPassword: handle MYSQL_PWD/PGPASSWORD env var format

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* fix: add PHP version and proxy backend to website create API body

PHP sites now include the php version number, and reverse proxy sites
include the backend address from Proxies[0].Pass. This matches the
WebsiteCreate validation rules (requiredIf:Type,php / requiredIf:Type,proxy).

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* refactor: replace map[string]any with typed request structs for all remote API calls

Use request.WebsiteCreate, request.DatabaseCreate, request.ProjectCreate,
and request.ToolboxMigrationSSHKey instead of ad-hoc map[string]any.
This ensures all required/validated fields are properly typed and present.

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* fix: website list empty and database migration items stuck in running status

1. Website list: pass "all" to websiteRepo.List() instead of "" — empty
   string was treated as a type filter matching nothing.

2. Database status: result was stored with name "aaa (mysql)" but
   failResult/succeedResult looked up by "aaa" — name mismatch meant
   status was never updated from "running". Use displayName consistently.

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* fix: use acepanel CLI to get remote DB passwords, show success text in results

1. Remote DB import: use `acepanel setting get mysql_root_password` and
   `acepanel setting get postgres_password` on the remote server via SSH
   instead of guessing file paths. The $() is escaped so it executes on
   the remote side, not locally.

2. Migration results: successful items now show "Migration succeeded"
   text alongside the completion timestamp instead of a bare date.

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* fix: lint

* refactor: 不基于rsync的迁移

* fix: lint

* fix: lint

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>
Co-authored-by: 耗子 <haozi@loli.email>
2026-02-10 02:51:03 +08:00
Copilot 0724a042ef feat: HTTP/3 (QUIC) 支持 + TLS 证书热重载 (#1356)
* Initial plan

* feat: 添加 HTTP/3 (QUIC) 协议支持,TLS 启用时自动启用

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* refactor: 优化证书路径复用,修正注释和依赖标记

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* feat: 添加证书热重载,TLS 握手时自动检测并加载变更的证书文件

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* refactor: 使用 fsnotify 替代每次握手 os.Stat 实现证书热重载

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* fix: lint

* fix: lint

* fix: 使用 wire 工具重新生成 wire_gen.go 替代手动编辑

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* feat: 通过 Wire 注入 *tlscert.Reloader,优雅关闭时正确释放资源

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* fix: lint

* fix: lint

* fix: lint

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>
Co-authored-by: 耗子 <haozi@loli.email>
2026-02-09 20:10:13 +08:00
耗子 0292d3d6c0 fix: lint 2026-01-26 02:41:35 +08:00
耗子 bd24e34aa9 fix: build 2026-01-24 19:34:44 +08:00
耗子 05b7f8e9ca fix: build 2026-01-24 19:25:32 +08:00
耗子 e8c1ad2b43 fix: build 2026-01-24 18:51:06 +08:00
耗子 3443fb1292 fix: build 2026-01-24 01:40:45 +08:00
耗子 0aebdd08e1 refactor: 重命名备份存储 2026-01-22 04:14:29 +08:00
耗子 3f46cb66f7 feat: 备份优化 2026-01-22 02:45:03 +08:00
Copilot 0d62d435d9 feat(backup): 新建/更新备份账号时验证 s3、sftp、webdav 存储连接 (#1264)
* Initial plan

* feat(backup): 新建/更新备份账号时验证 s3、sftp、webdav 存储连接

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* refactor(backup): 优化 validateStorage 函数,统一连接验证逻辑

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* feat: 优化备份账号保存

* fix: lint

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>
Co-authored-by: 耗子 <haozi@loli.email>
2026-01-22 01:27:40 +08:00
耗子 ddd19f1597 feat: 备份账号设置 2026-01-19 23:05:20 +08:00
耗子 c7ed032500 feat: 支持更多运行环境 2026-01-16 00:59:10 +08:00
耗子 d29e3d4d87 fix: 优化容器模版 2026-01-14 03:15:48 +08:00
耗子 c07a60d1c8 feat: 初步实现compose template 2026-01-13 23:31:37 +08:00
Copilot 908509e06b feat: 添加项目默认目录配置及目录跳转功能 (#1233)
* Initial plan

* feat: 添加项目默认目录配置及目录跳转功能

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

* fix: 为项目默认目录添加回退默认值

Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: devhaozi <115467771+devhaozi@users.noreply.github.com>
2026-01-13 22:25:20 +08:00