From bc195a29f0bce2af8ca3f96d08c632f527cbb1c8 Mon Sep 17 00:00:00 2001 From: g0ldyy <153996346+g0ldyy@users.noreply.github.com> Date: Fri, 2 Jan 2026 14:30:52 +0100 Subject: [PATCH] refactor: rename `is_correct_ip` function to `is_public_ip` for improved clarity --- comet/utils/network.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/comet/utils/network.py b/comet/utils/network.py index 400ae06..2fc67c0 100644 --- a/comet/utils/network.py +++ b/comet/utils/network.py @@ -28,7 +28,7 @@ IP_REQUEST_HEADERS = [ ] -def is_correct_ip(ip: str): +def is_public_ip(ip: str): try: parsed_ip = ipaddress.ip_address(ip) return not parsed_ip.is_private and not parsed_ip.is_loopback @@ -45,13 +45,13 @@ def get_client_ip(request: Request): if header == "X-Forwarded-For": for ip_part in header_value.split(","): ip_part = ip_part.strip() - if is_correct_ip(ip_part): + if is_public_ip(ip_part): return ip_part else: - if is_correct_ip(header_value): + if is_public_ip(header_value): return header_value - if request.client and request.client.host and is_correct_ip(request.client.host): + if request.client and request.client.host and is_public_ip(request.client.host): return request.client.host return ""