diff --git a/cista/app.py b/cista/app.py index df5a0c1..a8ff2e3 100644 --- a/cista/app.py +++ b/cista/app.py @@ -94,7 +94,7 @@ async def log_access(req, res): return res start = getattr(req.ctx, "_log_start", None) duration_ms = (time.perf_counter() - start) * 1000 if start is not None else 0.0 - client = req.ip or "-" + client = req.client_ip or "-" host = req.host or "-" path = req.path if req.query_string: diff --git a/cista/sanic_logging.py b/cista/sanic_logging.py index 69504a3..b26163f 100644 --- a/cista/sanic_logging.py +++ b/cista/sanic_logging.py @@ -55,8 +55,8 @@ def format_client_ip(ip: str) -> str: return "-" stripped = ip.strip("[]") if ":" in stripped: - return format_ipv6_network(ip) - return ip + return format_ipv6_network(stripped) + return stripped def status_color(status: int) -> str: @@ -144,7 +144,7 @@ def log_ws_open(request, extra: str | None = None) -> int: """Log WebSocket connection open. Returns connection ID for use in log_ws_close.""" ws_id = _next_ws_id() - client = request.ip or "-" + client = request.client_ip or "-" host = request.host or "-" path = request.path origin = request.headers.get("origin")