Initial certificate system

This commit is contained in:
nelso
2026-06-06 19:32:24 +08:00
commit ce4ed6213b
105 changed files with 9133 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import time
_hits: dict[str, list[float]] = {}
def hit_too_often(key: str, limit: int, window_seconds: int) -> bool:
now = time.time()
start = now - window_seconds
recent = [value for value in _hits.get(key, []) if value >= start]
recent.append(now)
_hits[key] = recent
return len(recent) > limit