16 Commits

Author SHA1 Message Date
xfy
6612819f3a chore: remove stale AGENTS.md files, rewrite root AGENTS.md 2026-06-03 23:47:29 +08:00
xfy
1a6b5f9166 Merge origin/master into master 2026-06-03 16:36:23 +08:00
xfy
2734b04d8f refactor: remove 16.8k lines of dead code across all internal packages
- Delete unused files: tempfile subsystem, matcher variants, server/internal
- Remove 200+ unused functions across proxy, ssl, lua, http2/3, stream, variable
- Fix proxy test type errors (backgroundRefresh ctx→Request)
- Move bench/tools mock backend into internal/testutil
- Remove corresponding test functions for all deleted code
2026-06-03 16:15:43 +08:00
xfy911
a6152d4dc1 docs: add documentation comments for method implementations and test utilities
- Add GoDoc for Warning.String, ParseError.Error
- Add GoDoc for ngxReqAPILayer.String, Phase.String, SocketState.String
- Add GoDoc for ConflictError.Error
- Add GoDoc for noopResolver methods (LookupHost, LookupHostWithCache, Refresh, Start, Stop, Stats)
- Add GoDoc for load balancer Select methods (roundRobin, weightedRoundRobin, ipHash)
- Add GoDoc for WithWSHeaders test utility
- Include author attribution (xfy)
2026-06-03 15:28:53 +08:00
xfy
74f08466d4 fix(lint): 修复 goconst 和未使用导入问题
- 将重复的 "static" 字符串提取为 staticType 常量
- 移除 compression_e2e_test.go 中未使用的 fmt 导入

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 17:38:14 +08:00
xfy
0e1a826464 fix(converter): 支持一个 server 块有多个 listen 指令的转换
nginx 配置中一个 server 块可以有多个 listen 指令(如 listen 80; listen 443 ssl;),
之前转换器只保留最后一个 listen 值,导致多个 server 块最终有相同的 listen 地址,
触发验证冲突。

修改内容:
- converter: 添加 listenInfo 结构体和 parseListenInfo 函数
- converter: 重构 convertServerBlock 返回 []ServerConfig,为每个 listen 创建独立配置
- validate: 使用 listen+name 组合作为唯一键,允许相同 listen 但不同 server_name

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 15:21:17 +08:00
xfy
d191e1865d feat(static): 添加 expires 缓存控制支持
- StaticConfig 添加 Expires 字段,支持 nginx 兼容格式(30d, 1h, max, epoch)
- StaticHandler 添加 SetExpires 方法和缓存响应头设置
- serveFile 自动设置 Cache-Control 和 Expires 响应头
- nginx 转换器正确转换 expires 指令
- --generate-config 输出包含 expires 文档和示例

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 14:05:25 +08:00
xfy
02265331d4 fix(converter): 没有 root/alias/try_files 的 location 继承 server root
- classifyLocation 增加 serverRoot 参数
- 当 location 没有显式 root/alias/try_files 但有 server 级别 root 时,分类为 static
- 正则 location 正确继承 server root 并设置 location_type

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 13:28:25 +08:00
xfy
07acfad146 feat(config): 添加 alias 配置支持
- StaticConfig 添加 Alias 字段,与 Root 互斥
- server.go 创建 handler 时设置 alias
- validate.go 添加 root/alias 互斥验证和路径安全检查
- converter.go nginx alias 指令正确转换为 Alias 字段
- defaults.go --generate-config 输出包含 alias 文档和示例

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 13:16:12 +08:00
xfy
5bb44fdbcb fix(converter): try_files 也作为静态类型判断条件,继承 server 级别 root/index
- classifyLocation 将 try_files 也识别为静态类型
- 静态配置自动继承 server 级别的 root 和 index(如果未指定)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 11:41:40 +08:00
xfy
78ca32748c feat(converter): 支持 server 级别的 root 和 index 指令转换
- 在 convertServerBlock 中收集 server 级别的 root/index 指令
- 如果没有显式的 location / 静态配置,创建默认静态配置
- 如果 location / 是 proxy 类型,不创建静态配置
- 添加 3 个测试用例覆盖不同场景

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 11:38:47 +08:00
xfy
b290cea0f6 fix(converter): 修复 nginx 配置解析空字符串和 upstream URL
- 解析器正确处理空引号字符串 "",使用标记区分空字符串和特殊字符
- upstream server URL 自动添加 http:// 前缀以满足 lolly 配置验证
- proxy_set_header 正确处理空字符串值(如 Connection "")

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 11:27:32 +08:00
xfy
c18ce613b3 style: 格式化代码
- 使用 Go 1.13+ 八进制字面量格式 (0o644)
- 修复文件末尾缺少换行符
- 对齐结构体字段

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 10:20:18 +08:00
xfy
1f672d1a7a fix(lint): 修复所有 lint 错误
- 为导出的函数添加注释 (revive)
- 检查 os.Stdout.Write 返回值 (errcheck)
- 重命名 err 变量避免 shadow declaration (govet)
- 使用 tagged switch 替代 if-else (staticcheck QF1003)
- 用 append 展开替换循环 (staticcheck S1011)
- 添加常量消除重复字符串 (goconst)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-27 10:20:01 +08:00
xfy
2122067efb docs: 更新 AGENTS.md 文档,添加新模块说明
- 更新所有 AGENTS.md 时间戳至 2026-04-24
- 添加 converter、e2e、testutil 模块文档
- 更新 README.md:nginx 配置导入、stale 缓存功能说明
- 更新项目统计:132 Go 文件,157 测试文件

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 18:24:31 +08:00
xfy
909bd405d2 feat(converter,app): 添加 nginx 配置导入功能
- 新增 internal/converter/nginx 解析器和转换器
- main.go 添加 --import/-i 参数支持 nginx 配置导入
- app_test.go 添加导入功能相关测试

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 17:12:49 +08:00