1a6b5f9166
Merge origin/master into master
2026-06-03 16:36:23 +08:00
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
xfy911
a136b07bb9
docs: add documentation comments for exported constants and variables
...
- Fix gjson/gjson.go package comments and constant documentation
- Fix internal/config/config.go constant documentation
- Fix internal/utils/httperror.go variable documentation
- Fix internal/matcher/matcher.go constant documentation
- Fix internal/middleware/compression/compression.go constant documentation
- Fix internal/middleware/limitrate/limitrate.go constant documentation
- Fix internal/middleware/rewrite/rewrite.go constant documentation
- Fix internal/middleware/security/access.go and auth.go constant documentation
- Fix internal/ssl/client_verify.go constant documentation
- Fix internal/variable/builtin.go and ssl.go constant documentation
- Fix internal/lua/api_log.go HTTP and log level constant documentation
- Fix internal/benchmark/tools/tools.go constant documentation
- Include author attribution (xfy)
2026-06-03 15:28:53 +08:00
xfy911
396a466de1
docs: add documentation comments for exported constants and variables
...
- Add comments for lua/api_log.go HTTP status codes and log levels
- Add comments for variable/builtin.go and ssl.go constants
- Add comments for utils/httperror.go error variables
- Add comments for matcher/matcher.go location types
- Add comments for compression/compression.go algorithms
- Include author attribution (xfy)
2026-06-03 15:28:53 +08:00
556d40ceb0
fix(matcher,server): use ConflictError in AddNamed and add tests
...
Make AddNamed return *ConflictError for consistency with other Add*
methods so handleRegistrationError treats named location conflicts as
warnings instead of fatal errors. Add tests for handleRegistrationError
covering both conflict and fatal error paths.
2026-06-03 11:47:06 +08:00
38bb743781
fix(server): handle LocationEngine registration errors properly
...
Add typed ConflictError for path conflicts, change register functions
to return errors, handle conflicts as warnings and fatal errors as
startup failures. Remove all 20 instances of ignored Add* return values.
2026-06-03 10:12:09 +08:00
25d93c25fa
refactor: remove unused code and fix formatting
...
- Remove unused benchmark/tools package
- Make ValidAlgorithms private (validAlgorithms) in loadbalance
- Remove dead code (_ = result) in lua/api_socket_tcp.go
- Fix code formatting with goimports
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-09 16:58:45 +08:00
f145a8770e
refactor: modernize code with Go 1.22+ features
...
Apply modern Go patterns across the codebase:
- Replace `interface{}` with `any` (Go 1.18+)
- Use `for range n` instead of `for i := 0; i < n; i++` (Go 1.22+)
- Replace `sort.Slice` with `slices.Sort` from slices package
- Simplify sync.WaitGroup patterns with errgroup where appropriate
- Add Makefile targets for modernize analyzer
Total: 84 files updated, net reduction of 79 lines
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-30 10:37:45 +08:00
ae0bec6c3b
feat(internal): 实现 internal 指令
...
- 新增 IsInternalRedirect 检测内部重定向请求
- static handler 支持 internal 访问限制
- proxy handler 支持 internal 访问限制
- 支持 X-Accel-Redirect 内部重定向
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 18:09:06 +08:00
65080cca66
feat(matcher): 支持 internal location 标记
...
- MatchResult 新增 Internal 字段
- AddExact/AddPrefix/AddPrefixPriority/AddRadix/AddRegex 方法新增 internal 参数
- location 解析器支持 internal 指令
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 18:08:23 +08:00
82658359cb
fix(matcher): 修正 ParseRegexPattern nginx 风格正则解析
...
- ~ 现为大小写敏感正则(之前错误为不敏感)
- ~* 为大小写不敏感正则
- ^~ 为前缀优先匹配(非正则,之前错误标记为正则)
- 更新测试用例匹配正确行为
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 16:04:18 +08:00
10f3da0954
docs(matcher): 为 location 匹配引擎添加标准化 godoc 注释
...
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 11:23:03 +08:00
6094327620
docs(matcher): 为 location 匹配引擎添加标准化 godoc 注释
...
为 matcher 包所有文件添加完整文档注释:
- conflict: 路径冲突检测器
- exact: 精确路径匹配器(O(1) hash map)
- location: 统一匹配引擎(整合所有策略)
- matcher: 匹配结果和接口定义
- named: 命名捕获组匹配器
- prefix: 普通前缀匹配器
- prefix_priority: 前缀优先匹配器(^~)
- radix: Radix Tree 最长前缀匹配
- regex: 正则表达式匹配器
注释说明匹配优先级顺序(精确 > 前缀优先 > 正则 > 普通前缀),
以及各匹配器的使用方法和性能特点。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 10:59:27 +08:00
c82e6dcdb7
test(matcher): 添加 location 匹配引擎完整测试覆盖
...
- conflict_test.go: 测试 location 冲突检测
- location_test.go: 测试 location 匹配逻辑
- named_test.go: 测试命名捕获组
- prefix_priority_test.go: 测试前缀匹配优先级
- prefix_test.go: 测试前缀匹配
- regex_test.go: 测试正则匹配
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 08:27:24 +08:00
ca03c121d3
refactor(matcher): 提取 LocationType 常量并优化结构体字段布局
...
- 添加 LocationType 常量定义替代硬编码字符串
- 优化 MatchResult、ExactMatcher、NamedMatcher 结构体字段顺序
- RadixTree.Insert 添加 locationType 参数用于调试追踪
- 更新测试代码适配新接口
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-17 10:11:45 +08:00
53eaec57ad
feat(matcher): 添加 nginx 风格 location 匹配引擎
...
实现 nginx 兼容的 location 匹配系统,支持:
- 精确匹配 (=) - Hash Map O(1)
- 前缀优先匹配 (^~) - Radix Tree
- 正则匹配 (~, ~*) - 按配置顺序
- 普通前缀匹配 - Radix Tree 最长匹配
- 命名 location (@name) - 内部重定向
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-17 09:26:22 +08:00