INNER CODE UNIT · Python
ProxyError
Kounex/obs_blade · tool/kick_auth_proxy/proxy.py:77
class ProxyError(Exception):
def __init__(self, status: int, message: str):
super().__init__(message)
self.status = status
self.message = message
def _allow(ip: str, now: float | None = None) -> bool:
moment = time.monotonic() if now is None else now
bucket = _hits[ip]
while bucket and moment - bucket[0] > WINDOW_SECONDS:
bucket.popleft()
if len(bucket) >= MAX_PER_WINDOW:
return False
bucket.append(moment)
return True