# 变更日志 本文档记录rhttpd项目的所有重要变更。 格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/), 并且本项目遵循 [语义化版本](https://semver.org/lang/zh-CN/)。 ## [未发布] ### 修复 - ✅ 修复ForwardProxy的Clone trait实现 - ✅ 修复TcpProxyManager的Clone trait实现 - ✅ 确保项目编译通过 - ✅ 验证所有测试通过(7个测试) - ✅ 通过clippy代码检查 ### 计划中 - [ ] TCP代理协议检测 - [ ] WebSocket消息解析和转发 - [ ] 完整SSL/TLS支持 - [ ] 完整JavaScript运行时集成 ## [0.2.0] - 2025-01-15 ### 新增 - 🌊 **TCP代理支持** - 原始TCP流量转发 - WebSocket协议代理框架 - 协议检测和路由 - 🔄 **连接池管理** - HTTP连接复用 - 连接保活机制 - 连接数限制 - 空闲连接清理 - ⚖️ **负载均衡** - 轮询 (Round Robin) 算法 - 最少连接 (Least Connections) 算法 - 加权轮询 (Weighted Round Robin) 算法 - IP哈希 (IP Hash) 算法 - 随机选择 (Random) 算法 - 🏥 **健康检查机制** - HTTP健康检查端点 - TCP连接健康检查 - 后端服务状态监控 - 故障检测和恢复 - 响应时间统计 - 🛠️ **配置增强** - 连接池配置选项 - 健康检查配置选项 - 多种负载均衡策略配置 ### 变更 #### 新增模块 - `proxy/tcp_proxy.rs` - TCP和WebSocket代理实现 - `proxy/connection_pool.rs` - HTTP连接池管理 - `proxy/load_balancer.rs` - 负载均衡策略实现 - `proxy/health_check.rs` - 健康检查系统 #### 配置增强 ```toml # 新增连接池配置 [connection_pool] max_connections = 100 idle_timeout = 90 # 秒 # 新增健康检查配置 [health_check] interval = 30 # 秒 timeout = 5 # 秒 path = "/health" expected_status = 200 # 增强的负载均衡配置 [[sites."example.com".routes]] type = "reverse_proxy" path_pattern = "/api/*" target = "http://backend:3000" [sites."example.com".routes.load_balancer] strategy = "round_robin" # round_robin, least_connections, weighted_round_robin, ip_hash, random upstreams = ["http://backend1:3000", "http://backend2:3000"] weights = [1, 2] # 可选的权重配置 ``` #### API增强 - `ConnectionPool` - HTTP连接池管理 - `LoadBalancer` - 负载均衡器 - `HealthChecker` - 健康检查器 - `TcpProxyManager` - TCP代理管理器 #### 测试覆盖 - 新增连接池测试 (1个测试) - 新增负载均衡测试 (1个测试) - 现有测试7个全部通过 ### 技术细节 #### 新增依赖 - `tokio-tungstenite` - WebSocket支持 - `base64` - WebSocket握手支持 - `sha1` - WebSocket认证支持 - `rand` - 负载均衡随机选择 #### 性能优化 - 连接池减少连接建立开销 - 负载均衡提高后端利用率 - 健康检查快速故障转移 - 异步架构保证高并发性能 #### 安全增强 - 连接数限制防止资源耗尽 - 超时机制防止连接堆积 - 健康检查确保服务可用性 ### 文档更新 - README.md - 新增v0.2.0功能介绍 - AGENTS.md - 更新开发指南 - roadmap.md - 新增详细实现计划 - CHANGELOG.md - 版本变更记录 ### 配置示例 #### TCP代理配置 ```toml [[sites."ws.example.com".routes]] type = "tcp_proxy" path_pattern = "/ws/*" target = "ws://websocket-server:8080" protocol = "websocket" # tcp, websocket, http ``` #### 负载均衡配置 ```toml [[sites."api.example.com".routes]] type = "reverse_proxy" path_pattern = "/api/*" target = "http://primary-backend" [sites."api.example.com".routes.load_balancer] strategy = "least_connections" upstreams = [ "http://backend1:3000", "http://backend2:3000", "http://backend3:3000" ] weights = [3, 2, 1] # 权重配置 ``` #### 健康检查配置 ```toml [health_check] interval = 30 # 检查间隔(秒) timeout = 5 # 超时时间(秒) path = "/health" # 健康检查路径 expected_status = 200 # 期望的状态码 ``` ## [0.1.0] - 2025-01-15 ### 新增 - 🏗️ **基础HTTP服务器框架** - 基于axum的异步服务器 - 支持多站点托管 - 基于Host头的路由 - 📁 **静态文件服务** - 自动MIME类型检测 - 索引文件支持 - 目录访问控制 - 🔀 **反向代理** - HTTP请求转发 - 头部重写和传递 - 请求/响应体转发 - ⚙️ **配置系统** - TOML格式支持 - JSON格式支持 - 配置验证机制 - 🧙 **JavaScript配置基础** - JS配置文件解析 (简化版) - 与TOML/JSON配置集成 ### 技术细节 #### 依赖 - `tokio` - 异步运行时 - `axum` - HTTP框架 - `hyper` - HTTP实现 - `reqwest` - HTTP客户端 - `serde` - 序列化/反序列化 - `toml` - TOML解析 - `mime_guess` - MIME类型检测 - `tower-http` - HTTP服务工具 - `tracing` - 日志记录 #### 项目结构 ``` rhttpd/ ├── src/ │ ├── main.rs # 应用程序入口 │ ├── lib.rs # 库根 │ ├── config/ # 配置管理 │ ├── server/ # 服务器实现 │ ├── proxy/ # 代理功能 │ └── js_engine/ # JavaScript集成 ├── tests/ # 集成测试 ├── doc/ # 文档和需求 ├── public/ # 静态文件示例 ├── static/ # 静态文件示例 ├── config.toml # TOML配置示例 ├── config.js # JavaScript配置示例 ├── README.md # 项目文档 ├── AGENTS.md # 开发者指南 ├── roadmap.md # 开发路线图 └── CHANGELOG.md # 变更日志 ``` #### 测试结果 - ✅ 3个单元测试通过 - ✅ 2个集成测试通过 - ✅ 所有代码符合clippy规范 - ✅ 项目可正常构建和运行 ### 配置示例 #### 基本配置 ```toml port = 8080 [sites."example.com"] hostname = "example.com" [[sites."example.com".routes]] type = "static" path_pattern = "/*" root = "./public" index = ["index.html"] [[sites."example.com".routes]] type = "reverse_proxy" path_pattern = "/api/*" target = "http://localhost:3000" ``` #### JavaScript配置示例 ```javascript export default { port: 8080, sites: { "api.example.com": { hostname: "api.example.com", routes: [ { type: "reverse_proxy", path_pattern: "/v1/*", target: "http://localhost:3001", rewrite: { "^/v1": "/api/v1" } } ] }, "static.example.com": { hostname: "static.example.com", routes: [ { type: "static", path_pattern: "/*", root: "./static", index: ["index.html"] } ] } }, // JavaScript中间件示例 middleware: async function(req) { console.log(`Request: ${req.method} ${req.url}`); return null; // 返回null继续处理,或返回Response直接响应 } }; ``` ### 使用示例 #### 启动服务器 ```bash # 使用默认配置 cargo run # 使用指定配置文件 cargo run -- config.toml # 使用JavaScript配置 cargo run -- config.js ``` #### 测试 ```bash # 运行所有测试 cargo test # 运行单个测试 cargo test test_name # 代码检查 cargo clippy # 代码格式化 cargo fmt # 文档生成 cargo doc --open ``` --- ## 版本说明 ### 版本号规则 - **主版本号**: 不兼容的API修改 - **次版本号**: 向下兼容的功能性新增 - **修订号**: 向下兼容的问题修正 ### 发布周期 - **主版本**: 根据需要发布 - **次版本**: 每季度发布 - **修订版**: 根据需要发布 ### 分支策略 - **main**: 稳定版本 - **develop**: 开发版本 - **feature/***: 功能分支 --- *最后更新: 2025年1月15日*