INNER CODE UNIT · Python

_client_ip

Kounex/obs_blade · tool/kick_auth_proxy/proxy.py:309

        def _client_ip(self) -> str:
            forwarded = self.headers.get("CF-Connecting-IP", "").strip()
            if forwarded:
                return forwarded
            return self.client_address[0]

        def _read_json(self) -> dict:
            length = int(self.headers.get("Content-Length", "0") or "0")
            if length <= 0 or length > MAX_BODY:
                raise ProxyError(400, "invalid_request")
            raw = self.rfile.read(length)
            try:
                parsed = json.loads(raw.decode("utf-8"))
            except json.JSONDecodeError as error:
                raise ProxyError(400, "invalid_request") from error
            if not isinstance(parsed, dict):
                raise ProxyError(400, "invalid_request")
            return {str(key): str(value) for key, value in parsed.items()}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…