INNER CODE UNIT · Python

_read

cipi-sh/cipi · lib/cipi-crowdsec-rescue.py:51

def _read(path: str) -> str:
    with open(path, "r", encoding="ascii") as fh:
        return fh.read().strip()


def _peer_ip(handler: BaseHTTPRequestHandler) -> str:
    # Socket peer only. Headers that claim a client IP are ignored on purpose.
    host = handler.client_address[0]
    if host.startswith("::ffff:"):
        host = host[7:]
    return host


def _rate_ok(ip: str) -> bool:
    now = time.monotonic()
    with _fails_lock:
        q = _fails[ip]
        while q and now - q[0] > WINDOW:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…