✨ feat(server): 新增每 IP 请求限流

- 新增 RateLimit 中间件:golang.org/x/time/rate 令牌桶,超出返回 429
- server.rate_limit_qps 配置(默认 0 不限制,突发 10),公网部署建议开启
- 业务路由统一接入 限流 → 鉴权 中间件链;/healthz 与静态资源不限流
- X-Forwarded-For 优先取真实客户端 IP(反代场景),visitor 表定时清理防泄漏
- config.yaml 补齐 protect_all 与 rate_limit_qps 配置项(此前仅存在于代码)
This commit is contained in:
chenxin committed 2026-09-30 00:24:58 +08:00
1 parent 822d3fe444
commit f89bee8ddc
5 files changed
+112 -38

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ require (
github.com/mattn/go-sqlite3 v1.14.18
github.com/redis/go-redis/v9 v9.22.0
github.com/spf13/viper v1.18.2
golang.org/x/time v0.5.0
)
require (