Skip to content

Conversation

@wxszlm
Copy link
Contributor

@wxszlm wxszlm commented Dec 8, 2025

📝 更新内容

🎯 新增功能

1. 构建时配置注入系统

  • ✅ 支持通过配置文件 (.build.config) 在构建时自动注入后端地址
  • ✅ 支持环境变量方式配置
  • ✅ 运行时环境变量优先级最高,可覆盖构建配置
  • ✅ 自动记录构建版本和构建时间

实现文件

  • main.go - 添加可注入的配置变量
  • build.sh - 增强构建脚本,支持配置读取和注入
  • .build.config.example - 配置文件模板
  • .build.config - 实际配置文件(已添加到 .gitignore

2. 完善的日志系统

  • ✅ 所有操作自动记录到日志文件 (~/.config/antihook/kiro.log)
  • ✅ 记录完整的请求和响应信息
  • ✅ 便于调试和问题排查

实现文件

  • main.go - 添加日志记录功能

3. 用户体验优化

  • ✅ 移除中间过程弹框("Logging info...")
  • ✅ 只在成功或失败时显示结果
  • ✅ 静默运行,减少用户干扰

实现文件

  • main.go - 优化弹框显示逻辑

4. macOS 协议注册优化

  • ✅ 修复 macOS 协议注册问题
  • ✅ 添加 Bundle Identifier 和完整的 Info.plist 配置
  • ✅ 使用 LaunchServices 正确注册协议
  • ✅ 自动使用 duti 设置默认处理器

实现文件

  • registry/registry_darwin.go - 完善 macOS 协议注册

5. GitHub Actions 多平台构建

  • ✅ 添加 macOS Intel (amd64) 构建
  • ✅ 添加 macOS Apple Silicon (arm64) 构建
  • ✅ 保留 Windows (amd64) 构建
  • ✅ 使用矩阵策略并行构建
  • ✅ 自动创建 Release 并上传所有平台的构建产物
  • ✅ Release 中包含配置信息和使用说明

实现文件

  • .github/workflows/build.yml - 重构为多平台矩阵构建

📚 文档更新

新增文档

  • BUILD_GUIDE.md - 详细的构建配置指南
  • MAC_INSTALL_GUIDE.md - macOS 完整安装和使用教程
  • TROUBLESHOOTING.md - 故障排查指南
  • API_ISSUE_REPORT.md - API 诊断报告模板

更新文档

  • README.md - 添加所有新功能说明、使用方法和文档索引

🔧 配置文件

新增配置

  • .build.config.example - 配置文件模板
  • .build.config - 生产环境配置(已配置 tunnel.mortis.edu.kg)

更新配置

  • .gitignore - 添加 .build.config 到忽略列表

📊 技术细节

构建时配置注入实现

配置优先级(从高到低):

  1. 运行时环境变量 (KIRO_SERVER_URL, BACKEND_URL)
  2. 构建时配置文件 (.build.config)
  3. 构建时环境变量
  4. 默认值 (localhost)

注入方式

go build -ldflags="-X 'main.DefaultServerURL=$SERVER_URL' -X 'main.DefaultBackendURL=$BACKEND_URL'"

GitHub Actions 构建矩阵

strategy:
  matrix:
    include:
      - os: windows-latest
        output: antihook.exe
      - os: macos-latest
        goarch: amd64
        output: antihook-darwin-amd64
      - os: macos-latest
        goarch: arm64
        output: antihook-darwin-arm64

日志系统

日志文件~/.config/antihook/kiro.log

日志内容

  • 接收到的回调 URL
  • 发送的请求详情
  • 服务器响应状态和内容
  • 错误信息

🧪 测试说明

本地测试

  1. 配置测试
# 配置后端地址
cp .build.config.example .build.config
# 编辑 .build.config 设置地址

# 构建
./build.sh darwin

# 验证配置
strings build/antihook-darwin-amd64 | grep "tunnel.mortis.edu.kg"
  1. 功能测试
# 安装
./build/antihook-darwin-amd64

# 测试协议
open "kiro://test?code=123"

# 查看日志
cat ~/.config/antihook/kiro.log

CI/CD 测试

Push 到 main/master 分支后:

  1. GitHub Actions 自动触发构建
  2. 并行构建 3 个平台
  3. 创建 Release
  4. 上传所有构建产物

📈 影响范围

修改的文件

  • main.go - 核心功能增强
  • registry/registry_darwin.go - macOS 协议注册修复
  • build.sh - 构建脚本增强
  • .github/workflows/build.yml - CI/CD 多平台支持
  • README.md - 文档更新

新增的文件

  • .build.config.example - 配置模板
  • .build.config - 生产配置
  • BUILD_GUIDE.md - 构建指南
  • MAC_INSTALL_GUIDE.md - macOS 安装指南
  • TROUBLESHOOTING.md - 故障排查
  • API_ISSUE_REPORT.md - API 诊断

✅ 检查清单

  • 代码已经过本地测试
  • 所有新功能已添加文档说明
  • 构建脚本在 macOS 和 Windows 上测试通过
  • GitHub Actions 配置已验证
  • 日志系统正常工作
  • 协议注册在 macOS 上测试通过
  • README.md 已更新所有新功能

🔄 Breaking Changes

无破坏性变更。所有现有功能保持向后兼容。

📝 备注

  • 配置文件 .build.config 已添加到 .gitignore,不会被提交
  • GitHub Actions 需要配置 Secrets:KIRO_SERVER_URLBACKEND_URL
  • macOS 用户首次使用时可能需要在"系统设置 → 隐私与安全性"中允许运行

🎯 后续计划

  • 添加 Linux 构建支持(需要 Linux registry 实现)
  • 添加自动更新检查功能
  • 优化 Windows 协议注册体验
  • 添加配置验证功能

测试环境

  • macOS Sequoia
  • Go 1.21+
  • GitHub Actions

相关 Issue:#N/A

文档:所有文档已更新,详见 README.md

@KKKrZa KKKrZa merged commit 7b0550b into AntiHub-Project:main Dec 8, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants