From 85f91b1ed7782c9ff6f81f073bf66be0784bc778 Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 8 Jun 2026 17:25:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20license=20.github?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .agent/new-async-task/SKILL.md | 62 ++++++- .github/ISSUE_TEMPLATE/bug_report.yml | 8 +- .github/ISSUE_TEMPLATE/feature_request.yml | 8 +- .github/copilot-instructions.md | 5 +- .github/pull_request_template.md | 6 +- .github/workflows/build_frontend.yml | 2 +- .github/workflows/build_image.yml | 162 ++++++------------ .github/workflows/check_license.yml | 18 -- .github/workflows/copilot-setup-steps.yml | 2 +- .github/workflows/eslint.yml | 2 +- Makefile | 8 + NOTICE | 7 + docs/docs.go | 106 ++++++++++++ docs/swagger.json | 106 ++++++++++++ docs/swagger.yaml | 67 ++++++++ internal/apps/admin/auth_source/routers.go | 16 ++ .../apps/admin/auth_source/routers_test.go | 1 + internal/apps/admin/errs.go | 1 + internal/apps/admin/logs/routers.go | 1 + internal/apps/admin/logs/utils.go | 1 + internal/apps/admin/middlewares.go | 1 + internal/apps/admin/status/routers.go | 1 + internal/apps/admin/system_config/errs.go | 1 + internal/apps/admin/system_config/routers.go | 1 + .../apps/admin/system_config/routers_test.go | 1 + internal/apps/admin/task/errs.go | 1 + internal/apps/admin/task/routers.go | 1 + internal/apps/admin/task/routers_test.go | 1 + internal/apps/admin/user/errs.go | 1 + internal/apps/admin/user/routers.go | 1 + internal/apps/admin/user/routers_test.go | 1 + internal/apps/cap/middleware.go | 16 ++ internal/apps/cap/routers.go | 16 ++ internal/apps/cap/routers_test.go | 16 ++ internal/apps/config/routers.go | 1 + internal/apps/health/routers.go | 1 + internal/apps/oauth/audit.go | 1 + internal/apps/oauth/constants.go | 1 + internal/apps/oauth/errs.go | 1 + internal/apps/oauth/middlewares.go | 1 + internal/apps/oauth/oauth_test.go | 1 + internal/apps/oauth/routers.go | 1 + internal/apps/oauth/sources.go | 16 ++ internal/apps/upload/errs.go | 1 + internal/apps/upload/file_server.go | 1 + internal/apps/upload/routers.go | 1 + internal/apps/upload/routers_test.go | 1 + internal/apps/upload/tasks.go | 1 + internal/apps/upload/tasks_test.go | 1 + internal/apps/upload/utils.go | 1 + internal/apps/user/access_tokens.go | 1 + internal/apps/user/constants.go | 1 + internal/apps/user/controllers.go | 16 ++ internal/apps/user/errs.go | 4 +- internal/apps/user/routers.go | 1 + internal/apps/user/tasks.go | 1 + internal/cmd/api.go | 1 + internal/cmd/root.go | 1 + internal/cmd/scheduler.go | 1 + internal/cmd/worker.go | 1 + internal/common/constants.go | 1 + internal/common/errs.go | 1 + internal/config/config.go | 1 + internal/config/model.go | 1 + internal/db/clickhouse.go | 1 + internal/db/idgen/snowflake.go | 1 + internal/db/migrator/migrator.go | 1 + internal/db/postgres.go | 1 + internal/db/postgres_logger.go | 1 + internal/db/redis.go | 1 + internal/logger/logger.go | 1 + internal/logger/ringbuffer.go | 1 + internal/logger/ringbuffer_test.go | 1 + internal/logger/utils.go | 1 + internal/model/access_token.go | 1 + internal/model/auth_source.go | 16 ++ internal/model/system_configs.go | 1 + internal/model/task_execution.go | 1 + internal/model/task_execution_test.go | 1 + internal/model/uploads.go | 1 + internal/model/users.go | 1 + internal/otel_trace/propagator.go | 1 + internal/otel_trace/sampler.go | 1 + internal/otel_trace/trace.go | 1 + internal/otel_trace/trace_provider.go | 1 + internal/router/frontend.go | 1 + internal/router/frontend_embedded.go | 1 + internal/router/middlewares.go | 1 + internal/router/router.go | 1 + internal/storage/cache.go | 1 + internal/storage/errs.go | 1 + internal/storage/s3.go | 1 + internal/task/constants.go | 1 + internal/task/executor.go | 1 + internal/task/executor_test.go | 1 + internal/task/handler.go | 1 + internal/task/handlers/register.go | 1 + internal/task/scheduler/scheduler.go | 1 + internal/task/utils.go | 1 + internal/task/worker/middlewares.go | 1 + internal/task/worker/worker.go | 1 + internal/testhelper/test_helper.go | 1 + internal/util/cap/cap.go | 16 ++ internal/util/cap/cap_test.go | 16 ++ internal/util/cap/manager.go | 16 ++ internal/util/cap/prng.go | 16 ++ internal/util/cap/store.go | 16 ++ internal/util/context.go | 1 + internal/util/crypto.go | 1 + internal/util/custom_types.go | 1 + internal/util/http_clients.go | 1 + internal/util/mail/mail.go | 1 + internal/util/mail/mail_test.go | 1 + internal/util/password.go | 16 ++ internal/util/response.go | 1 + internal/util/session.go | 1 + internal/util/strings.go | 1 + internal/util/uuid.go | 1 + internal/util/validate.go | 1 + main.go | 1 + scripts/license.sh | 64 ------- scripts/update_go_license.sh | 160 +++++++++++++++++ 122 files changed, 881 insertions(+), 215 deletions(-) delete mode 100644 .github/workflows/check_license.yml create mode 100644 NOTICE delete mode 100755 scripts/license.sh create mode 100755 scripts/update_go_license.sh diff --git a/.agent/new-async-task/SKILL.md b/.agent/new-async-task/SKILL.md index 10889dd5..6cc5f3b1 100644 --- a/.agent/new-async-task/SKILL.md +++ b/.agent/new-async-task/SKILL.md @@ -1,6 +1,6 @@ --- name: "new-async-task" -description: "项目专用:指导如何在本项目中新增异步任务(TaskHandler),包括常量定义、参数传递(TaskParam)、PayloadValidator 接口、处理器实现、注册、Cron 调度、AppendLog 日志规范等完整步骤。" +description: "项目专用:指导如何在 wavelet 项目中新增异步任务(TaskHandler)。当用户提到新增任务、Asynq、后台任务、定时任务、任务日志、任务重试、TaskMeta、TaskParam 或 PayloadValidator 时必须使用本技能,覆盖常量定义、参数校验、处理器实现、统一注册、Worker 路由、Cron 调度、AppendLog 日志和测试验证。" --- # 新增异步任务开发指南 @@ -29,7 +29,8 @@ TaskHandler.Execute (← 你写这一步) - `internal/task/handler.go` — `TaskHandler` 接口、`TaskResult` 类型、`PayloadValidator` 可选接口 - `internal/task/constants.go` — 任务类型常量、`TaskMeta`、`TaskParam`、`DispatchableTasks` - `internal/task/executor.go` — 注册、下发、执行、日志追加、参数校验分发 -- `internal/task/worker/worker.go` — Worker 启动、处理器注册、路由 +- `internal/task/handlers/register.go` — 内置任务处理器统一注册点,Admin API 和 Worker 都依赖它 +- `internal/task/worker/worker.go` — Worker 启动、Asynq mux 路由、队列配置 - `internal/task/scheduler/scheduler.go` — Cron 定时调度 - `internal/model/task_execution.go` — `TaskExecution` GORM 模型 - `internal/apps/admin/task/routers.go` — 管理 API(下发、查询、重试) @@ -216,20 +217,37 @@ type PayloadValidator interface { - 成功:返回 `&task.TaskResult{Message: "摘要", Detail: "可选详细JSON"}`。`ProcessTask` 会将 `Message + "\n" + Detail` 存入 `TaskExecution.Result`。 - 失败:返回 `nil, fmt.Errorf("...")`。`ProcessTask` 会将错误信息存入 `TaskExecution.ErrorMessage`,状态标记为 `failed`,并将 error 返回给 Asynq 触发自动重试。 -### 第 3 步:在 worker.go 注册 +### 第 3 步:统一注册 Handler,并在 worker.go 添加路由 -打开 `internal/task/worker/worker.go`,做两件事: +新增任务必须同时满足两条链路: -**1. 在 `init()` 中注册处理器**: +- Admin API 下发任务时能找到 Handler,从而调用 `PayloadValidator` 做服务端参数校验。 +- Worker 消费 Asynq 消息时能路由到 `task.ProcessTask`,再由框架分发到 Handler。 + +#### 3.1 在 `internal/task/handlers/register.go` 注册处理器 + +打开 `internal/task/handlers/register.go`,导入你的业务模块并在 `Register()` 中注册: ```go -func init() { +package handlers + +import ( + "github.com/Rain-kl/Wavelet/internal/apps/upload" + "github.com/Rain-kl/Wavelet/internal/apps/user" + "github.com/Rain-kl/Wavelet/internal/task" +) + +func Register() { task.RegisterHandler(task.CleanupUnusedUploadsTask, &upload.CleanupUnusedUploadsHandler{}) task.RegisterHandler(task.SendEmailTask, &user.SendEmailHandler{}) } ``` -**2. 在 `StartWorker()` 的 mux 中添加路由**: +`Register()` 会被 Admin task API 和 Worker 共同调用。不要只在 `worker` 包里注册,否则 Admin dispatch 时 `ValidateAndNormalizePayload` 找不到 Handler,带参数任务会绕过 `PayloadValidator`。 + +#### 3.2 在 `internal/task/worker/worker.go` 添加 Asynq 路由 + +在 `StartWorker()` 的 mux 中添加任务类型路由: ```go mux := asynq.NewServeMux() @@ -240,6 +258,14 @@ mux.HandleFunc(task.SendEmailTask, task.ProcessTask) 所有路由都指向同一个 `task.ProcessTask`,它内部根据 Asynq task type 查找对应的 handler 分发执行。 +`worker.go` 的 `init()` 应保持调用统一注册函数: + +```go +func init() { + taskhandlers.Register() +} +``` + ### 第 4 步(可选):添加 Cron 定时调度 如果任务需要定时执行,编辑 `internal/task/scheduler/scheduler.go`,在 `StartScheduler()` 中注册: @@ -289,6 +315,8 @@ scheduler: 关键点:Admin dispatch handler (`routers.go`) 是**通用的**,不需要按任务类型写 if 分支。新增带参数的任务时,只需在 Handler 上实现 `ValidatePayload` 方法即可。 +注意:`ValidateAndNormalizePayload` 依赖 Handler 已注册。新增任务后必须更新 `internal/task/handlers/register.go`,否则 Admin API 不会执行该任务的 `PayloadValidator`。 + ## AppendLog 使用指南 `task.AppendLog(ctx, format string, args ...interface{})` 在 `TaskHandler.Execute` 内部调用,将日志追加到 `TaskExecution.Log` 字段。管理端 API 可查看完整执行日志。 @@ -338,3 +366,23 @@ scheduler: - `internal/apps/upload/tasks.go` — `CleanupUnusedUploadsHandler`:无参数任务,展示游标分页批量处理、每批次 AppendLog、事务内操作、单条失败 continue 不终止。 - `internal/apps/user/tasks.go` — `SendEmailHandler`:带参数任务,展示 Payload 结构体定义、`PayloadValidator` 实现(`ValidatePayload` 用于校验+标准化)、`Execute` 中 json.Unmarshal 使用参数。 +## 测试与验证 + +新增或调整异步任务后,至少做以下验证: + +1. 单测 Handler 本身:无参数任务验证业务结果;带参数任务额外覆盖 `ValidatePayload` 的成功、非法 JSON、缺失必填字段。 +2. 单测 Admin dispatch:`POST /api/v1/admin/tasks/dispatch` 对合法 payload 返回 200,对非法 payload 返回 400,并包含清晰错误信息。 +3. 单测 Retry:可重试失败任务应创建新的 `TaskExecution`,达到 `MaxRetry`、非 failed 状态、`Retryable=false` 都应拒绝。 +4. 跑目标包测试: + +```bash +go test ./internal/task ./internal/apps/admin/task ./internal/apps/ +``` + +5. 最后跑全量测试: + +```bash +go test ./... +``` + +测试环境中如需下发/重试任务,使用 `miniredis` 初始化 `task.AsynqClient`;不要把 `internal/task` 依赖塞回通用 `internal/testhelper`,否则容易让 `model`/`task` 测试产生 import cycle。 diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 9c4ebc20..1ff0c89a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -9,7 +9,7 @@ body: value: | 感谢您花时间填写此 Bug 报告! - - **提交错误报告前**:请检查 [已有 Issues](https://github.com/linux-do/credit/issues)列表,了解是否有类似问题被报告。如果不确定,请进行搜索,这有助于我们高效地专注于改进项目。 + - **提交错误报告前**:请检查 [已有 Issues](https://github.com/Rain-kl/Wavelet/issues) 列表,了解是否有类似问题被报告。如果不确定,请进行搜索,这有助于我们高效地专注于改进项目。 - type: checkboxes id: issue-check attributes: @@ -18,7 +18,7 @@ body: options: - label: 我已经搜索了现有问题和讨论。 required: true - - label: 我正在使用最新版本或 credit.linux.do 上的此应用。 + - label: 我正在使用 wavelet 的最新版本或当前部署实例。 required: true - type: textarea id: what-happened @@ -68,7 +68,7 @@ body: options: - label: 我已阅读并遵循了 `README.md` 中的所有说明。 required: true - - label: 我正在使用 linux-do/credit 的最新版本。 + - label: 我正在使用 Rain-kl/Wavelet 的最新版本。 required: true - label: 我已提供我能够提供的尽可能多的相关日志,屏幕截图等。 required: true @@ -87,4 +87,4 @@ body: value: | ## 注意 如果 Bug 报告不完整或不遵循说明,则可能不会得到处理。请确保您已遵循所有 **README.md** 指南,并提供所有必要信息以便我们重现该问题。 - 感谢您为 linux-do/credit 做出贡献! + 感谢您为 wavelet 做出贡献! diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 7faa5ea3..bd14554c 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -9,7 +9,7 @@ body: value: | 感谢您花时间填写此功能请求! - - **提交功能请求前**:请检查 [已有 Issues](https://github.com/linux-do/credit/issues) 列表和讨论区,了解是否有类似功能已被讨论或请求。这有助于我们避免重复工作,并高效地专注于改进项目。 + - **提交功能请求前**:请检查 [已有 Issues](https://github.com/Rain-kl/Wavelet/issues) 列表和讨论区,了解是否有类似功能已被讨论或请求。这有助于我们避免重复工作,并高效地专注于改进项目。 - type: checkboxes id: check-existing attributes: @@ -18,7 +18,7 @@ body: options: - label: 我已经搜索了现有问题和讨论。 required: true - - label: 我正在使用最新版本或 credit.linux.do 上的此应用。 + - label: 我正在使用 wavelet 的最新版本或当前部署实例。 required: true - type: textarea id: feature-description @@ -65,7 +65,7 @@ body: options: - label: 我已阅读并遵循了 `README.md` 中的所有说明。 required: true - - label: 我正在使用 linux-do/credit 的最新版本。 + - label: 我正在使用 Rain-kl/Wavelet 的最新版本。 required: true - label: 我已提供我能够提供的尽可能多的相关信息,包括用例和场景。 required: true @@ -76,4 +76,4 @@ body: value: | ## 注意 如果功能请求不完整或不遵循说明,则可能不会得到处理。请确保您已提供所有必要信息以便我们理解您的建议。 - 感谢您为 linux-do/credit 做出贡献! + 感谢您为 wavelet 做出贡献! diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index c9aad0d7..2e543a9c 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,7 +1,7 @@ ## 基础规范 - 在任何情况都使用简体中文 -- 你是一个专业的代码助手,专门为 LINUX DO Credit 项目提供代码编写和优化服务 +- 你是一个专业的代码助手,专门为 wavelet 项目提供代码编写和优化服务 - 严格遵循项目的代码规范和最佳实践,确保代码质量和一致性 - 保持代码简洁、可读、高效 - 优先考虑项目的可维护性、性能和安全性,避免引入不必要的复杂性 @@ -10,8 +10,9 @@ - 避免仅修改格式、注释或无影响力的拼写错误 - 重构代码时必须带来可维护性或功能上的实质提升 - 新增功能时考虑向后兼容性和 API 稳定性 -- 遵循项目的 MIT 许可证要求 +- 遵循项目的 Apache2.0 许可证要求 - 遵循语义化版本控制规范 +- 新增异步任务时使用项目技能 `.agent/new-async-task/SKILL.md` ## 后端规范 diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index efad130f..3c3dcd8f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,8 +2,8 @@ -- [ ] 我已阅读并理解 [贡献者公约](https://github.com/linux-do/credit/blob/master/CODE_OF_CONDUCT.md) -- [ ] 我已阅读并同意 [贡献者许可协议 (CLA)](https://github.com/linux-do/credit/blob/master/CLA.md),确认我的贡献将根据项目的 Apache2.0 许可证进行许可 +- [ ] 我已阅读并理解 [贡献者公约](https://github.com/Rain-kl/Wavelet/blob/main/CODE_OF_CONDUCT.md) +- [ ] 我已阅读并同意 [贡献者许可协议 (CLA)](https://github.com/Rain-kl/Wavelet/blob/main/CLA.md),确认我的贡献将根据项目的 Apache2.0 许可证进行许可 - [ ] 我知晓如果此 PR 并不做出实质性更改,或可被认为是*为了PR被合并而提交PR*的,则可能不会被合并 **关联信息** @@ -22,4 +22,4 @@ resolves #1234 **变更原因** - \ No newline at end of file + diff --git a/.github/workflows/build_frontend.yml b/.github/workflows/build_frontend.yml index 22e8d969..5fd1ae43 100644 --- a/.github/workflows/build_frontend.yml +++ b/.github/workflows/build_frontend.yml @@ -23,7 +23,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: "20" + node-version: "22" cache: 'pnpm' cache-dependency-path: frontend/pnpm-lock.yaml diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index 47c0c964..be89f726 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -1,58 +1,36 @@ -name: Build Docker Image +name: Build Docker Images on: push: - branches: [ "master" ] - tags: [ "*" ] + branches: + - "main" + tags: + - "*" pull_request: - branches: [ "master" ] + branches: + - "main" env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} - FRONTEND_IMAGE_NAME: ${{ github.repository }}-web + FRONTEND_IMAGE_NAME: ${{ github.repository }}-frontend + BACKEND_IMAGE_NAME: ${{ github.repository }}-backend -# add permission for package publishing permissions: contents: read packages: write jobs: - build_image: + build_integrated_image: + name: Build integrated image runs-on: ubuntu-24.04 steps: - # checkout code - name: Checkout repository uses: actions/checkout@v4 - # set up go - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: "1.25" - check-latest: true - - # download Go modules - - name: Download Go modules - run: go mod download - - # build do - - name: Build Go Binary (multi-arch) - run: | - # build amd64 binary - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o credit-server-amd64 main.go - - # build arm64 binary - GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -o credit-server-arm64 main.go - - # show binaries - ls -alh credit-server-* - - # set up docker buildx - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - # login to registry - name: Log into registry uses: docker/login-action@v3 with: @@ -60,41 +38,38 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # extract metadata for docker - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=ref,event=tag type=sha,format=short,prefix= - # build and push docker image - name: Build Docker image uses: docker/build-push-action@v5 with: context: . - push: ${{ github.ref_type == 'tag' || (github.ref == 'refs/heads/master' && github.event_name == 'push') }} + file: docker/Dockerfile + push: ${{ github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name == 'push') }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 build_frontend_image: + name: Build frontend image runs-on: ubuntu-24.04 steps: - # checkout code - name: Checkout repository uses: actions/checkout@v4 - # set up docker buildx - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - # login to registry - name: Log into registry uses: docker/login-action@v3 with: @@ -102,99 +77,70 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - # extract metadata for docker (frontend) - - name: Extract Docker metadata (frontend) + - name: Extract Docker metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE_NAME }} tags: | - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }} + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=ref,event=tag type=sha,format=short,prefix= - # generate frontend build date in utc - name: Generate frontend build date id: frontend_build_meta run: echo "build_date=$(date -u +'%Y/%m/%d UTC')" >> "$GITHUB_OUTPUT" - # build and push frontend docker image with version argument - name: Build Frontend Docker image uses: docker/build-push-action@v5 with: - context: ./frontend - push: ${{ github.ref_type == 'tag' || (github.ref == 'refs/heads/master' && github.event_name == 'push') }} + context: . + file: docker/Dockerfile.frontend + push: ${{ github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name == 'push') }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 build-args: | VERSION=${{ github.ref_type == 'tag' && github.ref_name || '' }} BUILD_DATE=${{ steps.frontend_build_meta.outputs.build_date }} - update_helm_values: + build_backend_image: + name: Build backend image runs-on: ubuntu-24.04 - needs: [build_image, build_frontend_image] - if: github.ref_type == 'tag' steps: - # configure SSH agent with deploy key - - name: Setup SSH agent - uses: webfactory/ssh-agent@v0.9.0 + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log into registry + uses: docker/login-action@v3 with: - ssh-private-key: ${{ secrets.DEPLOY_KEY }} + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} - # add github.com to known_hosts to avoid host verification prompt - - name: Add GitHub to known_hosts - run: ssh-keyscan github.com >> ~/.ssh/known_hosts + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE_NAME }} + tags: | + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=ref,event=tag + type=sha,format=short,prefix= - # clone the helm charts repository - - name: Clone Helm Charts repository - run: git clone ${{ vars.HELM_CHARTS_REPO }} helm-charts - - # install yq for yaml editing - - name: Install yq - run: | - sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 - sudo chmod +x /usr/local/bin/yq - - # determine helm values file based on tag type (production or test) - - name: Determine Helm values file - id: helm_config - run: | - TAG="${{ github.ref_name }}" - if [[ $TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "values_file=values/credit/credit.yaml" >> "$GITHUB_OUTPUT" - echo "branch_prefix=update/credit" >> "$GITHUB_OUTPUT" - else - echo "values_file=values/credit_test/credit.yaml" >> "$GITHUB_OUTPUT" - echo "branch_prefix=update/credit_test" >> "$GITHUB_OUTPUT" - fi - - # update image tags in helm values file - - name: Update image tags in helm values file - run: | - cd helm-charts - yq -i '.image.tag = "${{ github.ref_name }}"' ${{ steps.helm_config.outputs.values_file }} - yq -i '.image.webTag = "${{ github.ref_name }}"' ${{ steps.helm_config.outputs.values_file }} - - # commit and push to a new branch, then open a PR for review - - name: Commit, push and create PR - env: - GH_TOKEN: ${{ secrets.GH_TOKEN }} - run: | - cd helm-charts - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - BRANCH_NAME="${{ steps.helm_config.outputs.branch_prefix }}-${{ github.ref_name }}" - git checkout -b "$BRANCH_NAME" - git add ${{ steps.helm_config.outputs.values_file }} - git commit -m "chore: update credit image tag to ${{ github.ref_name }}" - git push origin "$BRANCH_NAME" - HELM_REPO=$(echo "${{ vars.HELM_CHARTS_REPO }}" | sed 's/git@github.com://;s/\.git$//') - gh pr create \ - --repo "${HELM_REPO}" \ - --title "chore: update credit image tag to ${{ github.ref_name }}" \ - --body "Automated PR: update \`${{ steps.helm_config.outputs.values_file }}\` image tags to \`${{ github.ref_name }}\` after Docker image build." \ - --base main \ - --head "$BRANCH_NAME" + - name: Build Backend Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: docker/Dockerfile.backend + push: ${{ github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name == 'push') }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: linux/amd64,linux/arm64 diff --git a/.github/workflows/check_license.yml b/.github/workflows/check_license.yml deleted file mode 100644 index b625d9a6..00000000 --- a/.github/workflows/check_license.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: check license - -on: - push: - branches: [ "master" ] - tags: [ "*" ] - pull_request: - branches: [ "master" ] - -jobs: - check_license: - runs-on: ubuntu-24.04 - steps: - - name: checkout code - uses: actions/checkout@v4 - - - name: run make add_license - run: make check_license diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 9055760c..dfc6162e 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -28,7 +28,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: "20" + node-version: "22" cache: "pnpm" cache-dependency-path: frontend/pnpm-lock.yaml diff --git a/.github/workflows/eslint.yml b/.github/workflows/eslint.yml index f8865db9..647c2eb2 100644 --- a/.github/workflows/eslint.yml +++ b/.github/workflows/eslint.yml @@ -22,7 +22,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: "20" + node-version: "22" cache: 'pnpm' cache-dependency-path: frontend/pnpm-lock.yaml diff --git a/Makefile b/Makefile index d8cd6da5..89884372 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,14 @@ +.PHONY: swagger license license-check build-embedded + swagger: scripts/swagger.sh +license: + scripts/update_go_license.sh + +license-check: + scripts/update_go_license.sh --check + build-embedded: cd frontend && pnpm build:embed rm -rf internal/router/dist diff --git a/NOTICE b/NOTICE new file mode 100644 index 00000000..c1f31f91 --- /dev/null +++ b/NOTICE @@ -0,0 +1,7 @@ +Wavelet + +Copyright 2025 linux.do +Modifications Copyright 2026 Arctel.net + +This product includes software originally licensed under the Apache License, +Version 2.0. Portions of this work have been modified by Arctel.net in 2026. diff --git a/docs/docs.go b/docs/docs.go index 84431935..a5ef2d26 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -452,6 +452,81 @@ const docTemplate = `{ } } }, + "/api/v1/admin/logs": { + "get": { + "security": [ + { + "SessionCookie": [] + } + ], + "description": "分页获取系统历史日志,cursor=0 获取最新日志,cursor\u003e0 获取更早日志", + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "获取系统日志", + "parameters": [ + { + "type": "integer", + "default": 0, + "description": "日志游标,0=获取最新", + "name": "cursor", + "in": "query" + }, + { + "type": "integer", + "default": 200, + "description": "每页条数", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "description": "日志列表", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseAny" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/logs.logsResponse" + } + } + } + ] + } + }, + "401": { + "description": "未登录", + "schema": { + "$ref": "#/definitions/util.ResponseAny" + } + }, + "403": { + "description": "无管理员权限", + "schema": { + "$ref": "#/definitions/util.ResponseAny" + } + } + } + } + }, + "/api/v1/admin/logs/ws": { + "get": { + "description": "通过 WebSocket 实时推送系统日志,需要管理员权限", + "tags": [ + "admin" + ], + "summary": "系统日志实时推送", + "responses": {} + } + }, "/api/v1/admin/status": { "get": { "security": [ @@ -2905,6 +2980,37 @@ const docTemplate = `{ } } }, + "logger.LogEntry": { + "type": "object", + "properties": { + "data": { + "description": "一行日志原文(含换行符)", + "type": "string" + }, + "index": { + "description": "全局递增序号", + "type": "integer" + } + } + }, + "logs.logsResponse": { + "type": "object", + "properties": { + "has_more": { + "type": "boolean" + }, + "lines": { + "type": "array", + "items": { + "$ref": "#/definitions/logger.LogEntry" + } + }, + "next_cursor": { + "description": "用于加载更早日志的 cursor", + "type": "integer" + } + } + }, "model.AccessToken": { "type": "object", "properties": { diff --git a/docs/swagger.json b/docs/swagger.json index 9e0a4d38..8ed89a58 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -445,6 +445,81 @@ } } }, + "/api/v1/admin/logs": { + "get": { + "security": [ + { + "SessionCookie": [] + } + ], + "description": "分页获取系统历史日志,cursor=0 获取最新日志,cursor\u003e0 获取更早日志", + "produces": [ + "application/json" + ], + "tags": [ + "admin" + ], + "summary": "获取系统日志", + "parameters": [ + { + "type": "integer", + "default": 0, + "description": "日志游标,0=获取最新", + "name": "cursor", + "in": "query" + }, + { + "type": "integer", + "default": 200, + "description": "每页条数", + "name": "limit", + "in": "query" + } + ], + "responses": { + "200": { + "description": "日志列表", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseAny" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/logs.logsResponse" + } + } + } + ] + } + }, + "401": { + "description": "未登录", + "schema": { + "$ref": "#/definitions/util.ResponseAny" + } + }, + "403": { + "description": "无管理员权限", + "schema": { + "$ref": "#/definitions/util.ResponseAny" + } + } + } + } + }, + "/api/v1/admin/logs/ws": { + "get": { + "description": "通过 WebSocket 实时推送系统日志,需要管理员权限", + "tags": [ + "admin" + ], + "summary": "系统日志实时推送", + "responses": {} + } + }, "/api/v1/admin/status": { "get": { "security": [ @@ -2898,6 +2973,37 @@ } } }, + "logger.LogEntry": { + "type": "object", + "properties": { + "data": { + "description": "一行日志原文(含换行符)", + "type": "string" + }, + "index": { + "description": "全局递增序号", + "type": "integer" + } + } + }, + "logs.logsResponse": { + "type": "object", + "properties": { + "has_more": { + "type": "boolean" + }, + "lines": { + "type": "array", + "items": { + "$ref": "#/definitions/logger.LogEntry" + } + }, + "next_cursor": { + "description": "用于加载更早日志的 cursor", + "type": "integer" + } + } + }, "model.AccessToken": { "type": "object", "properties": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 134f6459..02ca7ff0 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -73,6 +73,27 @@ definitions: - solutions - token type: object + logger.LogEntry: + properties: + data: + description: 一行日志原文(含换行符) + type: string + index: + description: 全局递增序号 + type: integer + type: object + logs.logsResponse: + properties: + has_more: + type: boolean + lines: + items: + $ref: '#/definitions/logger.LogEntry' + type: array + next_cursor: + description: 用于加载更早日志的 cursor + type: integer + type: object model.AccessToken: properties: created_at: @@ -938,6 +959,52 @@ paths: summary: 切换认证源启用状态 tags: - admin + /api/v1/admin/logs: + get: + description: 分页获取系统历史日志,cursor=0 获取最新日志,cursor>0 获取更早日志 + parameters: + - default: 0 + description: 日志游标,0=获取最新 + in: query + name: cursor + type: integer + - default: 200 + description: 每页条数 + in: query + name: limit + type: integer + produces: + - application/json + responses: + "200": + description: 日志列表 + schema: + allOf: + - $ref: '#/definitions/util.ResponseAny' + - properties: + data: + $ref: '#/definitions/logs.logsResponse' + type: object + "401": + description: 未登录 + schema: + $ref: '#/definitions/util.ResponseAny' + "403": + description: 无管理员权限 + schema: + $ref: '#/definitions/util.ResponseAny' + security: + - SessionCookie: [] + summary: 获取系统日志 + tags: + - admin + /api/v1/admin/logs/ws: + get: + description: 通过 WebSocket 实时推送系统日志,需要管理员权限 + responses: {} + summary: 系统日志实时推送 + tags: + - admin /api/v1/admin/status: get: description: 获取后端服务运行状态、Goroutine、内存指标等详细统计数据,需要管理员权限 diff --git a/internal/apps/admin/auth_source/routers.go b/internal/apps/admin/auth_source/routers.go index 11f8bc56..7db2f93e 100644 --- a/internal/apps/admin/auth_source/routers.go +++ b/internal/apps/admin/auth_source/routers.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package auth_source import ( diff --git a/internal/apps/admin/auth_source/routers_test.go b/internal/apps/admin/auth_source/routers_test.go index 74841d20..043dbbfc 100644 --- a/internal/apps/admin/auth_source/routers_test.go +++ b/internal/apps/admin/auth_source/routers_test.go @@ -1,5 +1,6 @@ /* Copyright 2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/errs.go b/internal/apps/admin/errs.go index 21627959..1e0ce1eb 100644 --- a/internal/apps/admin/errs.go +++ b/internal/apps/admin/errs.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/logs/routers.go b/internal/apps/admin/logs/routers.go index fa34244f..b4a17e58 100644 --- a/internal/apps/admin/logs/routers.go +++ b/internal/apps/admin/logs/routers.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/logs/utils.go b/internal/apps/admin/logs/utils.go index 7d044c30..0bb4e667 100644 --- a/internal/apps/admin/logs/utils.go +++ b/internal/apps/admin/logs/utils.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/middlewares.go b/internal/apps/admin/middlewares.go index 8cb392f0..2b1e946a 100644 --- a/internal/apps/admin/middlewares.go +++ b/internal/apps/admin/middlewares.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/status/routers.go b/internal/apps/admin/status/routers.go index f8d8eecf..08f71b6f 100644 --- a/internal/apps/admin/status/routers.go +++ b/internal/apps/admin/status/routers.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/system_config/errs.go b/internal/apps/admin/system_config/errs.go index ce45ea44..a2ab435d 100644 --- a/internal/apps/admin/system_config/errs.go +++ b/internal/apps/admin/system_config/errs.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/system_config/routers.go b/internal/apps/admin/system_config/routers.go index 14ee2b0c..ebad97aa 100644 --- a/internal/apps/admin/system_config/routers.go +++ b/internal/apps/admin/system_config/routers.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/system_config/routers_test.go b/internal/apps/admin/system_config/routers_test.go index 564b9135..940f00e7 100644 --- a/internal/apps/admin/system_config/routers_test.go +++ b/internal/apps/admin/system_config/routers_test.go @@ -1,5 +1,6 @@ /* Copyright 2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/task/errs.go b/internal/apps/admin/task/errs.go index ff24cccc..aa58db5e 100644 --- a/internal/apps/admin/task/errs.go +++ b/internal/apps/admin/task/errs.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/task/routers.go b/internal/apps/admin/task/routers.go index b68a2c30..286b1224 100644 --- a/internal/apps/admin/task/routers.go +++ b/internal/apps/admin/task/routers.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/task/routers_test.go b/internal/apps/admin/task/routers_test.go index ea213c35..55a0c88e 100644 --- a/internal/apps/admin/task/routers_test.go +++ b/internal/apps/admin/task/routers_test.go @@ -1,5 +1,6 @@ /* Copyright 2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/user/errs.go b/internal/apps/admin/user/errs.go index 5e345c62..de42bd7c 100644 --- a/internal/apps/admin/user/errs.go +++ b/internal/apps/admin/user/errs.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/user/routers.go b/internal/apps/admin/user/routers.go index 10b2f8cd..03c18aec 100644 --- a/internal/apps/admin/user/routers.go +++ b/internal/apps/admin/user/routers.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/admin/user/routers_test.go b/internal/apps/admin/user/routers_test.go index 60ef3820..1eb9ccc4 100644 --- a/internal/apps/admin/user/routers_test.go +++ b/internal/apps/admin/user/routers_test.go @@ -1,5 +1,6 @@ /* Copyright 2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/cap/middleware.go b/internal/apps/cap/middleware.go index 2874ebc1..7025f0e7 100644 --- a/internal/apps/cap/middleware.go +++ b/internal/apps/cap/middleware.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cap import ( diff --git a/internal/apps/cap/routers.go b/internal/apps/cap/routers.go index 6b84f3fe..eb096c35 100644 --- a/internal/apps/cap/routers.go +++ b/internal/apps/cap/routers.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cap import ( diff --git a/internal/apps/cap/routers_test.go b/internal/apps/cap/routers_test.go index f1f8c6cb..e95dda22 100644 --- a/internal/apps/cap/routers_test.go +++ b/internal/apps/cap/routers_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cap import ( diff --git a/internal/apps/config/routers.go b/internal/apps/config/routers.go index 6171da08..3eaf28b8 100644 --- a/internal/apps/config/routers.go +++ b/internal/apps/config/routers.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/health/routers.go b/internal/apps/health/routers.go index e3d79d68..c8870f38 100644 --- a/internal/apps/health/routers.go +++ b/internal/apps/health/routers.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/oauth/audit.go b/internal/apps/oauth/audit.go index 4649547f..f67649ee 100644 --- a/internal/apps/oauth/audit.go +++ b/internal/apps/oauth/audit.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/oauth/constants.go b/internal/apps/oauth/constants.go index ef0955f4..9afb689b 100644 --- a/internal/apps/oauth/constants.go +++ b/internal/apps/oauth/constants.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/oauth/errs.go b/internal/apps/oauth/errs.go index 0414ef7b..98aba25a 100644 --- a/internal/apps/oauth/errs.go +++ b/internal/apps/oauth/errs.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/oauth/middlewares.go b/internal/apps/oauth/middlewares.go index 9960ad6a..719ce507 100644 --- a/internal/apps/oauth/middlewares.go +++ b/internal/apps/oauth/middlewares.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/oauth/oauth_test.go b/internal/apps/oauth/oauth_test.go index b38b74bd..1bf35865 100644 --- a/internal/apps/oauth/oauth_test.go +++ b/internal/apps/oauth/oauth_test.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/oauth/routers.go b/internal/apps/oauth/routers.go index 013a5505..d413f401 100644 --- a/internal/apps/oauth/routers.go +++ b/internal/apps/oauth/routers.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/oauth/sources.go b/internal/apps/oauth/sources.go index 7a8e0e22..6b14bec0 100644 --- a/internal/apps/oauth/sources.go +++ b/internal/apps/oauth/sources.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package oauth import ( diff --git a/internal/apps/upload/errs.go b/internal/apps/upload/errs.go index 5c59a57f..01cc9248 100644 --- a/internal/apps/upload/errs.go +++ b/internal/apps/upload/errs.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/upload/file_server.go b/internal/apps/upload/file_server.go index 86c4f030..218d0358 100644 --- a/internal/apps/upload/file_server.go +++ b/internal/apps/upload/file_server.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/upload/routers.go b/internal/apps/upload/routers.go index 64512ff5..979ac820 100644 --- a/internal/apps/upload/routers.go +++ b/internal/apps/upload/routers.go @@ -1,5 +1,6 @@ /* Copyright 2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/upload/routers_test.go b/internal/apps/upload/routers_test.go index b4a452f2..ada65892 100644 --- a/internal/apps/upload/routers_test.go +++ b/internal/apps/upload/routers_test.go @@ -1,5 +1,6 @@ /* Copyright 2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/upload/tasks.go b/internal/apps/upload/tasks.go index 2bc195f9..41256a3c 100644 --- a/internal/apps/upload/tasks.go +++ b/internal/apps/upload/tasks.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/upload/tasks_test.go b/internal/apps/upload/tasks_test.go index eaca2375..624ed080 100644 --- a/internal/apps/upload/tasks_test.go +++ b/internal/apps/upload/tasks_test.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/upload/utils.go b/internal/apps/upload/utils.go index 0d31808f..e0a3a27a 100644 --- a/internal/apps/upload/utils.go +++ b/internal/apps/upload/utils.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/user/access_tokens.go b/internal/apps/user/access_tokens.go index 04973db4..3128d0e3 100644 --- a/internal/apps/user/access_tokens.go +++ b/internal/apps/user/access_tokens.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/user/constants.go b/internal/apps/user/constants.go index b1e60dbd..d473d6fe 100644 --- a/internal/apps/user/constants.go +++ b/internal/apps/user/constants.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/user/controllers.go b/internal/apps/user/controllers.go index 891ac809..293edc4e 100644 --- a/internal/apps/user/controllers.go +++ b/internal/apps/user/controllers.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package user import ( diff --git a/internal/apps/user/errs.go b/internal/apps/user/errs.go index 8064501d..27b4e083 100644 --- a/internal/apps/user/errs.go +++ b/internal/apps/user/errs.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,5 +17,4 @@ limitations under the License. package user -const ( -) +const () diff --git a/internal/apps/user/routers.go b/internal/apps/user/routers.go index e4ff2657..a715ff87 100644 --- a/internal/apps/user/routers.go +++ b/internal/apps/user/routers.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/apps/user/tasks.go b/internal/apps/user/tasks.go index f5e5fcfa..0c1cfac0 100644 --- a/internal/apps/user/tasks.go +++ b/internal/apps/user/tasks.go @@ -1,5 +1,6 @@ /* Copyright 2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/cmd/api.go b/internal/cmd/api.go index cd7bb27d..5cfe2d70 100644 --- a/internal/cmd/api.go +++ b/internal/cmd/api.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/cmd/root.go b/internal/cmd/root.go index b6264c5d..5908872c 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/cmd/scheduler.go b/internal/cmd/scheduler.go index 6561638f..363d3db8 100644 --- a/internal/cmd/scheduler.go +++ b/internal/cmd/scheduler.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/cmd/worker.go b/internal/cmd/worker.go index 04e2c4ae..e7fa9273 100644 --- a/internal/cmd/worker.go +++ b/internal/cmd/worker.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/common/constants.go b/internal/common/constants.go index 118f7c5d..3543dc6e 100644 --- a/internal/common/constants.go +++ b/internal/common/constants.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/common/errs.go b/internal/common/errs.go index ca5c7485..3f15975d 100644 --- a/internal/common/errs.go +++ b/internal/common/errs.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/config/config.go b/internal/config/config.go index f2dd97a0..67bae14f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/config/model.go b/internal/config/model.go index 2cb65800..09c14f46 100644 --- a/internal/config/model.go +++ b/internal/config/model.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/db/clickhouse.go b/internal/db/clickhouse.go index 7d1311c2..25a8bf85 100644 --- a/internal/db/clickhouse.go +++ b/internal/db/clickhouse.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/db/idgen/snowflake.go b/internal/db/idgen/snowflake.go index 32d61644..640274a7 100644 --- a/internal/db/idgen/snowflake.go +++ b/internal/db/idgen/snowflake.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/db/migrator/migrator.go b/internal/db/migrator/migrator.go index 93a51dcd..666249da 100644 --- a/internal/db/migrator/migrator.go +++ b/internal/db/migrator/migrator.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/db/postgres.go b/internal/db/postgres.go index 3fc2205d..958b3d5c 100644 --- a/internal/db/postgres.go +++ b/internal/db/postgres.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/db/postgres_logger.go b/internal/db/postgres_logger.go index d49f2d76..3fbb8df3 100644 --- a/internal/db/postgres_logger.go +++ b/internal/db/postgres_logger.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/db/redis.go b/internal/db/redis.go index 40bdd63a..99fe3e99 100644 --- a/internal/db/redis.go +++ b/internal/db/redis.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/logger/logger.go b/internal/logger/logger.go index 13c8f2a0..747eb6d8 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/logger/ringbuffer.go b/internal/logger/ringbuffer.go index 91b3a5e7..9fbad256 100644 --- a/internal/logger/ringbuffer.go +++ b/internal/logger/ringbuffer.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/logger/ringbuffer_test.go b/internal/logger/ringbuffer_test.go index ab4f0f0d..a5762c78 100644 --- a/internal/logger/ringbuffer_test.go +++ b/internal/logger/ringbuffer_test.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/logger/utils.go b/internal/logger/utils.go index db64ca9b..e24e52cc 100644 --- a/internal/logger/utils.go +++ b/internal/logger/utils.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/model/access_token.go b/internal/model/access_token.go index c73e5148..1b0d6695 100644 --- a/internal/model/access_token.go +++ b/internal/model/access_token.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/model/auth_source.go b/internal/model/auth_source.go index 16ba0292..ae8c0d52 100644 --- a/internal/model/auth_source.go +++ b/internal/model/auth_source.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package model import ( diff --git a/internal/model/system_configs.go b/internal/model/system_configs.go index ac969cf3..78a0b011 100644 --- a/internal/model/system_configs.go +++ b/internal/model/system_configs.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/model/task_execution.go b/internal/model/task_execution.go index b87dce80..07f7635f 100644 --- a/internal/model/task_execution.go +++ b/internal/model/task_execution.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/model/task_execution_test.go b/internal/model/task_execution_test.go index dc5affed..aa0424f8 100644 --- a/internal/model/task_execution_test.go +++ b/internal/model/task_execution_test.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/model/uploads.go b/internal/model/uploads.go index f26d65ab..bed2f3c0 100644 --- a/internal/model/uploads.go +++ b/internal/model/uploads.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/model/users.go b/internal/model/users.go index 5a5b876d..302343a2 100644 --- a/internal/model/users.go +++ b/internal/model/users.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/otel_trace/propagator.go b/internal/otel_trace/propagator.go index 73a5064d..382c8c51 100644 --- a/internal/otel_trace/propagator.go +++ b/internal/otel_trace/propagator.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/otel_trace/sampler.go b/internal/otel_trace/sampler.go index bfc05aad..b02290d2 100644 --- a/internal/otel_trace/sampler.go +++ b/internal/otel_trace/sampler.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/otel_trace/trace.go b/internal/otel_trace/trace.go index 7cd523d6..d513095a 100644 --- a/internal/otel_trace/trace.go +++ b/internal/otel_trace/trace.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/otel_trace/trace_provider.go b/internal/otel_trace/trace_provider.go index 9a12972c..8a106552 100644 --- a/internal/otel_trace/trace_provider.go +++ b/internal/otel_trace/trace_provider.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/router/frontend.go b/internal/router/frontend.go index 4481bdeb..a2b86dfd 100644 --- a/internal/router/frontend.go +++ b/internal/router/frontend.go @@ -2,6 +2,7 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/router/frontend_embedded.go b/internal/router/frontend_embedded.go index c1abcd14..7e94ab56 100644 --- a/internal/router/frontend_embedded.go +++ b/internal/router/frontend_embedded.go @@ -2,6 +2,7 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/router/middlewares.go b/internal/router/middlewares.go index 9c0377fb..bfd72a7b 100644 --- a/internal/router/middlewares.go +++ b/internal/router/middlewares.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/router/router.go b/internal/router/router.go index e052cb7d..403c0e76 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/storage/cache.go b/internal/storage/cache.go index 6e8a20f8..8e263493 100644 --- a/internal/storage/cache.go +++ b/internal/storage/cache.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/storage/errs.go b/internal/storage/errs.go index 926b3ced..dfb5061e 100644 --- a/internal/storage/errs.go +++ b/internal/storage/errs.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/storage/s3.go b/internal/storage/s3.go index 919a9f41..a0d4f930 100644 --- a/internal/storage/s3.go +++ b/internal/storage/s3.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/task/constants.go b/internal/task/constants.go index d832bf12..111fa098 100644 --- a/internal/task/constants.go +++ b/internal/task/constants.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/task/executor.go b/internal/task/executor.go index 1c3c682a..585dfd0c 100644 --- a/internal/task/executor.go +++ b/internal/task/executor.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/task/executor_test.go b/internal/task/executor_test.go index 3326e72f..697a122b 100644 --- a/internal/task/executor_test.go +++ b/internal/task/executor_test.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/task/handler.go b/internal/task/handler.go index 9c06b3c0..2d2eb1b3 100644 --- a/internal/task/handler.go +++ b/internal/task/handler.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/task/handlers/register.go b/internal/task/handlers/register.go index ae10fcff..0588a0c1 100644 --- a/internal/task/handlers/register.go +++ b/internal/task/handlers/register.go @@ -1,5 +1,6 @@ /* Copyright 2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/task/scheduler/scheduler.go b/internal/task/scheduler/scheduler.go index e33e0dcf..fbc0e12a 100644 --- a/internal/task/scheduler/scheduler.go +++ b/internal/task/scheduler/scheduler.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/task/utils.go b/internal/task/utils.go index e8f4cfb1..7ca88f49 100644 --- a/internal/task/utils.go +++ b/internal/task/utils.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/task/worker/middlewares.go b/internal/task/worker/middlewares.go index d437e277..80fe8015 100644 --- a/internal/task/worker/middlewares.go +++ b/internal/task/worker/middlewares.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/task/worker/worker.go b/internal/task/worker/worker.go index 073ddb88..78053ee7 100644 --- a/internal/task/worker/worker.go +++ b/internal/task/worker/worker.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/testhelper/test_helper.go b/internal/testhelper/test_helper.go index 944184b5..30b38937 100644 --- a/internal/testhelper/test_helper.go +++ b/internal/testhelper/test_helper.go @@ -1,5 +1,6 @@ /* Copyright 2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/util/cap/cap.go b/internal/util/cap/cap.go index f173f9b7..76790e2a 100644 --- a/internal/util/cap/cap.go +++ b/internal/util/cap/cap.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cap import ( diff --git a/internal/util/cap/cap_test.go b/internal/util/cap/cap_test.go index afb062d9..85cead21 100644 --- a/internal/util/cap/cap_test.go +++ b/internal/util/cap/cap_test.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cap import ( diff --git a/internal/util/cap/manager.go b/internal/util/cap/manager.go index af53a773..27d9f920 100644 --- a/internal/util/cap/manager.go +++ b/internal/util/cap/manager.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cap import ( diff --git a/internal/util/cap/prng.go b/internal/util/cap/prng.go index f85bbd4e..6bd59242 100644 --- a/internal/util/cap/prng.go +++ b/internal/util/cap/prng.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cap import ( diff --git a/internal/util/cap/store.go b/internal/util/cap/store.go index 84b4b2fa..e08cd0c7 100644 --- a/internal/util/cap/store.go +++ b/internal/util/cap/store.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cap import ( diff --git a/internal/util/context.go b/internal/util/context.go index f452f3ae..4e4dcd83 100644 --- a/internal/util/context.go +++ b/internal/util/context.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/util/crypto.go b/internal/util/crypto.go index 5f055e84..16fd66a4 100644 --- a/internal/util/crypto.go +++ b/internal/util/crypto.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/util/custom_types.go b/internal/util/custom_types.go index aa0ce08d..145c9547 100644 --- a/internal/util/custom_types.go +++ b/internal/util/custom_types.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/util/http_clients.go b/internal/util/http_clients.go index bbf8f4e5..207a5acb 100644 --- a/internal/util/http_clients.go +++ b/internal/util/http_clients.go @@ -1,5 +1,6 @@ /* Copyright 2025-2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/util/mail/mail.go b/internal/util/mail/mail.go index 72bbfe21..43179d7c 100644 --- a/internal/util/mail/mail.go +++ b/internal/util/mail/mail.go @@ -1,5 +1,6 @@ /* Copyright 2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/util/mail/mail_test.go b/internal/util/mail/mail_test.go index 0b3be496..50b9df8e 100644 --- a/internal/util/mail/mail_test.go +++ b/internal/util/mail/mail_test.go @@ -1,5 +1,6 @@ /* Copyright 2026 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/util/password.go b/internal/util/password.go index d66bd0a6..4647f025 100644 --- a/internal/util/password.go +++ b/internal/util/password.go @@ -1,3 +1,19 @@ +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package util import "golang.org/x/crypto/bcrypt" diff --git a/internal/util/response.go b/internal/util/response.go index be36d31b..16a69794 100644 --- a/internal/util/response.go +++ b/internal/util/response.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/util/session.go b/internal/util/session.go index 6a835db3..7125ba42 100644 --- a/internal/util/session.go +++ b/internal/util/session.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/util/strings.go b/internal/util/strings.go index 39436a8f..91f894a7 100644 --- a/internal/util/strings.go +++ b/internal/util/strings.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/util/uuid.go b/internal/util/uuid.go index 4df9a4ee..eda96312 100644 --- a/internal/util/uuid.go +++ b/internal/util/uuid.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/internal/util/validate.go b/internal/util/validate.go index feac9616..42e06dab 100644 --- a/internal/util/validate.go +++ b/internal/util/validate.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/main.go b/main.go index 3ecf82e1..2b444833 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,6 @@ /* Copyright 2025 linux.do +Modified by Arctel.net, 2026 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/scripts/license.sh b/scripts/license.sh deleted file mode 100755 index f03f6c2a..00000000 --- a/scripts/license.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash - -# simple_license_check.sh - 支持多目录排除版本 - -LICENSE_FILE="LICENSE" -FAILED_FILES=() - -# 要排除的目录列表 -EXCLUDE_DIRS=("vendor" "docs" ".git" "node_modules" "build") - -# 检查 LICENSE 文件是否存在 -if [ ! -f "$LICENSE_FILE" ]; then - echo "错误: LICENSE 文件不存在" - exit 1 -fi - -echo "检查 Go 文件是否包含 LICENSE 内容..." - -# 构建 find 命令的排除参数 -exclude_args="" -for dir in "${EXCLUDE_DIRS[@]}"; do - exclude_args="$exclude_args -not -path \"./$dir/*\"" -done - -# 查找所有 Go 文件(排除指定目录和测试文件) -eval "find . -name \"*.go\" $exclude_args -not -name \"*_test.go\"" | while read file; do - echo -n "检查 $file ... " - - # 检查文件前20行是否包含 license 相关关键词 - if head -n 20 "$file" | grep -qi "license\|copyright\|©"; then - echo "✓" - else - echo "✗ 缺少 license" - FAILED_FILES+=("$file") - fi -done - -# 重新统计(因为管道会创建子shell) -FAILED_COUNT=0 -echo -echo "最终检查结果:" - -eval "find . -name \"*.go\" $exclude_args -not -name \"*_test.go\"" | while read file; do - if ! head -n 20 "$file" | grep -qi "license\|copyright\|©"; then - echo "❌ $file 缺少 license" - ((FAILED_COUNT++)) - fi -done - -# 统计失败的文件数量 -TOTAL_FAILED=$(eval "find . -name \"*.go\" $exclude_args -not -name \"*_test.go\"" | \ - while read file; do - if ! head -n 20 "$file" | grep -qi "license\|copyright\|©"; then - echo "$file" - fi - done | wc -l) - -if [ "$TOTAL_FAILED" -eq 0 ]; then - echo "✅ 所有文件都包含 license 头部" - exit 0 -else - echo "❌ 共有 $TOTAL_FAILED 个文件缺少 license 头部" - exit 1 -fi \ No newline at end of file diff --git a/scripts/update_go_license.sh b/scripts/update_go_license.sh new file mode 100755 index 00000000..252457a4 --- /dev/null +++ b/scripts/update_go_license.sh @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +set -euo pipefail + +MODE="write" + +usage() { + cat <<'EOF' +Usage: + scripts/update_go_license.sh [--check] + +Updates Go source files with the project license header. + +Rules: + - Existing Apache license headers gain: + Modified by Arctel.net, 2026 + directly after the Copyright line. + - Go files without a license header receive an Arctel.net Apache header. + - //go:build and legacy // +build constraints stay at the top of the file. + +Options: + --check Report files that would change and exit non-zero if any are found. +EOF +} + +while (($#)); do + case "$1" in + --check) + MODE="check" + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "unknown argument: $1" >&2 + usage >&2 + exit 2 + ;; + esac + shift +done + +tmp_dir="$(mktemp -d)" +trap 'rm -rf "$tmp_dir"' EXIT + +changed=0 + +find_go_files() { + find . \ + \( -path './.git' \ + -o -path './frontend/node_modules' \ + -o -path './frontend/.next' \ + -o -path './frontend/out' \ + -o -path './internal/router/dist' \ + -o -path './vendor' \) -prune \ + -o -type f -name '*.go' -print +} + +process_file() { + local file="$1" + local out="$2" + + perl -0 - "$file" "$out" <<'PERL' +use strict; +use warnings; + +my ($file, $out) = @ARGV; + +open my $in, '<', $file or die "open $file: $!"; +local $/; +my $src = <$in>; +close $in; + +my $modified = 'Modified by Arctel.net, 2026'; +my $new_header = <<'HEADER'; +/* +Copyright 2026 Arctel.net + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ +HEADER +chomp $new_header; + +my @lines = split /\n/, $src, -1; +my @prefix; +my $i = 0; + +if (@lines && ($lines[0] =~ m{^//go:build } || $lines[0] =~ m{^// \+build })) { + while ($i < @lines) { + if ($lines[$i] =~ m{^//go:build } || $lines[$i] =~ m{^// \+build }) { + push @prefix, $lines[$i++]; + next; + } + if ($lines[$i] eq '') { + push @prefix, $lines[$i++]; + last if $i >= @lines || ($lines[$i] !~ m{^//go:build } && $lines[$i] !~ m{^// \+build }); + next; + } + last; + } +} + +my $prefix = @prefix ? join("\n", @prefix) . "\n" : ''; +my $body = join "\n", @lines[$i .. $#lines]; +my $result; + +if ($body =~ m{\A(/\*.*?\*/)(\n*)}s) { + my $block = $1; + my $rest = substr($body, length($1) + length($2)); + + if ($block =~ /Licensed under the Apache License, Version 2\.0/ && $block =~ /Copyright /) { + if ($block !~ /Copyright [^\n]*Arctel\.net/ && $block !~ /\Q$modified\E/) { + $block =~ s/^(Copyright [^\n]*)$/$1\n$modified/m; + } + $result = $prefix . $block . "\n\n" . $rest; + } else { + $rest =~ s/\A\n+//; + $result = $prefix . $new_header . "\n\n" . $block . "\n\n" . $rest; + } +} else { + $body =~ s/\A\n+//; + $result = $prefix . $new_header . "\n\n" . $body; +} + +open my $fh, '>', $out or die "write $out: $!"; +print {$fh} $result; +close $fh; +PERL +} + +while IFS= read -r file; do + tmp_file="$tmp_dir/${file#./}" + mkdir -p "$(dirname "$tmp_file")" + process_file "$file" "$tmp_file" + + if ! cmp -s "$file" "$tmp_file"; then + changed=1 + if [[ "$MODE" == "check" ]]; then + echo "needs license update: $file" + else + cp "$tmp_file" "$file" + echo "updated: $file" + fi + fi +done < <(find_go_files) + +if [[ "$MODE" == "check" && "$changed" -ne 0 ]]; then + exit 1 +fi