6f17bbad7e
chore: remove trailing blank lines and clean up whitespace
2026-06-03 18:08:34 +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
fdf04476e8
refactor(lua): merge variable getter functions
...
Make getVariable call getVariableLua and convert LValue to string,
eliminating ~85 lines of duplicate variable access logic.
Both functions now share the same switch-case implementation.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 18:25:41 +08:00
247fa81c00
fix(lua): 修复 Lua 引擎并发安全问题
...
- 缓存 coroutine.yield/status 函数,避免并发读取全局 Lua 状态机
- 添加 ngxRegisterMu 锁保护共享 ngx 表的并发写入
- 各 API 注册函数检查字段是否已存在,避免重复写入
- TCPSocket.currentOp 字段添加锁保护
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-29 14:19:11 +08:00
5354dceaf7
fix(lua): 修复 remote_port 和 server_port 变量返回空值
...
- 实现 remote_port 从 RemoteAddr 正确解析端口
- 实现 server_port 从 LocalAddr 正确解析端口
- 使用 strings.LastIndex 兼容 IPv4/IPv6 地址格式
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 16:03:41 +08:00
ad177e9640
docs(lua): 为 Lua API 模块添加标准化 godoc 注释
...
为所有 Lua API 文件添加完整的包级和函数级文档注释:
- api_balancer: 负载均衡 API(set_current_peer, set_more_tries 等)
- api_ctx: 请求上下文存储 API(ngx.ctx)
- api_location: 子请求捕获 API(ngx.location.capture)
- api_log: 日志输出 API(ngx.log)
- api_req: 请求对象 API
- api_resp: 响应对象 API
- api_shared_dict: 共享字典 API
- api_socket_tcp: TCP socket API
- api_timer: 定时器 API
- api_var: 变量 API
- engine: Lua 引擎核心
- context: 请求上下文管理
- coroutine: 协程调度器
- middleware: 中间件集成
- filter_writer: 响应过滤器
- cache: Lua 脚本缓存
- shared_dict: 共享字典实现
- socket_manager: socket 连接管理
注释格式遵循 Go 官方风格,包含功能说明、参数说明和注意事项。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-20 10:59:17 +08:00
9d95aecd6f
refactor(lua): 提取常量并优化结构体字段布局
...
- api_var.go: 提取 argPrefix 常量,消除魔法字符串
- coroutine.go: 按逻辑分组重排 LuaCoroutine 字段,改善可读性
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 18:24:05 +08:00
f123018f2d
feat(lua): 增强变量 API 支持数值类型返回和测试覆盖
...
- 新增 getVariableLua 方法返回 Lua 类型而非字符串
- request_length 等变量返回数值类型而非字符串
- luaVarNewIndex 支持 nil 值转换为空字符串
- 添加 api_var 全面的单元测试覆盖
- 添加 api_ctx 上下文 API 测试
- 添加 api_socket_tcp TCP socket 测试
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 18:12:16 +08:00
26f18055ce
feat(lua): 添加 Scheduler 模式下的 API 安全检查
...
为定时器回调上下文注册不安全的 ngx API 时返回错误:
- ngx.ctx: 请求上下文不可用
- ngx.req: 请求 API 不可用
- ngx.resp: 响应 API 不可用
- ngx.var: 变量 API 不可用
- ngx.log: 提供安全版本(不依赖 RequestCtx)
防止定时器回调中误用请求相关 API 导致并发问题。
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 09:24:43 +08:00
51061d68ff
feat(lua): 实现 ngx.var API
...
通过元表实现动态变量读写,支持 nginx 内置变量和自定义变量
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-11 12:17:35 +08:00