修复:调整游客取号限流策略
问题:移动网络共享出口 IP 会造成游客取号被误限流。 实现:移除公开取号 IP 限制,改用项目总量与手机号 HMAC 限流,并支持 Retry-After 倒计时。
This commit is contained in:
@@ -25,6 +25,23 @@ func TestQueryLimiterResetsAfterWindow(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestQueryLimiterRemovesExpiredEntries(t *testing.T) {
|
||||
now := time.Unix(100, 0)
|
||||
limiter := newQueryLimiter(func() time.Time { return now }, 2, time.Minute)
|
||||
limiter.allow("project:old-a")
|
||||
limiter.allow("project:old-b")
|
||||
|
||||
now = now.Add(2 * time.Minute)
|
||||
limiter.allow("project:current")
|
||||
|
||||
if len(limiter.entries) != 1 {
|
||||
t.Fatalf("entries=%d, want only the current window entry", len(limiter.entries))
|
||||
}
|
||||
if _, ok := limiter.entries["project:current"]; !ok {
|
||||
t.Fatal("current limiter entry was removed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoginLimiterBlocksAfterTenFailures(t *testing.T) {
|
||||
now := time.Unix(100, 0)
|
||||
limiter := newLoginLimiter(func() time.Time { return now })
|
||||
|
||||
Reference in New Issue
Block a user