9824ad5b57
perf(netutil): cache RemoteAddr string formatting
...
Add netutil.FormatRemoteAddr() to avoid repeated net.TCPAddr.String()
allocations on the hot logging path.
- IPv4 addresses use a zero-allocation fast path (custom uint8->ASCII).
- IPv6 falls back to addr.String() with a 1024-entry LRU cache.
- Update logging.LogAccess and variable $remote_addr/$remote_port
getters to use the shared helper.
Eliminates net.JoinHostPort and net.IP.String from top allocators
when access logging is active.
2026-06-11 14:43:12 +08:00
6f17bbad7e
chore: remove trailing blank lines and clean up whitespace
2026-06-03 18:08:34 +08:00
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
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
dc7358bf4e
feat(variable): 添加 EphemeralGet 和 PersistentGet 零拷贝变量访问 API
...
- 新增 EphemeralGet() 方法返回 []byte,用于请求范围内的零拷贝访问
- 新增 PersistentGet() 方法返回 string,用于跨请求持久存储
- BuiltinVariable 结构体添加 GetterBytes 字段支持字节获取器
- Context 结构体添加 bytesCache map 缓存字节值
- 为 $host、$request_uri、$uri、$args、$request_method 添加字节获取器
- 添加完整的单元测试和性能基准测试
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 13:50:15 +08:00
0731dc46e4
refactor(variable): 重命名核心类型移除冗余前缀
...
VariableContext → Context
VariableStore → Store
ReleaseVariableContext → ReleaseContext (别名保留向后兼容)
提取硬编码字符串为命名常量 sslProtocolNone
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 09:40:17 +08:00
61455412eb
feat(variable,proxy): 新增上游变量支持,集成到代理请求处理
...
- 新增 upstream_addr、upstream_status、upstream_response_time 等变量
- 新增 UpstreamTiming 结构体捕获连接、首字节、响应时间
- Proxy.ServeHTTP 集成变量上下文,记录上游时间
- 新增测试覆盖上游变量和计时功能
Co-Authored-By: Claude <noreply@anthropic.com>
2026-04-08 14:36:37 +08:00
c95f474539
feat(variable): 新增变量系统支持
...
新增 internal/variable 包,提供 Nginx 风格的变量展开功能:
- 支持 $remote_addr、$host、$uri、$args 等 30+ 内置变量
- 使用 sync.Pool 优化 VariableContext 分配
- 支持 set_response_info 存储响应状态信息
添加 github.com/google/uuid 依赖用于请求 ID 生成。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 11:36:49 +08:00