feat log use_x_forwarded_for

This commit is contained in:
Ishaan Jaff 2024-08-13 15:22:54 -07:00
parent ab208eb546
commit 0c6c350c23

View file

@ -177,7 +177,17 @@ async def add_litellm_data_to_request(
requester_ip_address = ""
if premium_user is True:
# Only set the IP Address for Enterprise Users
# logic for tracking IP Address
if (
general_settings is not None
and general_settings.get("use_x_forwarded_for") is True
and request is not None
and hasattr(request, "headers")
and "x-forwarded-for" in request.headers
):
requester_ip_address = request.headers["x-forwarded-for"]
elif (
request is not None
and hasattr(request, "client")
and hasattr(request.client, "host")