Commit Graph
5 Commits
Author SHA1 Message Date
TT 666a5c6f87 fix(redeem): use a fixed 10-minute failure window
The redeem failure counter used INCR followed by Expire(24h) on every
attempt, so each failed attempt refreshed the key TTL and the window
never actually closed for a user who kept retrying within 24h.

- Count attempts in a fixed 10-minute window via a small Lua script
  (INCR, then PEXPIRE only when the key is created or has no TTL), which
  is atomic and also repairs keys that lost their TTL.
- Move the counter to the redeem:ratelimit:v2: key space so pre-existing
  24h counters do not seed the new window.
- Rename the service threshold to redeemMaxFailedAttempts (30) to reflect
  that it bounds attempts per window, not per hour.

Public redeem behavior is unchanged apart from the window semantics:
the check fails open when the counter read fails, and a failed
increment never masks the underlying domain error.
2026-09-05 23:38:50 +08:00
Forest 06d5876b02 refactor: 封装 Redis key 生成函数 2025-12-26 16:47:44 +08:00
Forest f51ad2e126 refactor: 删除 ports 目录 2025-12-25 17:15:01 +08:00
Forest 836c4dda2b refactor: 重命名 go module 2025-12-24 21:07:21 +08:00
Forest 7bbf621490 refactor(backend): 添加 service 缓存端口 2025-12-19 23:44:18 +08:00