xfy911
|
522685e55b
|
feat: 实现带宽限速 / 流量整形(Token Bucket 算法)
CI / build (push) Failing after 1m0s
- 新增 throttle.c/throttle.h:Token Bucket 双层限速实现
- 支持 per-connection(单连接限速)和 global(服务器总带宽限速)
- 使用 fd 映射表自动注册/清理,侵入性最小
- cocoon.h: 配置结构体新增 throttle_conn_rate、throttle_global_rate
- server.c: 连接创建时自动初始化 per-connection throttle;server_destroy 释放 global throttle
- static.c: send_all() 自动查表限速
- platform.c: cocoon_file_send() 限速启用时回退到 read+write 循环,逐 chunk 限速
- proxy.c: send_all_fd() 加入限速
- config.c: 解析 JSON 配置中的 throttle 对象(conn_rate / global_rate)
- config.h: 更新 config_merge 签名
- Makefile: 将 throttle.c 加入 SRCS 和所有单元测试编译规则
编译零警告,109 项集成测试通过(6 个失败为已知环境反向代理 404 问题)
|
2026-06-16 15:41:24 +08:00 |
|